Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 57 lines (46 sloc) 1.127 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#include "vgl.h"

class ExampleRenderer : public vgl::Renderer
{
public:
  ExampleRenderer() {}

  virtual void setup() {
    glEnable(GL_DEPTH_TEST);
    glShadeModel(GL_SMOOTH);

    /*
glEnable(GL_LINE_STIPPLE);
glLineStipple(1, 0xFF00);
*/

  }

  virtual void render() {
    glPushMatrix();
    glTranslatef(-5, 0, -1);
    glScalef(10, 10, 10);
    quad(GL_FILL, vgl::Vec4f(0.6, 0, 0, 1));
    glPopMatrix();

    quad(GL_FILL, vgl::Vec4f(0.4, 0.4, 0.4, 0.5));
    quad(GL_LINE, vgl::Vec4f(0.8, 0.8, 1, 1));
  }

private:
  void quad(GLenum mode, vgl::Vec4f color) {
    glPolygonMode(GL_FRONT_AND_BACK, mode);
    if (mode == GL_LINE) {
      glEnable(GL_POLYGON_OFFSET_LINE);
      glPolygonOffset(1, -5);
    } else {
      glDisable(GL_POLYGON_OFFSET_LINE);
    }
    glColor4fv(color.data);
    glBegin(GL_POLYGON);
    glVertex3f(-0.5, -0.5, 0);
    glVertex3f( 0.5, -0.5, 0);
    glVertex3f( 0.5, 0.5, 0);
    glVertex3f(-0.5, 0.5, 0);
    glEnd();
  }
};


int main(int argc, char** argv)
{
  ExampleRenderer renderer;
  vgl::Viewer viewer("Example Viewer", 800, 600, &renderer);
  viewer.run();
}

Something went wrong with that request. Please try again.