/* W B Langdon at MUN 10 May 2007 * Program to demonstarte use of OpenGL's glDrawPixels */ /* modified for animation by Sam Watkins. refs: http://www.cs.mun.ca/~blangdon/opengl/glDrawPixels.html http://www.gamedev.net/community/forums/topic.asp?topic_id=470849 http://www.rage3d.com/board/showthread.php?t=33651848 */ //http://msdn2.microsoft.com/en-us/library/ms537062.aspx //glDrawPixels writes a block of pixels to the framebuffer. #include #include #include //#include //#include #include "stdio.h" #include "stdlib.h" #include "math.h" #include "string.h" #include #include unsigned int window_width = 1024, window_height = 768; int size; unsigned long *pixels; double last_time = 0; //WBL 9 May 2007 Based on //http://www.codeguru.com/cpp/w-d/dislog/commondialogs/article.php/c1861/ //Common.h //Convert a wide range of data values into nice colours void colour(const float data, unsigned char * out) { //convert data to angle out[0] = 128 + data*128/10; out[1] = 64 - data*64/10; out[2] = 32; out[3] = 128; } int frame = 0; //#define rgb(r,g,b) ((r)<<24|(g)<<16|(b)<<8) #define rgb(r,g,b) ((b)<<16|(g)<<8|(r)) void animate() { unsigned long *px = pixels; unsigned char r = frame, g = frame, b = -frame; int x, y; for(y=0; y