PDA

View Full Version : glGetStringi how make it work?



ewerton
01-04-2013, 05:08 AM
I want to know the opengl extensions, using glGetStringi, but the code doesn't compile. What the include for glGetStringi?
I'm using Code::Blocks with mingw on windows 7.

My code:

#include <iostream>
#include "GL/gl.h"
#include <windows.h>

using namespace std;

int main()
{
int max = 0;
glGetIntegerv(GL_EXTENSIONS, &max);

for(int i = 0; i < max; i++)
cout << glGetStringi(GL_EXTENSIONS, i) << endl;


return 0;
}

thokra
01-04-2013, 05:36 AM
Care to share the actual compiler error? :confused:

ewerton
01-04-2013, 05:45 AM
The error is:
'glGetStringi' was not declared in this scope

thokra
01-04-2013, 06:26 AM
Ah yes, glGetStringi is a GL 3.0 or higher function IIRC. The standard GL header shipped with Windows, however, exposes only GL 1.1 functionality. Checkout glLoadGen (https://bitbucket.org/alfonse/glloadgen/wiki/Home) or GLEW (http://glew.sourceforge.net/).

Correction: Your header is shipped with MinGW. Still, MinGW's gl.h doesn't expose GL 3.0 or higher functions. The advice stays the same.

Dan Bartlett
01-04-2013, 06:34 AM
glGetStringi was only added to OpenGL in version 3.0, and the gl.h provided by Microsoft only includes OpenGL 1.1 entry points, so you will need to include extra code to the retrieve the function pointers (http://www.opengl.org/wiki/Load_OpenGL_Functions), or use tools that do this for you (http://www.opengl.org/wiki/OpenGL_Loading_Library)

ewerton
01-04-2013, 07:44 AM
I got GLEW_OK on glewInit, but glGetStringi don't compile, I got undefined reference. What shall be wrong?
glewExperimental is a undefined reference too.

tonyo_au
01-04-2013, 04:26 PM
I am not sure what glew you are using but glGetStringi works find for me. Check your glew.h.

Alfonse Reinheart
01-04-2013, 04:52 PM
You're getting linker errors because you're probably linking with the wrong libraries (or not linking with them at all). Honestly, if you want this to be much simpler, just use glLoadGen and include the source/headers into your project directly.

ewerton
01-06-2013, 01:33 PM
I added glew source files to my project and it worked. Now I can call the extensions!
Thank you =)