Mail Archives: djgpp/1997/01/26/21:13:57
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
once, weird things start happening. The mouse no longer
displays properly, text just looks like a rectangle,
random blips appear on the screen, etc etc.
I stepped through the source code for the functions that I
called, but couldn't find anything. I even tried completely
shutting down Allegro (by calling allegro_exit()) and
re-initializing it before setting a new graphics mode, but
that didn't work either (it actually made things worse
since it screwed up the atexit functions). I reduced the
code down to this, which produces the exact same results
as my program.
#include <stdio.h>
#include <allegro.h>
int main(void)
{
int card, w, h;
allegro_init();
install_timer();
install_mouse();
install_keyboard();
set_gfx_mode(GFX_VGA, 320, 200, 0, 0);
gfx_mode_select(&card, &w, &h);
set_gfx_mode(card, w, h, w, h);
show_mouse(screen);
int done = FALSE;
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;
}
}
Thanks in advance.
Ryan Blazecka
eblazecka AT bc DOT sympatico DOT ca
- Raw text -