How do you display a images in C++

Started by
4 comments, last by Gamerman25 23 years, 8 months ago
I''m new to game developing. I''ve read some books on C and C++ but all the programs in the books were simple text program. If anyone can tell me how to load and use images in my programs it would be much appreciated.
Bad pizza good Andy
Advertisement
ACSII art is kuhl
seriouly though, what compiler are you using? if dos, there are libraries out there such as Allegro, if a windows compiler, you hae a few options, GDI, DirectX, OpenGL, or one of the many other libraries out there.

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
I use MS Visual C++. Are there built in functions that let you load images with it?
Bad pizza good Andy
If you''re doing some Windows programming, you can use the LoadImage() function. Here it is:

HANDLE LoadImage(HINSTANCE hinst, UINT uType, int cxDesired, int cyDesired, UINT fuLoad);

Here''s an example of it, that I''ve used previously:

if(!(LoadImage(NULL, "D:/game images/monster.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION))
{
MessageBox(hwnd, "Failed to load image", "Error", MB_OK);

return (0);
}


If you want to make a REAL game, choose an API like DirectX or OpenGL. The GDI isn''t the greatest thing in the world, I''ll tell yah that.

There are three types of people in the world; those who can count, and those who can't.
3D Math- The type of mathematics that'll put hair on your chest!
go buy the book "Tricks of the Windows Game Programming Gurus" by Andre Lamothe
it will teach you the stuff you need to know about windows programming, and then go into detail about DirectX
Thanks for the help. I''l go check out that book too.

This topic is closed to new replies.

Advertisement