SDL, fullscreen probs

Started by
5 comments, last by rouncED 14 years, 6 months ago
Hello, I wonder why I can't have totally fullscreen in SDL. It works totally fine with any resolution 640x480 and bigger, but when I choose to have resolutions like 320x240 my SDL program won't stretch enough (black borders on the sides occur.) Look here this is how a small resolution SDL game looks like on my computer: http://thuski.se/ixuz/not_fullscreen.jpg It may be my monitor that doesn't allow this low resolutions? Is there any another ways or settings to fullscreen my game? thanks.
Advertisement
Use SDL_ListModes to enumerate the available modes. Windows generally will not run in anything less than 640x480x8, and lower modes are generally not natively supported in modern video hardware.

You can set a direct multiple, such as 640x480, and stretch your image to fit. Each pixel is twice as high and twice as wide.
Quote:Original post by Oluseyi
You can set a direct multiple, such as 640x480, and stretch your image to fit. Each pixel is twice as high and twice as wide.


I think a better way do achieve the same effect would be to set up a middle layer buffer with a desired screen resolution (320x240 for instance), blit all images to that buffer before lastly blitting and scaling the middle layer buffer to the actual screen buffer.
Quote:Original post by JNT
I think a better way do achieve the same effect would be to set up a middle layer buffer with a desired screen resolution (320x240 for instance), blit all images to that buffer before lastly blitting and scaling the middle layer buffer to the actual screen buffer.

Yes. Using a stretch bit also gives you the effect of virtual resolution, so you can render to any physical resolution. Just blit to an adjusted rectangle with letterboxing or pillarboxing as necessary (requires SDL_gfx for zoomSurface):

void blitVirtualSurface(const SDL_Surface * source, SDL_Surface * destination){  float scaleFactor;  SDL_Rect offset;  if ((float(source->w) / source->h) > (float(destination->w) / destination->h))  {    // letterbox; compute vertical offset    scaleFactor = float(destination->w) / source->w;    offset.x = 0;    offset.y = int((float(destination->h) - (scaleFactor * source->h)) / 2 + 0.5f);  }  else  {    // pillarbox; compute horizontal offset    scaleFactor = float(destination->h) / source->h;    offset.x = int((float(destination->w) - (scaleFactor * source->w)) / 2 + 0.5f);    offset.y = 0;  }  SDL_Surface * temp = zoomSurface(source, scaleFactor, scaleFactor, 1);  SDL_BlitSurface(temp, NULL, destination, &offset);}

Re-opening this topic from retirement at request of user 'ryanh77', who wanted to post the following response:

Quote:
In the SDL Release Notes, they mention a way to use lower full-screen resolutions in Windows without the black border: Begin pasting...

The "windib" video driver is the default now, to prevent problems with certain laptops, 64-bit Windows, and Windows Vista. The DirectX driver is still available, and can be selected by setting the environment variable SDL_VIDEODRIVER to "directx". End pasting...

See the Windows Notes section of the following page: http://www.libsdl.org/release/changes-1.2.html After running the following command from my DOS prompt: set SDL_VIDEODRIVER=directx SDL_ListModes returned the following Available Modes: 1600 x 1200 1280 x 1024 1152 x 864 1024 x 768 848 x 480 800 x 600 768 x 576 720 x 480 640 x 480 640 x 400 512 x 384 400 x 300 320 x 240 320 x 200 as opposed to the following with the default "windib" video driver: 1600 x 1200 1280 x 1024 1152 x 864 1024 x 768 848 x 480 800 x 600 768 x 576 720 x 480 640 x 480


Hope that helps someone. [smile]

- Jason Astle-Adams

..Bump.. I need this for my SDL game development.
Why not make your game 640x480, is your sprite drawing res challenged.

When I do a 2d game, I draw fat huge sprites at 1280x1024... your game looks real ingenious tho :)

sorry i cant help other than saying that.

This topic is closed to new replies.

Advertisement