![]() |
|
Window resizing |
Kevlar Games
Member #7,757
September 2006
|
Hi, In my game, I have a main menu that is 800x600 and I want the game to play in 640x480. How do I change to that resolution? |
Matthew Leverton
Supreme Loser
January 1999
![]() |
set_gfx_mode |
Kevlar Games
Member #7,757
September 2006
|
I tried that and it works but the screen goes crazy. It starts flickering and gives me the standard "Program has encountered an error and needs to close" message. Here's my code for resizing it: set_color_depth(32); set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0); buffer = create_bitmap(640,480); What am I doing wrong? |
Matt Smith
Member #783
November 2000
|
This is a bug/limitation in Allegro unfortunately. It probably won't get fixed in the immediate future as we are short of good Windows devs. It's another remnant of Allegro originally being full-screen only (for DOS) so the window is actually created by the startup code, and then sized by set_gfx_mode(), so 2 calls to set_gfx_mode(*_WINDOWED,,,) causes problems. You might have more luck switching between fullscreen modes, but this has similar problems on various other platforms. You have 3 proper solutions 1) Stick to 1 resolution 2) Write a hybrid WinAPI/allegro prog that opens its own window and uses blit_to_hdc() to output allegro gfx 3) Help fix this part of Allegro, or put your whole project on hold until someone else does. EDIT: I assumed you are using MSWindows, but GFX_AUTODETECT_WINDOWED could also mean X11 or MacOS. The same problem exists there really, so the solutions remain valid. |
Kevlar Games
Member #7,757
September 2006
|
Thanks, I'll try that. EDIT: Going to text mode first didn't work either. I'm not really good with the WinAPI, so I don't think that's an option. I could try making the main menu 640x480. That wouldn't be a problem. |
Kris Asick
Member #1,424
July 2001
|
Quote: EDIT 2: It can help if you set_gfx_mode(GFX_TEXT,0,0,0,0); before setting the new size, as this gives the screen driver a chance to clean up the old settings and release the old screen BITMAP.
However, if you switch video modes while in Windows, there's two very important things you have to remember. 1: All contents of all bitmaps made with create_video_bitmap() will be lost. (The bitmap pointers and memory will still be intact, just nothing inside them.) 2: If you change the colour depth too, you have to reload all of your graphics so that they can be formatted to the current colour depth properly. EDIT: Waitaminute... I just looked at my code and realized I'm not doing this, yet it works perfectly on every system I've tested on... Download PixelShips Retro and try pushing F9 to change screen modes. If that works for you, let me know because I can post the code that's doing the change and you can see if perhaps there's a solution for you in there. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
Kevlar Games
Member #7,757
September 2006
|
PixelShips resizes perfectly when I press F9. P.S. Are you selling a lot of copies? I'm thinking of getting into the shareware business. |
Kris Asick
Member #1,424
July 2001
|
Quote: PixelShips resizes perfectly when I press F9. Alrighty then. Here's the code I use to do the switching. I didn't post it at first because there's a TON of it:
F9 essentially cycles through a list of video modes in PixelShips Retro. The list is as follows:
If the list does one complete loop and is unable to reset the original mode before pressing F9, the game aborts, otherwise it settles on whatever comes next that doesn't fail. Now, there is the fact going that I'm only using 8bpp, not 32, however, I think the problem may be related to my setting the display switch mode to allow the game to continue running in the background. I have to do this to properly cancel out the music on a switch, however, I've recently discovered that a realm of issues with Allegro are solved when you take it out of its default pausing mode and set it into a background mode. So you might want to try that first. (Just remember that the moment you make another call to set_gfx_mode(), all display switching settings are forgotten, including callbacks!) Quote: P.S. Are you selling a lot of copies? I'm thinking of getting into the shareware business. That's not a fair question to ask someone. If my business is in the slums, answering as such would turn people away. If my business is booming, answering as such would seem like flagrant advertising. All I can recommend if you want to get into shareware is to do your homework and to not expect to be an overnight success story. Shareware is ultimately 10% programming and 90% marketing. Going into it just to make a quick buck won't leave you with much. There are a lot of resources on the net for people who want to get started. Read them and obey them, because any moment when you say, "That's not how I want to do shareware," is another 20%-80% off your sales. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
James Stanley
Member #7,275
May 2006
![]() |
Try keeping it in 800x600 and stretch_blitting to the screen |
Kevlar Games
Member #7,757
September 2006
|
Quote:
Quote:
Quote: That's not a fair question to ask someone. Yeah, sorry. I was just wondering, though. I just figured that an indie game other than a match-3 or Tetris clone would do really well. I'll try your code and see if it works. Thanks. |
|