OpenGL integration with SDL, problem
-
I am trying to create a simple game framework that covers all the boilerplate code involved with initializing a opengl/sdl window. I am having a problem getting it to work properly though. I know for sure that I initialized the screen SDL_surface properly but that is about it (the screen goes black); none of the opengl commands work properly. I added code to check to make sure the loop is working (it is). I'm well versed in Opengl but am an SDL noob. Its probably something small I screwed up or overlooked but I cannot figure it out, help on the topic of opengl integration with SDL is scarce. Here is a link to my code. http://pastebay.com/106583[^] If anyone knows what the problem is, I would greatly appreciate some help with this problem.
-
I am trying to create a simple game framework that covers all the boilerplate code involved with initializing a opengl/sdl window. I am having a problem getting it to work properly though. I know for sure that I initialized the screen SDL_surface properly but that is about it (the screen goes black); none of the opengl commands work properly. I added code to check to make sure the loop is working (it is). I'm well versed in Opengl but am an SDL noob. Its probably something small I screwed up or overlooked but I cannot figure it out, help on the topic of opengl integration with SDL is scarce. Here is a link to my code. http://pastebay.com/106583[^] If anyone knows what the problem is, I would greatly appreciate some help with this problem.
I haven't looked at the code, but... Try specifying a non-black glClearColor value and then call glClear (with the GL_COLOR_BUFFER_BIT flag set, along with, probably, GL_DEPTH_BUFFER_BIT) at the beginning of your rendering loop (comment out any other rendering calls, so you don't overwrite the intialized contents of the buffer). If the GL window changes color, then you probably have it initialized correctly. If that's the case, double and triple check your camera orientation and the location of any test object you're trying to render. Very often, if you have a black screen and can't see anything you're rendering, it's because the camera is pointing in the wrong direction.
L u n a t i c F r i n g e
-
I haven't looked at the code, but... Try specifying a non-black glClearColor value and then call glClear (with the GL_COLOR_BUFFER_BIT flag set, along with, probably, GL_DEPTH_BUFFER_BIT) at the beginning of your rendering loop (comment out any other rendering calls, so you don't overwrite the intialized contents of the buffer). If the GL window changes color, then you probably have it initialized correctly. If that's the case, double and triple check your camera orientation and the location of any test object you're trying to render. Very often, if you have a black screen and can't see anything you're rendering, it's because the camera is pointing in the wrong direction.
L u n a t i c F r i n g e
I tried that, and I get nothing. I've based this on a port of the NeHe basecode to SDL, and even though I can see no differences in the method of either code, mine doesn't work. I tried calling gluLookat(), I tried translating the geometry to be in front of the camera, i tried making the backcolor something other than black, nothing works.
-
I am trying to create a simple game framework that covers all the boilerplate code involved with initializing a opengl/sdl window. I am having a problem getting it to work properly though. I know for sure that I initialized the screen SDL_surface properly but that is about it (the screen goes black); none of the opengl commands work properly. I added code to check to make sure the loop is working (it is). I'm well versed in Opengl but am an SDL noob. Its probably something small I screwed up or overlooked but I cannot figure it out, help on the topic of opengl integration with SDL is scarce. Here is a link to my code. http://pastebay.com/106583[^] If anyone knows what the problem is, I would greatly appreciate some help with this problem.
I didn't really looked at your code but I just want to let you know that there is probably a better alternative to SDL: take a look at SFML[^]. It's a more modern library which is similar to SDL but is fully object oriented (and much more efficient too). I suggest you take a look at the features page.
Cédric Moonen Software developer
Charting control [v3.0] OpenGL game tutorial in C++