Problem with alleg42.dll / program crashes / Allegro & Codeblocks
- by user24152
I'm having a serious problem with allegro. The program should display random pixels on the screen and when I build and run it I get the following error message:
Below is the full code of my program:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "allegro.h"
#define Text_Color_Red makecol(255,0,0)
int main()
{
int ret;
int color_depth = 32;
int x;
int y;
int red;
int green;
int blue;
int color;
//init allegro
allegro_init();
//install keyboard
install_keyboard();
//set color depth to 32 bits
set_color_depth(color_depth);
//init random seed
srand(time(NULL));
//init video mode to 640 x 480
ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
if(ret !=0)
{
allegro_message(allegro_error);
return 1;
}
//Display string
textprintf(screen,font,0,0,10,0,Text_Color_Red,"Screen Resolution is: %dx%d -- Press ESC to quit !",SCREEN_W,SCREEN_H);
//display pixels until ESC key is pressed
//wait for keypress
while(!key[KEY_ESC])
{
//set a random location
x = 10 + rand() % (SCREEN_W-20);
y = 10 + rand() % (SCREEN_H-20);
//set a random color
red = rand() % 255;
green = rand() % 255;
blue = rand() % 255;
color = makecol(red,green,blue);
//draw the pixel
putpixel(screen, x, y, color);
}
//quit allegro
allegro_exit();
}
END_OF_MAIN()
Error message: AllegroPixels1.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
Error signature: AppName: allegropixels1.exe AppVer: 0.0.0.0 ModName: alleg42.dll
ModVer: 4.2.3.0 Offset: 0006c05c
I am using Windows XP inside a virtual machine under Parallels 7.0