std::cout << glGetString(GL_RENDER) << std::endl; Throws an Error but not GL_Renderer or GL_Verision and I can't figure out why?

0

First time asking a question on here so if it's not layed out correctly or something is missing I'll try to get everything else up.

I'm trying to learn OpenGl because I'm interested in developing games of my own and I would rather create my own engine than one already out there. I'm using GLEW also and I know it inits because the code doesn't output an Error

I spend alittle while googling the error code and the OpenGL but none of the problems really match what I'm getting. I also tried the GLEW_Experimental = true but that did not change anything.

Code: main

#include "src/graphics/window.h"

int main()
{
    using namespace FutureGamingEngine;
    using namespace graphics;



    Window window("Test", 1080, 720);
    glClearColor(0, 255, 0, 1.0f); //Red, Green, Blue, No Idea

    std::cout << glGetString(GL_VERSION) << std::endl;
    std::cout << glGetString(GL_RENDERER) << std::endl;
    std::cout << glGetString(GL_RENDER) << std::endl;



    while (!window.closed())
    {


        window.clear();

        glBegin(GL_QUADS);
        glVertex2f(-0.5f, -0.5f);
        glVertex2f(-0.5f, 0.5f);
        glVertex2f(0.5f, 0.5f);
        glVertex2f(0.5f,-0.5f);
        glEnd();
        window.update();
    }

    //system("PAUSE");

    return 0;
}

Window:

#include "window.h"

namespace FutureGamingEngine
{
    namespace graphics
    {

        void windowResize(GLFWwindow *window, int width, int height);

        Window::Window(const char *title, int width, int height)
        {
            c_title = title;
            c_height = height;
            c_width = width;
            if (!init())
            {
                glfwTerminate();
            }
        }

        Window::~Window()
        {
            glfwTerminate();
        }

        bool Window::init()
        {
            glewExperimental = true;

            if (!glfwInit())
            {
                std::cout << "Error Code: 0" << std::endl;
                return false;
            }


            //Create a windowed mode and it's OpenGl Content
            c_window = glfwCreateWindow(c_width, c_height, c_title, NULL, NULL);

            //If we fail to make the window Terminate OpenGL
            if (!c_window)
            {
                glfwTerminate();
                return false;
            }

            //std::cout << "Open GL: " <<  glGetString(GL_VERSION) << std::endl;

            glfwMakeContextCurrent(c_window);
            glfwSetWindowSizeCallback(c_window, windowResize);

            if (glewInit() != GLEW_OK)
            {
                std::cout << "Error Code: 1" << std::endl;
                return false;
            }       


            return true;

        }

        bool Window::closed() const
        {
            return glfwWindowShouldClose(c_window);
        }

        void Window::update()
        {
            //poll for and process events
            glfwPollEvents();

            glfwGetFramebufferSize(c_window, &c_width, &c_height);

            //swap front and backbuffers
            glfwSwapBuffers(c_window);
        }

        void Window::clear() const
        {
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        }

        void windowResize(GLFWwindow *window, int width, int height)
        {
            glViewport(0, 0, width, height);
        }
    }
}

The Header for window:

#pragma once

#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>

namespace FutureGamingEngine 
{
    namespace graphics
    {
        class Window
        {
        private:
            const char *c_title;
            int c_width, c_height;
            GLFWwindow *c_window;
            bool c_closed;
        public:
            Window(const char *a_name, int a_width, int a_height);
            ~Window();
            bool closed() const;
            void update();
            void clear() const;

            inline int getHeight() const { return c_height; };
            inline int getWidth() const { return c_width; };

        private:
            bool init();


        };
    }

}

I'm expecting it to tell me the Render Version. What I'm actually getting is Error Produced on std::cout << glGetString(GL_RENDER) << std::endl; :

Exception thrown at 0x7C50F6E0 (ucrtbased.dll) in FutureGamingEngine-Core.exe: 0xC0000005: Access violation reading location 0x00000000.

(https://i.imgur.com/uKu3hxX.png)

and the doesn't get to rendering the Triangle like it did prior to me asking for Gl_render

c++
opengl
visual-studio-2017
asked on Stack Overflow Oct 12, 2019 by OnlyMathias • edited Oct 12, 2019 by OnlyMathias

1 Answer

1

GL_RENDERER is valid enum, GL_RENDER is not. See OpenGL doc Thank you Ripi2! I apperently did not look hard enough :D

answered on Stack Overflow Oct 12, 2019 by OnlyMathias

User contributions licensed under CC BY-SA 3.0