/** * Original Code was GLUT-Test for proggen.org taken from here: * http://www.proggen.org/doku.php?id=frameworks:opengl:glut:test **/ #ifdef _WIN32 #include #endif #include #ifdef __APPLE__ #include #else #include #include #endif struct rgb_data { char red, green, blue; }; struct rgb_data* data; void display( void ) { /* clear all pixels */ glClear( GL_COLOR_BUFFER_BIT ); /* set the raster position to 0,0 */ glRasterPos2f ( 0, 0 ); /* Draws the pixeldata in data in the GL-Framebuffer */ glDrawPixels (300, 300, GL_RGB, GL_UNSIGNED_BYTE, data); /* don't wait * start processing buffered OpenGL routines */ glFlush(); } 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 ); } int main(int argc, char* argv[]) { /* create a window with glut */ glutInit( &argc, (char **) argv ); glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB ); glutInitWindowSize( 300, 300 ); glutInitWindowPosition( 100, 100 ); glutCreateWindow( "hello" ); init(); /* open a raw-image file (RGBRGBRGBRGB...) */ FILE* f=fopen("image.raw", "rb"); /* load the data into a struct containing char red, green, blu */ data = (struct rgb_data*) malloc ( 300 * 300 * sizeof(struct rgb_data) ); fread ( data, 300*300*3, 1, f); /* register the display-function with opengl */ glutDisplayFunc( display ); glutMainLoop(); free (data); return 0; }