This is the best I could come up with while trying to display a bmp image in a OpenGL window. It’s not working, so if someone could take a look at it and tell me what’s wrong, I’d be gratefull:
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(560,800);
glutInitWindowPosition(100,100);
glutCreateWindow("Instrukcja");
init();
glutDisplayFunc(display);
glutMainLoop();
init();
void init(void)
{
//select clearing (background) color
glClearColor(0.0, 0.0, 0.0, 0.0);
//initialize viewing values
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
display();
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
HBITMAP hBmp = (HBITMAP) ::LoadImage (NULL,
(LPCTSTR) "Q0.bmp", IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE |LR_CREATEDIBSECTION);
if (hBmp == NULL) {
printf("Nie znaleziono bitmapy
");
}
else printf("Znaleziono bitmape!
");
BITMAP BM;
::GetObject (hBmp, sizeof (BM), &BM);
if (BM.bmBitsPixel != 24){
printf("Zla paleta kolorow!
");
}
else printf("Dobra paleta kolorow!
");
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glDrawPixels( BM.bmHeight, BM.bmWidth, GL_RGB,
GL_UNSIGNED_BYTE, BM.bmBits );
glEnd();
glFlush();
}
the resulting windo looks like a ‘system halt’ back on the old Win95s. Random configuration of pixels /but the pallete is taken from the desktop/. But at least it’s not black as it was some time ago. So i’m guessing it’s the parameter problem. Can someone help we with finding the right configuration?
Regards, Rafal