Updating an SDL/OpenGL context...
...or, "how are you supposed to?"
At the moment, the context is only update if it receives an external event (ie. resizing the context) - I've tried to force it to update by SDL_UnlockSurface followed by SDL_UpdateRect, but this merely crashes the app... any suggestions?
At the moment, the context is only update if it receives an external event (ie. resizing the context) - I've tried to force it to update by SDL_UnlockSurface followed by SDL_UpdateRect, but this merely crashes the app... any suggestions?
Mark Bishop
The source might be helpful...
Yes, I know, lots of labels, bad bad sealfin...
Code:
int main(int argc,
char *argv[])
{
SDL_Surface *theSurface;
SDL_Event theEvent;
const Uint32 theInitialisationFlags = ( SDL_INIT_VIDEO ),
theVideoFlags = ( SDL_OPENGL );
const Uint16 theWidth = 640,
theHeight = 480;
const Uint8 theDepth = 16;
Uint8 whetherFullscreen = false;
if( SDL_Init( theInitialisationFlags ) != 0 )
goto label_quit;
if(( SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ) != 0 )
|| ( SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ) != 0 )
|| ( SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 ) != 0 )
|| ( SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 ) != 0 )
|| ( SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 ) != 0 ))
goto label_quit;
label_video_initialisation:
if(( theSurface = SDL_SetVideoMode( theWidth, theHeight, theDepth, ( theVideoFlags | ( SDL_FULLSCREEN * whetherFullscreen )))) == NULL )
goto label_quit;
// Sets the fill-colour to a RGBA colour, and fills the context with that colour.
glClearColor(0.30, 0.38, 0.60, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
// The context is not updated until the 'glFinish()'.
glFinish();
// we like to crash you...
SDL_UnlockSurface( theSurface );
SDL_UpdateRect( theSurface, 0, 0, 0, 0 );
//
label_loop:
while( SDL_PollEvent( &theEvent ))
if( theEvent.type == SDL_KEYDOWN )
switch( theEvent.key.keysym.sym )
{
case SDLK_ESCAPE:
goto label_quit;
case SDLK_f:
whetherFullscreen ^= true;
SDL_FreeSurface( theSurface );
goto label_video_initialisation;
default:;
}
goto label_loop;
label_quit:
SDL_Quit();
return 0;
}Mark Bishop
Found the error - a slight oversight, I'd created a double buffered context, but never swapped the buffers...
Mark Bishop
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Full screen context doesn't remain the current context | Malarkey | 3 | 2,966 |
Feb 1, 2007 05:27 PM Last Post: OneSadCookie |
|
| cocoa for nibbies [OpenGL context creation/ Initializing a PixelFormat] | Byron Clarke | 7 | 3,565 |
Jun 23, 2005 01:23 AM Last Post: Byron Clarke |
|
| Screenshot of OpenGL context | aarku | 6 | 6,328 |
Jul 23, 2004 07:05 PM Last Post: aarku |
|
| Placing Quesa Objects in an OpenGL Context? | lpetrich | 2 | 2,484 |
Feb 13, 2003 06:53 AM Last Post: -dair |
|
| OpenGL context and Windows/Dialogs | oxenos | 4 | 3,064 |
Dec 30, 2002 06:25 AM Last Post: oxenos |
|

