42#include "ramCanvas.hpp"
57mjr::ramCanvas3c8b theRamCanvas = mjr::ramCanvas3c8b(XSIZE, YSIZE, -1, 1, -1, 1);
60void reshapeCall(
int h,
int w) {
63 glMatrixMode(GL_PROJECTION);
65 gluOrtho2D(0.0, XSIZE, 0.0, XSIZE);
66 glMatrixMode(GL_MODELVIEW);
68 glViewport(0,0,XSIZE,YSIZE);
75 for(
int x=0; x<theRamCanvas.getNumPixX(); x++)
76 for(
int y=0; y<theRamCanvas.getNumPixX(); y++)
77 theRamCanvas.drawPoint(x, y, mjr::ramCanvas3c8b::colorType(
static_cast<mjr::ramCanvas3c8b::colorChanType
>(offset+y-x),
78 static_cast<mjr::ramCanvas3c8b::colorChanType
>(offset+x+y),
79 static_cast<mjr::ramCanvas3c8b::colorChanType
>(offset+x-y)));
90 if((retVal=theRamCanvas.exportRasterData(image, 0, 0, theRamCanvas.getNumPixX()-1, theRamCanvas.getNumPixY()-1, 0, 1, 2, 3))) {
91 printf(
"ERROR: Nonzero return from exportRasterData(): %d\n", retVal);
95 glClear(GL_COLOR_BUFFER_BIT);
97 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
99 xMag =
static_cast<float>(XSIZE) /
static_cast<float>(theRamCanvas.getNumPixX());
100 yMag =
static_cast<float>(YSIZE) /
static_cast<float>(theRamCanvas.getNumPixY());
102 glPixelZoom(xMag, yMag);
103 glDrawPixels(theRamCanvas.getNumPixX(), theRamCanvas.getNumPixY(), GL_RGBA, GL_UNSIGNED_BYTE, (GLubyte*)image);
108int main(
int argc,
char *argv[]) {
109 for(
int x=0; x<theRamCanvas.getNumPixX(); x++)
110 for(
int y=0; y<theRamCanvas.getNumPixX(); y++)
111 theRamCanvas.drawPoint(x, y, mjr::ramCanvas3c8b::colorType(
static_cast<mjr::ramCanvas3c8b::colorChanType
>(y-x),
112 static_cast<mjr::ramCanvas3c8b::colorChanType
>(x+y),
113 static_cast<mjr::ramCanvas3c8b::colorChanType
>(x-y)));
114 glutInit(&argc, argv);
115 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
116 glutInitWindowSize(XSIZE, YSIZE);
117 glutInitWindowPosition(10, 10);
118 glutCreateWindow(
"ramCanvasDisplayViaGLUT");
119 glutReshapeFunc(reshapeCall);
120 glutDisplayFunc(displayCall);
121 glutIdleFunc(idleCall);
int main(int argc, char *argv[])