Hi
Honestly I didn’t look very carefully at your code but I found something which may be called “suspicious”. Meaby it’s only because I didn’t spend enough time reading the code but…
if(bitmap.infoheader->biBitCount == 24)
{
bitmap.data24=malloc(size);
readBMPdata(filename,bitmap.data24,NULL,size/sizeof(*(bitmap.data24)),bitmap.fileheader->bfOffBits);
resize = size+(size/sizeof(*(bitmap.data24)));
bitmap.data32 = malloc(resize);
for(ctr=0; ctr < (resize/ sizeof(*(bitmap.data32)));++ctr)
{
bitmap.data32[ctr].r = bitmap.data24[ctr].b;
bitmap.data32[ctr].g = bitmap.data24[ctr].g;
bitmap.data32[ctr].b = bitmap.data24[ctr].r;
bitmap.data32[ctr].a = 0;
}
glGenTextures(1,&texture[tex_pos]);
glBindTexture(GL_TEXTURE_2D, texture[tex_pos]);
glTexImage2D(GL_TEXTURE_2D,0,sizeof(*(bitmap.data32)),bitmap.infoheader->biWidth,bitmap.infoheader->biHeight,0,GL_RGBA,GL_UNSIGNED_BYTE,bitmap.data32);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
else if(bitmap.infoheader->biBitCount == 32)
{
bitmap.data32=malloc(size);
readBMPdata(filename,NULL,bitmap.data32,size/sizeof(*(bitmap.data24)),bitmap.fileheader->bfOffBits);
for(ctr=0; ctr < (((bitmap.fileheader->bfSize) - (bitmap.fileheader->bfOffBits)) / sizeof(*(bitmap.data32)));++ctr)
{
help = bitmap.data32[ctr].b;
bitmap.data32[ctr].b = bitmap.data32[ctr].r;
bitmap.data32[ctr].r = help;
}
glGenTextures(1,&texture[tex_pos]);
glBindTexture(GL_TEXTURE_2D, texture[tex_pos]);
glTexImage2D(GL_TEXTURE_2D,0,sizeof(*(bitmap.data32)),bitmap.infoheader->biWidth,bitmap.infoheader->biHeight,0,GL_RGB,GL_UNSIGNED_BYTE,bitmap.data32);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
It seems that you are assigning 32-bit image (RGBA) to GL_RGB texture and 24-bit image (RGB) to GL_RGBA one. I am not sure. Just trying to help…
And something different…
glFlush();
glutSwapBuffers();
… you don’t have to call glFLush really. ASFAIK glutSwapBuffers() is enough.
OK. Good luck!
[This message has been edited by Orzech (edited 08-09-2003).]