From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro mode setting problem Date: Wed, 29 Jan 1997 22:06:53 +0000 Organization: None Distribution: world Message-ID: <1yJu75A9n87yEwNZ@talula.demon.co.uk> References: <32EBC0D2 DOT 5C7F AT bc DOT sympatico DOT ca> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 43 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp eblazecka writes: >I am trying to write a program in C++ using DJGPP 2 and >Allegro 2.1, but am having problems with the mode-setting >code. My application needs to switch between the available >graphics modes, but when I try to do so, I get unusual >results. If I try to change the graphics mode more than It's possible that this could be a hardware/driver problem. When you run the test.exe program, can it change modes successfully? > while(!done) { > if(keypressed()) > if((readkey() & 0xFF) == ' ') > gfx_mode_select(&card, &w, &h); > set_gfx_mode(card, w, h, w, h); > textout(screen, font, "This is a test string", 32, 32, 255); > } > else > done = TRUE; > } You should turn the mouse off, by calling show_mouse(NULL), before changing the graphics mode. The docs state you must do this whenever you draw to the screen, and when changing mode it is even more important! It would also be a good idea to set the palette after you select the graphics mode. Most BIOS's will load a default palette as part of the mode set, but some don't, and Allegro doesn't do this for you. Also, you should check the return value from set_gfx_mode(). There is a very good chance that it will fail, particularly if you are letting the user enter whatever weird card parameters they like :-) Nb. a couple of people seem confused about whether you need to explicitly clear the screen. You do need to do a clear every time you create a memory bitmap, but not when you set the graphics mode in the first place, because one of the last things set_gfx_mode() does is to call clear(screen). /* * Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ * Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'. */