#define GL_GLEXT_PROTOTYPES #include #include #include #include #include void init(void) { /* 64 bits (8x8 bitmap), stipple pattern; */ GLubyte bitmap[8] = {0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55}; GLuint buffers[1]; GLubyte data[64]; glOrtho(0, 100, 0, 100, 0, -1); glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenBuffers(1, buffers); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffers[0]); glBufferData(GL_PIXEL_UNPACK_BUFFER, 8, bitmap, GL_DYNAMIC_DRAW); glBitmap(8, 8, 0, 0, 0, 0, 0); glReadPixels(0, 0, 8, 8, GL_RED, GL_UNSIGNED_BYTE, &data); glDeleteBuffers(1, buffers); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow(argv[0]); init(); return 0; }