All pastes #1364788 Raw Edit

sara

public cpp v1 · immutable
#1364788 ·published 2009-03-19 00:00 UTC
rendered paste body
#include "GlWindow.h"#include <GL/glu.h>#include <iostream>using namespace std;GlWindow::GlWindow(int width, int height, char *title):    Fl_Gl_Window(width, height, title), _height(height),    _width(width){        mode(FL_RGB | FL_ALPHA | FL_DEPTH |FL_DOUBLE);        size_range(0,0,_width,_height);}GlWindow::~GlWindow(void){}void GlWindow::initialiseGL(void){    glClearColor(.1f, .1f, .1f, 1);    glEnable(GL_DEPTH_TEST);}void GlWindow::draw(){    static bool firstTime = true;    if (firstTime){        initialiseGL();        firstTime = false;    }    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);    glMatrixMode(GL_PROJECTION);    glLoadIdentity();    glFrustum(-1, 1, -1, 1, 1, 100);    glMatrixMode(GL_MODELVIEW);    glLoadIdentity();    gluLookAt(0,0,3,0,0,0,0,1,0);    DrawCube();}void GlWindow::DrawCube(){    glBegin(GL_QUADS);    glColor3f(1, 0, 0);    glVertex3f(-1, 1, 1);    glVertex3f(-1, -1, 1);    glVertex3f(1, -1, 1);    glVertex3f(1, 1, 1);    // back    glColor3f(0, 1, 0);    glVertex3f(-1, 1, -1);    glVertex3f(1, 1, -1);    glVertex3f(1, -1, -1);    glVertex3f(-1, -1, -1);    // top    glColor3f(0, 0, 1);    glVertex3f(-1, 1, -1);    glVertex3f(-1, 1, 1);    glVertex3f(1, 1, 1);    glVertex3f(1, 1, -1);    // bottom    glColor3f(1, 1, 0);    glVertex3f(-1, -1, -1);    glVertex3f(1, -1, -1);    glVertex3f(1, -1, 1);    glVertex3f(-1, -1, 1);    // left    glColor3f(0, 1, 1);    glVertex3f(-1, 1, -1);    glVertex3f(-1, -1, -1);    glVertex3f(-1, -1, 1);    glVertex3f(-1, 1, 1);    // right    glColor3f(1, 0, 1);    glVertex3f(1, 1, 1);    glVertex3f(1, -1, 1);    glVertex3f(1, -1, -1);    glVertex3f(1, 1, -1);    glEnd();}int main(int argc, char **argv){    //Fl_Gl_Window win(0,0,400, 400);    //Fl_Scroll scroll(0,0,400,400);    GlWindow myWindow(400, 400, "moo");    myWindow.resizable(&myWindow);    //win.resizable(&myWindow);    //scroll.end();    //win.end();    //win.show();    myWindow.show();    Fl::run();    return 0;}