| Summary: | A bug in every game written in Opengl and SDL togetehr | ||
|---|---|---|---|
| Product: | SDL | Reporter: | korn800 |
| Component: | events | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | don't know | ||
| Hardware: | x86 | ||
| OS: | Windows (XP) | ||
hey, I've just solved the problem. It turned out that its window's fault when the user has sticky keys switched off... Sorry for trouble :P, anyway is there any way to switch on sticky keys always when running my game? Greetings I've no idea. I'm glad you figured it out though! :) |
Hey guys I've recently came across a very strange and annoying bug that occurs in every game written in opengl combined with SDL. When there's an animation on the screen and you push quickly shift and ctrl multiple times then the animation laggs. I dont know why but it happens only when using Opengl and SDL together. Separately there is no such bug. Im using Windows and its not fault of my keyboard or sth. But this bug doesnt happen on all OS and computers however many of my friends have this bug also. I have been looking for solution a couple of days and no one has managed to solve this yet :(. Any ideas what's wrong and how to fix it? I'm looking forward to hear from you ^^. Here the sample code (hold arrow to start the animation and press quickly shift and ctrl multiple times. That will cause laggs in animation): #include <gl/gl.h> #include <sdl/sdl.h> #include <sdl/sdl_opengl.h> void Run(); void ProcessEvents(); void Draw(); int ScrWidth = 800, ScrHeight = 450; SDL_Surface * Screen; SDL_Event event; Uint8 * key = SDL_GetKeyState( NULL ); bool End; int pos_x = 200; bool right = false, left = false; int main( int argc, char * argv[] ) { Run(); } void ProcessEvents() { if( End ) return; while( SDL_PollEvent( & event ) && event.type != SDL_MOUSEMOTION ) { if( event.type == SDL_QUIT ) { End = true; break; } } } void Run() { SDL_Init( SDL_INIT_EVERYTHING ); Screen = SDL_SetVideoMode( ScrWidth, ScrHeight, 32, SDL_OPENGL | SDL_HWSURFACE | SDL_GL_MULTISAMPLEBUFFERS ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); glClearColor( 0, 0, 0, 0 ); glViewport( 0, 0, ScrWidth, ScrHeight ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0, ScrWidth, ScrHeight, 0, - 1, 1 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); while( !End ) { ProcessEvents(); Draw(); } SDL_FreeSurface( Screen ); } void Draw() { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); if( key[ SDLK_LEFT ] ) pos_x -= 1; if( key[ SDLK_RIGHT ] ) pos_x += 1; glBegin( GL_QUADS ); glColor3f( 1, 0, 0 ); glVertex3f( 0, 0, 0 ); glColor3f( 1, 1, 0 ); glVertex3f( pos_x, 0, 0 ); glColor3f( 1, 0, 1 ); glVertex3f( pos_x, 100, 0 ); glColor3f( 1, 1, 1 ); glVertex3f( 0, 100, 0 ); glEnd(); SDL_GL_SwapBuffers(); }