SDL: changing video modes inside the game

Started by
1 comment, last by ReclusiveFreak 17 years, 1 month ago
Greetings Gamedev members. I am learning to program little games (NES, SNES style) for fun in my spare time. I've programmed a nice little tetris game that is like "The New Tetris" for the Nintendo 64 in that you can make gold and silver squares,etc. My question is thus: I would like the user to be able to change the video mode within the game, like an option in the menu. I have written a test program that displays a bitmap and allows you to change the video mode from 1024x768 fullscreen to 800x600 windowed by pressing "v". This works successfully. However, it obviously doesn't scale down my bitmap files. (ie my sprites and what have you). So if I go from 1024x768 to 800x600, my game is too big for the screen. Is there an easy way to change the videomode such that your graphics scale up/down with the screen resolution? If there's not an easy way, what is the conventional way? Should I use an SDL-gfx library I found which allows you to zoom in and out on sprites to adjust the zoom level depending on the video mode? This seems inelegant and non-standard. It seems like tons of games let you change the screen resolution. I am curious if anyone knows how this is usually accomplished. Thank you for any advice you may have. EDIT: I forgot to mention: I am writing the game in C++ using Bloodshed DevC++, SDL for 2D graphics, on a WindowsXP machine.
Advertisement
I'd say there are 2 ways, and you already found one. You can use SDL_gfx to scale down / up your graphics.

Or, use OpenGL. Check the openGl forums, should have informations about how to set it up (I posted about it this week) and google around for opengl with sdl and you should be in business.

OpenGL is a bit harder, but you do get better framerates.
Thanks for your help.

Tetris is such a simple program, and since the game is 90% done, I think I will try the SDL_gfx method. However, I'm glad to know that OpenGL is used with SDL for 2D development. I will likely use that for my next game, which will be more complex.

This topic is closed to new replies.

Advertisement