allegro newbie, need help on my frst program
i have just started using the allegro library and i'm already confused why my program won't run properly.
code is free to edit.
all i want this to do is open a window 800,640 and draw a blue pixel at (100,100). the program compiles and links, put when i open the .exe the concole opens and then windows says "pixels.exe has encountered a problem and needs to close. We are sorry for the inconvenience. blah blah blah" how do i get this baby to run the way i want it? thx.
You didnt call set_gfx_mode, the function that creates the graphics window.
Also the lines
don't do anything. Maybe you want them to do something later but in this program they do nothing.
so i continued expanding it and came up with this:
|2||using namespace std;|
|11|| int x;|
|12|| int y;|
|16|| int blue = makecol(0,0,255);|
|20|| _putpixel32(screen,x,y, blue);|
what happens is it opens a white window and i can draw simply by dragging
problem: the pixels are rectangular, how do i get them to be square.
problem2: when i draw i get 2 streams of pixels at 2 seemingly unrelated places
problem3: about 1/3 of each rectangular pixel is blue, other 2/3s is black
You need to set the color depth before setting the gfx mode. This should fix the last two problems.
Oh yea, the default color depth is 8 but it looks like you want 32. You don't really need nor should use _putpixel32 unless you really know what you are doing.
As for the rectangular thing; what resolution is your desktop at? If it's not the same ratio as your monitor (4:3 usually 16:9 for widescreen monitors), or, all pixels will be rectangular.
Though it's probably because you are trying to draw a 32 bit integer to 8 bit surface.
thx guys, ya the solution was to set the color depth and not use _putpixel32() it solved all 3 problems
Thread #591833. Printed from Allegro.cc
800x600 and 640x480 are 'standard' resolutions.
Never seen anyone use 800x640 before...