// draw bitmap sample on OpenGL // // Last updated: <2024/01/13 05:33:02 +0900> #include #include #include #include // include bitmap pattern #include "image_32x32.h" #include "image_lena.h" void display(void) { GLfloat xorig, yorig, xmove, ymove; GLsizei w, h; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // draw arrow glColor4f(1, 1, 1, 1); // set color glRasterPos2f(-0.5, -0.5); // set position xorig = 0.0; yorig = 0.0; xmove = 0.0; ymove = 0.0; w = image_32x32_width; h = image_32x32_height; glBitmap(w, h, xorig, yorig, xmove, ymove, image_32x32); // draw bitmap // draw lena glColor4f(1.0, 0.8, 0.5, 1); glRasterPos2f(0.0, 0.0); xorig = 0.0; yorig = 0.0; xmove = 0.0; ymove = 0.0; w = image_lena_width; h = image_lena_height; glBitmap(w, h, xorig, yorig, xmove, ymove, image_lena); glFlush(); } void keyboard(unsigned char key, int x, int y) { switch (key) { case '\x1B': case 'q': // Exit on escape or 'q' key press glutLeaveMainLoop(); // exit(EXIT_SUCCESS); break; } } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitWindowSize(512, 288); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH); glutCreateWindow("glBitmap sample"); glutKeyboardFunc(keyboard); glutDisplayFunc(display); glutMainLoop(); return EXIT_SUCCESS; }