Hello,
This may be a stupid question, or I could just be stupid, I do not know, but I am having a HELL of a time trying to figure out how to just texture map a polygon with just a normal, everyday, texture (no blending, no mipmap, etc).
Here is my code for setting the texture…
glGenTextures(1, &Texture);
glBindTexture(GL_TEXTURE_2D, Texture);
glTexImage2D(GL_TEXTURE_2D, 0, 3, Bitmap.GetWidth() - 1, Bitmap.GetHeight() - 1, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, Image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
And here is my code for generating Image, which is of type GLubyte*…
struct _pixBGRData{
GLubyte B;
GLubyte G;
GLubyte R;
GLubyte Reserved;
};
void glcBitmap::GetPixels(GLubyte Buffer[], int Type, int R, int G, int B){
int BufferIndex = 0;
int PixIndex = 0;
if (Loaded){
if (Type == 0){
for (; PixIndex < (Info.biWidth *
Info.biHeight); PixIndex++){
Buffer[BufferIndex] = BGR[PixIndex].B;
Buffer[BufferIndex + 1] = BGR[PixIndex].G;
Buffer[BufferIndex + 2] = BGR[PixIndex].R;
BufferIndex += 3;
}
}
}
}
Also, I know the data is intact because I make a call to glDrawPixels and it draws properly.
I just do NOT get it!! Is there a difference between the data passed in glDrawPixels and glTexImage2D, or am I forgetting a function call, messing up the order of calls?
I have a demo on this that works (someone else wrote it), and as far as I can tell, the openGL calls we make are the same, but how we load in the bitmap is different.
One last thing, in this very long problem. I know there is a built in bmp loader in the open gl library (though I didn’t know to AFTER I created my bmp loaded), but I want to get this working with MY bmp loader. I want to know what I am really doing wrong!!
Can anyone help?
Thank you for your time,
occamrzr