Easy Question: BMP Loading...
I am working on a very simple game engine... Just uses 16x16 tiles to create a map. How can I load and draw a bmp. I used to know something along the lines of:
bmp1 = LoadBMP("tile1.bmp");
DrawBMP(bmp1,x,y);
But can''t fine it anymore.
Any Help Greatly Appreciated!
Thanks Alot,
Rich
P.S. I am Using OpenGL/GLUT as the sub-system for my graphics.
Yeah Ive been going throu them... there all pretty good... but I don''t need to get all into textures... plus theres no easy clear cut way to load and then draw... I don''t need scaling.. or anything...
Just simplicity...
Thanks
Rich
Just simplicity...
Thanks
Rich
Dude, simplicity went out the door the moment you became a programmer. If you are using OpenGL to draw the bitmap then you need textures.
2D doesn''t mean 2D anymore. It means 2D with the camera perpendicular to the plane that you''re drawing on.
But hey, put it this way, at least you can spend a little time developing the camera code and you''ll have yourself a much more interesting over-head game
But hey, put it this way, at least you can spend a little time developing the camera code and you''ll have yourself a much more interesting over-head game

I like pie! - weebl.
Oneiric - Another graphics engine in the works.
Oneiric - Another graphics engine in the works.
Well, you could use LoadImage which loads bitmaps.
Or you could go here - http://opengl.nutty.org/OpenIL/
I recommend using either PNG or JPG files rather than bitmaps. They are much smaller.
Or you could go here - http://opengl.nutty.org/OpenIL/
I recommend using either PNG or JPG files rather than bitmaps. They are much smaller.
a bitmap file, in true color has 24 bits per pixel
(3 bytes, one for red, green, blue)
the image starts at offset 54.
a 640x480 image will then be 640x480x3=921600 bytes,
plus the header, 54 bytes equals 921654 bytes.
hoped it helped...
(3 bytes, one for red, green, blue)
the image starts at offset 54.
a 640x480 image will then be 640x480x3=921600 bytes,
plus the header, 54 bytes equals 921654 bytes.
hoped it helped...
[Hugo Ferreira][Positronic Dreams]
Need [3D Artist] & [Sound Designer]
for small project. Contact me plz...
I believe a BMP file also stores the data in the form BGR, not RGB as you might expect, so the byte at 0x36 is in fact the blue component of the first pixel, 0x37 is the green, and 0x38 is the red.

[edited by - Nemesis2k2 on March 7, 2003 7:06:53 AM]

[edited by - Nemesis2k2 on March 7, 2003 7:06:53 AM]
Hey Nemesis2k2, you are correct about the swap of Blue and Red components. To correct this use a feature of OpenGL to correct this for you if you don''t want to write the code to swap the bytes. Use GL_BGR or GL_BGR_EXT instead of GL_RGB when using gluBuild2DMipmaps() or glTexImage2D().
Example:
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Image.sizeX, Image.sizeY, GL_BGR, GL_UNSIGNED_BYTE, Image.data);
if you are using an old gl.h v1.1 header file then GL_BGR will not be defined so use GL_BGR_EXT. Or throw the following into you code:
#define GL_BGR 0x80E0
Example:
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Image.sizeX, Image.sizeY, GL_BGR, GL_UNSIGNED_BYTE, Image.data);
if you are using an old gl.h v1.1 header file then GL_BGR will not be defined so use GL_BGR_EXT. Or throw the following into you code:
#define GL_BGR 0x80E0
quote:
Original post by nfz
Hey Nemesis2k2, you are correct about the swap of Blue and Red components. To correct this use a feature of OpenGL to correct this for you if you don''t want to write the code to swap the bytes. Use GL_BGR or GL_BGR_EXT instead of GL_RGB when using gluBuild2DMipmaps() or glTexImage2D().
Example:
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Image.sizeX, Image.sizeY, GL_BGR, GL_UNSIGNED_BYTE, Image.data);
if you are using an old gl.h v1.1 header file then GL_BGR will not be defined so use GL_BGR_EXT. Or throw the following into you code:
#define GL_BGR 0x80E0
Or you might just want to swap the variables:
for (i = 0; i < width * height; i++) {
imageData ^= imageData;<br>imageData ^= imageData;<br>imageData ^= imageData;<br><br>And that''s all there is to it. </i>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement