![]() |
SDL and OpenGL Issues | ![]() |
![]() |
SDL and OpenGL Issues | ![]() |
Simon Roby
Guest
![]() |
![]() |
1) Last time I checked, on most platforms the GL context is completely
lost when switching between windowed and full screen. To be sure you won't lose everything you have to recreate everything after switching (textures, etc.). 2) To reduce tearing you have to enable vertical blank syncing. Double buffering is good towards reducing tearing, but not enough by itself because the actual "physical" redraws can still happen while a frame is in the middle of being thrown to the screen, which is what causes tearing. The attribute you need is SDL_GL_SWAP_CONTROL. Keep in mind your platform may not support it, though. Most video drivers (AMD and nVidia, on Windows or Linux) also allow you to force vsync on all OpenGL viewports, so you can try that too. -- - SR On Mon, Sep 14, 2009 at 16:01, Patricia Curtis wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||
|
![]() |
SDL and OpenGL Issues | ![]() |
Bruno Adami
Guest
![]() |
![]() |
Thats one alternative!
In my code I put a rest(1) (on windows I need to use timeBeginPeriod to set the timer precision to 1 ms ![]() ![]() Then I show a warning message saying that vsync could not be enabled. So the game will run on different speeds from pc to pc? No! I dont use the fps to update my logic, I just use it to calc the time it takes every frame and make the lpf calculation (logics per frame), than the logic loop of the game will run 'lpf' times! Something like this: Game loop begin - Start counting time / reset counting time - Draw things - SDL_GL_SwapBuffers and SDL_Delay(1) - Get counted time and make calculation of lpf - Update the logic 'lpf' times Game loop end The calculation would be something like this: double lpfAux = 0; // Out of the Game loop scope ... int elapsed = timer.elapsedTime(); // Do something to get the elapsed time up ther lpfAux = (elapsed/LPS_WAIT); // LPS_WAIT = 1000/Logic per Second, its a double!!! lpf = (int)lpfAux; // Convert it to int and put on lpf lpfAux -= lpf; // Lets subtract from lpfAux, its to accurate the lpf calculation, elapsed/LPS_WAIT wont give us a integer number ... for (int x = 0;x < lpf;x++) // Logic loop ... You can choice the best alternative that fits in your game! You only need to update the logic of your game uniformly not depending on a fix FPS value! Of course only if you intend to use vsync which I think its a great advantage. (it can have some small errors, like on one second it update 1002 times, so on the other second it will update 998 times, there are other techniques, like delta time) Bruno
|
||||||||||||||
|
![]() |
SDL and OpenGL Issues | ![]() |
Simon Roby
Guest
![]() |
![]() |
Well you should never rely on vsync for managing game logic time anyway.
A properly written game logic loop will work fine regardless of the presence of vsync or not. At worst vsync will create some minor overhead due to the extraneous sleeps. -- - SR On Tue, Sep 15, 2009 at 15:35, Bruno Adami wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||||||
|
![]() |
SDL and OpenGL Issues | ![]() |
kiaran
Guest
![]() |
![]() |
Hello,
When an SDL window is resized or switched between fullscreen/windowed modes it will destroy and recreate the OpenGL context. You will need to reload your textures into video memory which is why you are seeing a black screen. Not sure about the tearing problem. Maybe something to do with vsync being enabled/disabled? Just a guess though. Good luck, Kiaran Patricia Curtis-2 wrote:
-- View this message in context: http://www.nabble.com/SDL-and-OpenGL-Issues-tp25442541p25445086.html Sent from the SDL mailing list archive at Nabble.com. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||
|
![]() |
SDL and OpenGL Issues | ![]() |
Patricia Curtis
Guest
![]() |
![]() |
Thanks for your help guys, its all sorted now, the black textures were
an issue with my texture creator, and i have adopted a combination of your responses for the vblank issue SDL_GL_SwapBuffers(); StartTicks = EndTicks; EndTicks = SDL_GetTicks(); DeltaTick = ((EndTicks - StartTicks) / 15.0); RunTransition(); // this code use the DeltaTick as an multiplier for the movements of the front end eg // ScrollPos++; is now ScrollPos+=(1*DeltaTick); // now because there were too many changes needed in the animation code (game 90% complete) // i go through my animation loop a number of times depending how slow the last frame was while(AnimationTimes>1) { AnimationLoop(0, NULL); AnimationTimes--; } AnimationTimes+=DeltaTick; obviously i set the tick counts up before my main loop StartTicks = SDL_GetTicks(); EndTicks = SDL_GetTicks(); DeltaTick = (double)((EndTicks - StartTicks) / 15.0); also if i do a load of an image during my main loop i reset the counters after the load so there are no large jumps in the frame rate StartTicks = SDL_GetTicks(); Thanks a million _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||
|