Jump to content
  • Advertisement
Sign in to follow this  
kelvindavies11

loading bmp as textures

This topic is 4552 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
well, theres a tutorial showin how to load a 24bit (trucolor) bitmap for OpenGL without any gl utility libraries:

here

note: slight bug in their code:

l_texture[j+1] = rgb.rgbtRed; // Green component

should read (for obvious reasons):

l_texture[j+1] = rgb.rgbtGreen; // Green component

-
and heres a little info on the bmp format in general (incase 24-bit is just too specific for you).

Share this post


Link to post
Share on other sites
Seriously, 10 seconds in google would solve this for you.

nehe has several tutorials on this too.

Share this post


Link to post
Share on other sites
>>well, theres a tutorial showin how to load a 24bit (trucolor) bitmap for >>OpenGL without any gl utility libraries:
>>http://www.spacesimulator.net/tut3_texturemapping.html

Warning! My system catch spys inside the glut.dll within the downloadble source. Named "Employee Monitering" and others. Is that harmful?

Daniel



Share this post


Link to post
Share on other sites
Quote:
Original post by dan59314
>>well, theres a tutorial showin how to load a 24bit (trucolor) bitmap for >>OpenGL without any gl utility libraries:
>>http://www.spacesimulator.net/tut3_texturemapping.html

Warning! My system catch spys inside the glut.dll within the downloadble source. Named "Employee Monitering" and others. Is that harmful?

Daniel


A) Verify that it's indeed something in the .zip file or whatever you downloaded from the site, not something you got else where, then...
B) Always assume it's bad.
C) You likely want to send dmatter a PM about it so he doesn't hand out the link anymore.
D) Notify the site.

Share this post


Link to post
Share on other sites
I have recently written my own BMP reader/writer.

This class has 2 copies of pixmap data; one for default BGR and one for RGB order. By using getDataRGB(), you can easily pass the pixmap to OpenGL without using GL_BGR_EXT. Also, BMP image is flipped vertically when it is loaded.
Here is the source and testing program:

imageBmp.zip

Note that this example does not apply a BMP as a texture, but it displays an image by using glDrawPixels().

Share this post


Link to post
Share on other sites
Hello! I have a problem... I'm trying to make a chess and after i'm drawing the table i'm trying to draw the pawns, rooks, etc... But after drawing the first pawn the table disspears... Any idea? Here is the code:
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix

glTranslatef(0.0f,0.0f,-3.0f);
glColor3f(0.65f,0.5f,0.4f);

glBegin(GL_QUADS); // Start Drawing Quads
glVertex3f(-1.06f, 1.06f, 0.0f); // Left And Up 1 Unit (Top Left)
glVertex3f( 1.06f, 1.06f, 0.0f); // Right And Up 1 Unit (Top Right)
glVertex3f( 1.06f,-1.06f, 0.0f); // Right And Down One Unit (Bottom Right)
glVertex3f(-1.06f,-1.06f, 0.0f); // Left And Down One Unit (Bottom Left)
glEnd(); // Done Drawing A Quad

GLfloat x=1.0f;

glTranslatef(-0.875f,0.875f,0.0f);
glColor3f(1.0f,1.0f,1.0f);
for(int i=0;i<8;i++)
{
for(int j=0;j<8;j++)
{
glBegin(GL_QUADS);
glVertex3f(-0.125f, 0.1251f, 0.0f);
glVertex3f( 0.125f, 0.125f, 0.0f);
glVertex3f( 0.125f,-0.125f, 0.0f);
glVertex3f(-0.125f,-0.125f, 0.0f);
glEnd();
x=1.0f-x;
glColor3f(x,x,x);
glTranslatef(0.25f,0.0f,0.0f);
}
x=1.0f-x;
glColor3f(x,x,x);
glTranslatef(-2.0f,-0.25f,0.0f);
}

// DRAWING TEXTURES
glEnable(GL_BLEND); // Enable Blending
glDisable(GL_DEPTH_TEST); // Disable Depth Testing

glBlendFunc(GL_DST_COLOR,GL_ZERO); // Blend Screen Color With Zero (Black)
glTranslatef(0.0f,0.25f,0.0f);
glBindTexture(GL_TEXTURE_2D, texture[12]);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.125f, -0.1251f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.125f, -0.125f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.125f,0.125f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.125f,0.125f, 0.0f);
glEnd();

glBlendFunc(GL_ONE, GL_ONE); // Copy Image Color To The Screen
glBindTexture(GL_TEXTURE_2D, texture[0]); // Select The Image Texture

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.125f, -0.1251f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.125f, -0.125f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.125f,0.125f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.125f,0.125f, 0.0f);
glEnd();

glEnable(GL_DEPTH_TEST); // Enable Depth Testing
glDisable(GL_BLEND); // Disable Blending
return TRUE;
}


Any idea??

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!