The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Slow FPS in Fullscreen / Scaling
foundtimegames


Joined: 30 Jul 2014
Posts: 4
Location: Maine
Hello folks. I'm having some trouble...

My 2D game is hard-coded at 960x540. The fullscreen resolution is 1366x768, and I'm using SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear") and SDL_RenderSetLogicalSize(renderer, 960,540) to do the scaling. In windowed mode, I get 60+ FPS. When scaling for fullscreen, I get ~20FPS. I suspect that SDL is scaling all of the textures every frame while in fullscreen, which would explain the FPS decrease.

I read here that Ryan Gordon had a similar problem with Postal 1. He fixed it by using OpenGL, drawing all of the non-scaled images to a memory buffer, and then scaling that buffer.

I don't think I can use OpenGL without overhauling all of my draw functions. Also, I tried using the opengl renderer driver in SDL, but I get the "No hardware accelerated renderers available" error, and it causes SDL_GetWindowSurface() and SDL_CreateTextureFromSurface() to fail and/or cause segmentation faults.

Is it possible to fix my problem by using a similar approach to Ryan's, but strictly with SDL2 and a software renderer? Maybe by drawing everything to a single texture, and then scaling up that single texture?

Thank you in advance!
Follow-up
foundtimegames


Joined: 30 Jul 2014
Posts: 4
Location: Maine
K, I got it to work. I just used something like:

SDL_Texture * target_texture = SDL_CreateTexture(renderer, window_pixel_format, SDL_TEXTUREACCESS_TARGET, WINDOWX, WINDOWY);
target_texture = SDL_CreateTexture(renderer, window_pixel_format, SDL_TEXTUREACCESS_TARGET, WINDOWX, WINDOWY);

draw_stuff() {
SDL_SetRenderTarget(renderer, target_texture);

//
// Draw stuff with SDL_RenderCopy
//

SDL_SetRenderTarget(renderer, NULL);
if (SDL_RenderCopy(renderer, target_texture, NULL, NULL) != 0) {
printf("Error in draw() when rendering target_texture: %s\n", SDL_GetError() );
}
SDL_RenderPresent(c_graphics::renderer);
}


However, now SDL_PollEvent(&event) doesn't notice any SDL_JOYBUTTONDOWN events whenever fullscreen is on. Weird. UGH!