//=========================================================================== // ppmgl2d.hpp : portable pixel map framebuffer //=========================================================================== #ifndef _PPMGL2D_ #define _PPMGL2D_ #include #include class ppmGL2d { public: RGB* FB; // LINEAR PIXEL FRAMEBUFFER int Width, Height, NumPixels; // DIMENSIONS unsigned char fgR, fgG, fgB; // CURRENT FOREGROUND COLOR unsigned char bgR, bgG, bgB; // CURRENT BACKGROUND COLOR // THE CONSTRUCTOR: REQUIRES THE DESIRED DIMENSIONS OF THE FRAMEBUFFER ppmGL2d(int width=256, int height=256) { Width=width; Height=height; NumPixels = Width*Height; // STORE NUMPIXELS IN FB FB = new RGB[NumPixels]; // ALLOCATE FRAMEBUFFER SetBackground(0,0,0); // DEFAULT BACKGROUND COLOR (BLACK) SetForeground(1,1,1); // DEFAULT FOREGROUND COLOR (WHITE) ClearColor(); }; // THE DESTRUCTOR: FREE THE FRAMEBUFFER ~ppmGL2d() { delete[] FB; }; // CLEAR THE FRAMEBUFFER WITH THE CURRENT BACKGROUND COLOR void ClearColor() { for (int i=0; i