Sign in to follow this  

using OpenGL buffer objects with SDL

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, I have written an OpenGL application using SDL. Now I'd like to extend my application with pixel buffer objects. However I was not able to compile the code because glGenBuffers/glBindBuffer/glBufferData: identifier not found. I put #define GL_GLEXT_PROTOTYPES in front of #include SDL_OpenGL.h and was able to compile but not link my code because glGenBuffers/glBindBuffer/glBufferData: unresolved external symbol. How can I get this to work ? tahnks, quak

Share this post


Link to post
Share on other sites
You're using old opengl headers and/or libraries. You'll need to either get updated ones, or use the equivalent extensions.

Unfortunately, I think vs.net doesn't come with up to date opengl libs and headers. Don't quote me on that though.

Share this post


Link to post
Share on other sites
Yes, I know about Glee, however if I include the header additionally to my SDL_OpenGL.h I can't compile because of redefinitions. If I comment out these definitions in the SDL header I can compile but gleeInit() fails.

Share this post


Link to post
Share on other sites
Thanks, that worked. I included GLee.h and GLee.c in my project and I link against OpenGL32.lib. Linking against GLee.lib resulted in a "cannot find LIBC.LIB" error. However, if I use glGenBuffers it returns 0 which is wrong of course. I am using VC Express 2005 by the way.

Share this post


Link to post
Share on other sites
Quote:
However, if I use glGenBuffers it returns 0 which is wrong of course

Maybe, maybe not. You need to query your driver and see which version of OpenGL it exposes. Call glGetString(GL_VERSION) to see the version of OpenGL you are actually dealing with as reported by your driver. If it is less than 2.1, then that is why you are not able to use those functions. The solution is usually to update your video card driver.

Share this post


Link to post
Share on other sites
glGetString(GL_VERSION) returns <NULL>.
If I call GLeeInit() and GLeeGetErrorString() afterwards, it returns "GL extension querying failed".
I am sure that my driver and hardware supports buffer objects because I can run different applications that use them.

Share this post


Link to post
Share on other sites
Sounds like you are making OpenGL calls before the rendering context is created. Could you post some code. I am mostly concerned with the order of your calls to SDL_Init, SDL_SetVideoMode, and then any OpenGL calls. Also, you should make sure all your SDL_Init and SDL_SetVideoMode are succeeding, and to be safe you could query SDL_GetAttribute to see what the actual values are for your OpenGL attributes. You may need to manually call SDL_GL_SetAttribute to specify your color and depth buffer bits if SDL_SetVideoMode is failing.

Share this post


Link to post
Share on other sites
My code looks like this:

int main( int argc, char* argv[] )
{
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER ) < 0 )
return -1;

g_engine.init( 512, 512 );

...
}

void Engine::init( const uint resX, const uint resY ){

glEnable( GL_TEXTURE_2D );
glGenBuffers( 1, &pbo );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, 0 );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, pbo );
glBufferData( GL_PIXEL_UNPACK_BUFFER_ARB, 2048*2048*4, 0, GL_STREAM_DRAW_ARB );

...
}

Share this post


Link to post
Share on other sites
It comes after the code I posted. I moved the opengl code after setVideoMode() and now glGenBuffers returns 1. GL_VERSION is 2.1.2. Thank you very much for your fast replys, now I can sleep well :)

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this