nigels-com / glew

The OpenGL Extension Wrangler Library
Other
2.58k stars 609 forks source link

glewInit failed: Missing GL version #344

Closed VladimirBessonov closed 2 years ago

VladimirBessonov commented 2 years ago

the code below works fine on windows, but returns glewInit failed: Missing GL version on macos. Please advise `

include

include

include

using namespace std;

void init(GLFWwindow window) { } void display(GLFWwindow window, double currentTime) { glClearColor(1.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); } int main(void) { if (!glfwInit()) { exit(EXIT_FAILURE); } glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); GLFWwindow* window = glfwCreateWindow(600, 600, "Chapter2 - program1", NULL, NULL); glfwMakeContextCurrent(window); glewExperimental = GL_TRUE;

if (glewInit() != GLEW_OK) { GLenum err=glewInit(); cout << "glewInit failed: " << glewGetErrorString(err) << endl; exit(EXIT_FAILURE); } glfwSwapInterval(1); init(window); while (!glfwWindowShouldClose(window)) { display(window, glfwGetTime()); glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); glfwTerminate(); exit(EXIT_SUCCESS); }

`

nigels-com commented 2 years ago

Are you sure you have an OpenGL context? Would be worth checking.

VladimirBessonov commented 2 years ago

if it is running in visual studio, could it be there there is no OpenGL context? Is it a bot that replies?

nigels-com commented 2 years ago

See: https://www.glfw.org/faq.html#41---how-do-i-create-an-opengl-30-context

I'm not sure that 4.3 context is available on macos.