View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# glGenBuffers was not declared in this scope

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

31 replies to this topic

### #1Riztro  Members

Posted 05 February 2011 - 11:41 AM

Well I am trying to learn Vertex Arrays and VBOs. I didn't really want to learn VAs but I tried them anyway and couldnt draw anything. I think that because its deprecated. But then I tried VBOS and I am trying to use the GenBuffer,BindBuffer, etc. for using VBOS and it gives me these errors:
glGenBuffers not declared in this scope
GL_ARRAY_BUFFER not declared in this scope
glBindBuffer not declared in this scope
GL_DYNAMIC_DRAW not declared in this scope
glBufferData not declared in this scope

I am using opengl 3.3 and I have included gl.h and glu.h and windows.h.

I only have probelms with these functions..

Posted 05 February 2011 - 11:56 AM

You need the extensions. Google glew (glew.sourceforge.net). I think thats the address still. Everything in openGL is extended. gl.h is the original standard, every addition such as VBO's are separate for compatability.

### #3Riztro  Members

Posted 05 February 2011 - 12:13 PM

You need the extensions. Google glew (glew.sourceforge.net). I think thats the address still. Everything in openGL is extended. gl.h is the original standard, every addition such as VBO's are separate for compatability.

Thanks! Now I have another problem though. I downloaded glew but now I am getting this error:
error: cannot convert 'GLfloat' to 'const GLvoid*' in argument passing

on this function: glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*3, vbodat[0], GL_DYNAMIC_DRAW);

Posted 05 February 2011 - 12:17 PM

vbdat[0] is a float, you want to pass the address of your data ........., &(vbodat[0])

### #5Riztro  Members

Posted 05 February 2011 - 12:28 PM

vbdat[0] is a float, you want to pass the address of your data ........., &(vbodat[0])

Oh thanks! But now I am getting this:
|undefined reference to _imp____glewGenBuffers'
same error for bindbuffer and bufferdata.
I have the lib in lib directory of codeblocks.
I have the dll in the folder too...
I have also tried linking it with link libs and found the file directly..

Posted 05 February 2011 - 12:38 PM

I'm just using glew32.lib, dont know if they changed the name. You need to make sure it knows that path, otherwise just copy the whole filepath (+ .lib) and see if that works.

### #7Riztro  Members

Posted 05 February 2011 - 01:53 PM

I'm just using glew32.lib, dont know if they changed the name. You need to make sure it knows that path, otherwise just copy the whole filepath (+ .lib) and see if that works.

Ya I have a glew32.lib and a glew32s.lib for static.. I dont know why it isnt linking.

Posted 05 February 2011 - 02:10 PM

glewGenBuffers its just glGenBuffers

### #9Riztro  Members

Posted 05 February 2011 - 02:27 PM

glewGenBuffers its just glGenBuffers

Ya I know, I think I am just linking wrong or their is something wrong with my code. How do u link it?
I have the dll's and the libs... Dont I just need to have the dll and the header included to use this? Can I avoid libs?

Posted 05 February 2011 - 02:32 PM

I use visual studio and just have the exact file path in the linker box. Try commenting out your glew related code, and see if you get an error that it cant find glew32.lib.

### #11Riztro  Members

Posted 05 February 2011 - 02:36 PM

I use visual studio and just have the exact file path in the linker box. Try commenting out your glew related code, and see if you get an error that it cant find glew32.lib.

Well I got it working partly working statically but not dynamically. I can build the project but can execute it.

EDIT: It just stopped working.. Any tutorials for codeblocks you know of?

### #12Yours3!f  Members

Posted 05 February 2011 - 02:49 PM

Hi TTT_Dutch,

you dont need glew for using glGenBuffers,

just do the following:

before including SDL, glut or whatever window handling system you use type the following line:

#define GL_GLEXT_PROTOTYPES

voila, you should be able to use it.

for some functions like glGenRenderbuffers() you need to use the following instead:

glGenRenderbuffersEXT()

Hope I could help,
Yours3!f

### #13Riztro  Members

Posted 05 February 2011 - 02:54 PM

Hi TTT_Dutch,

you dont need glew for using glGenBuffers,

just do the following:

before including SDL, glut or whatever window handling system you use type the following line:

#define GL_GLEXT_PROTOTYPES

voila, you should be able to use it.

for some functions like glGenRenderbuffers() you need to use the following instead:

glGenRenderbuffersEXT()

Hope I could help,
Yours3!f

Thats not working.. I still get the original errors.

### #14Riztro  Members

Posted 05 February 2011 - 03:49 PM

Ok now I can link it statically but not dynamically... But when I run it, its crashes...

### #15Riztro  Members

Posted 05 February 2011 - 03:51 PM

Now I know its my code because I commented out all the glew functions and the program ran. Unless calling the lib makes it crash...

It seems like anything that is called form glew makes the program crash or not start. So...

EDIT: tried wglew and got wierd errors. Then I moved it below gl included files and I got original errors.

### #16cstony  Members

Posted 05 February 2011 - 04:08 PM

Now I know its my code because I commented out all the glew functions and the program ran. Unless calling the lib makes it crash...

It seems like anything that is called form glew makes the program crash or not start. So...

EDIT: tried wglew and got wierd errors. Then I moved it below gl included files and I got original errors.

Are you calling glewInit() after you have created your OpenGL context? and is it successful?

### #17Riztro  Members

Posted 05 February 2011 - 04:30 PM

Now I know its my code because I commented out all the glew functions and the program ran. Unless calling the lib makes it crash...

It seems like anything that is called form glew makes the program crash or not start. So...

EDIT: tried wglew and got wierd errors. Then I moved it below gl included files and I got original errors.

Are you calling glewInit() after you have created your OpenGL context? and is it successful?

Thanks! I feel so dumb! Still cant get it working dynamically though.. But now I cant get the vbo's working... I use them like this

GLuint vbo;
GLfloat vbodat[12] =
{0,0,20,
0,20,20,
20,20,20,
20,0,20};

glEnableClientState(GL_VERTEX_ARRAY);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*3, &vbodat[0], GL_DYNAMIC_DRAW);

Then in the loop

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT, 0, BUFFER_OFFSET(0));
glDisableClientState(GL_VERTEX_ARRAY);

### #18cstony  Members

Posted 05 February 2011 - 05:41 PM

When you are linking against the dynamic libs make sure you don't use #define GLEW_STATIC 1 anywhere. You may not have commented it out or something.The second parameter of glBufferData is the size of the data to upload in bytes. The second parameter should be sizeof(GLfloat) * 12.
Also the params for glDrawArrays should be (GL_QUADS, 0, 4)

### #19Riztro  Members

Posted 05 February 2011 - 06:05 PM

When you are linking against the dynamic libs make sure you don't use #define GLEW_STATIC 1 anywhere. You may not have commented it out or something.The second parameter of glBufferData is the size of the data to upload in bytes. The second parameter should be sizeof(GLfloat) * 12.
Also the params for glDrawArrays should be (GL_QUADS, 0, 4)

The GL_quad adjustmnet causes crash. BTW the dynamic this still doesnt work. All I do is link it and nothing..

### #20cstony  Members

Posted 06 February 2011 - 07:08 AM

When you are linking against the dynamic libs make sure you don't use #define GLEW_STATIC 1 anywhere. You may not have commented it out or something.The second parameter of glBufferData is the size of the data to upload in bytes. The second parameter should be sizeof(GLfloat) * 12.
Also the params for glDrawArrays should be (GL_QUADS, 0, 4)

The GL_quad adjustmnet causes crash. BTW the dynamic this still doesnt work. All I do is link it and nothing..

OK, let's not worry about the dynamic linking for the moment (one problem at a time). You should have something like this now:

GLuint vbo;
GLfloat vbodat[12] = { 0.0f,  0.0f, 20.0f,
0.0f, 20.0f, 20.0f,
20.0f, 20.0f, 20.0f,
20.0f,  0.0f, 20.0f};

glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*12, &vbodat[0], GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, NULL);


Now make sure you bind the VBO when you do your drawing:

glBindBuffer(GL_ARRAY_BUFFER, vbo);

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT, 0, 0);
`