Dies ist eine alte Version des Dokuments!
Bemerke: Das Bild muss hier eine Größe von 300 x 300 Pixeln haben, ansonsten müssen Anpassung beim malloc-Ruf gemacht werden - generell müssen dann viele '300's geändert werden.
/** * 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 <windows.h> #endif #include <cstdio> #ifdef __APPLE__ #include <GLUT/glut.h> #else #include <GL/glut.h> #include <GL/gl.h> #endif struct rgb_data { char red, green, blue; }; struct rgb_data* data; void display( void ) { /* clear all pixels */ glClear( GL_COLOR_BUFFER_BIT ); /* Draw white polygon (rectangle) with corners at * (0.25, 0.25, 0) and (0.75, 0.75, 0.0) */ glRasterPos2f ( 0, 0 ); 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[]) { glutInit( &argc, (char **) argv ); glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB ); glutInitWindowSize( 300, 300 ); glutInitWindowPosition( 100, 100 ); glutCreateWindow( "hello" ); init(); FILE* f=fopen("image.raw", "rb"); data = (struct rgb_data*) malloc ( 300 * 300 * sizeof(struct rgb_data) ); fread ( data, 300*300*3, 1, f); glutDisplayFunc( display ); glutMainLoop(); free (data); return 0; }