[c++] glew doesn't work

This topic is 1395 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello everyone!

• [08-11-14] GLEW 1.11.0 adds support for OpenGL 4.5, new extensions

then i added glew.c to my project also called glewInit() it returned 1 but after using any opengl function what glew includes the app crash.

I think it doesn't initialize those functions, tried to debug it but it won't let me include iostream for cout, after i include it cmath starts to show random errors ...

i also: #define GLEW_STATIC

What is going on guys?

Thanks!

Share on other sites

Not sure if it's the problem but have you tried to set glewExperimental = true before initialize?

http://glew.sourceforge.net/basic.html

"GLEW obtains information on the supported extensions from the graphics driver. Experimental or pre-release drivers, however, might not report every available extension through the standard mechanism, in which case GLEW will report it unsupported. To circumvent this situation, the glewExperimental global switch can be turned on by setting it to GL_TRUE before calling glewInit(), which ensures that all extensions with valid entry points will be exposed."

Share on other sites

now i did it and still crashing...

	glewExperimental = true;
cout << "s:" << (int)glewIsSupported("glCreateShader") << endl;
cout << "state:" << glewInit() << endl;
cout << "u:" << glGetString(GL_VERSION) << endl;


// cout

s:0
state:1

u:

// crash

Share on other sites
Why are you calling a glew* function before glewInit? Don't do that.

Do you have a GL context created and set active for the current thread for the gl* functions? Those only work with a context.

While not necessarily the problem with the specific example above, also be aware that GLEW doesn't magically make GL 4.5 work. Your driver still has to actually support it, which only one single driver on a small range of recent hardware does (NVIDIA on Kepler or Maxwell). If you tried to create a 4.5 context and assumed that it worked, there's a good chance it didn't and that you don't actually have a valid context.

Share on other sites
	cout << "state:" << glewInit() << endl;
cout << "s:" << (int)glewIsSupported("glCreateShader") << endl;
cout << "u:" << glGetString(GL_VERSION) << endl;


state:1

s:0

u:

My computer support the latest opengl, it was working with GLee or something.
Anyways, i was able to use all those latest functions and everything worked fine.

that worked fine.
Also getting those opengl func manually work fine but because there are just so many functions i wanted to include glew.

Share on other sites
First, glewInit is failing. 1 is not a good return value in most C-like APIs, as it's normal for C functions to return 0 on success and some non-zero value to indicate a specific error (or -1 for general errors). glewInit should be returning GLEW_OK if everything is working. The return value of 1 however corresponds to GLEW_ERROR_NO_GL_VERSION which means that most likely you did not create or bind a GL context properly before calling glewIinit (which also explains why a simple glGetString is crashing, as you cannot call gl* functions without a bound context in the current thread).

You need to be sure you're creating a context in the appropriate way for your platform (or using a helper library like GLFW, SDL, SFML, etc.) and that it's bound to the current thread (again, platform-dependent or via a helper library).

If you already are creating a context created somewhere else in code you're not showing us, just remember: create GL context /first/, initialize GLEW /second/.

Minor additional pointer: your use of glewIsSupported is wrong. It checks for extensions, not for entry points. glewIsSupported is correctly returning 0 as 'glCreateShader' is not the name of an extension (it would be 'GL_ARB_shading_language_100' or something like that, if you had any reason to check for it, which you don't). glCreateShader is a core function in GL 2.0+ so if you've created a context of that version or higher it's guaranteed to be present and there's no reason to check for it.

Share on other sites

Yay! that was what i was looking for.

wglMakeCurrent became after that glewinit, now its working.
@SeanMiddleditch thank you so much <3

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
12

• 14
• 22
• 9
• 31
• 18
• Forum Statistics

• Total Topics
632618
• Total Posts
3007478
• Who's Online (See full list)

There are no registered users currently online

×