VIZ++ Sample: Simple

VIZ++ Samples

1 Screenshot


2 Source code

/*
 * Simple.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


//2017/02/10

#include <viz++/opengl/OpenGLApplet.h>
#include <viz++/opengl/OpenGLMainView.h>
#include <viz++/opengl/OpenGLGC.h>

namespace VIZ {

class MainView :public OpenGLMainView {
private:
  SmartPtr<OpenGLGC> gc;

public:
  virtual void display()
  {
    if (gc) {
      //OpenGLGC gc;
      gc -> clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      gc -> loadIdentity();
       
      gc -> begin(GL_TRIANGLES);
      gc -> coloredVertex(1.0, 0.0, 1.0, 0.0, 0.0);
      gc -> coloredVertex(0.5, 0.5, 1.0, -1.0, 0.9);
      gc -> coloredVertex(0.0, 0.0, 0.0, 1.0, 0.9);

      gc -> coloredVertex(1.0, 0.0, 0.0, 0.0, 0.0);
      gc -> coloredVertex(0.0, 0.5, 0.0, -1.0, -0.9);
      gc -> coloredVertex(1.0, 1.0, 0.0, 1.0, -0.9);

      gc -> end();
    }
  }
    
  virtual void resize(int width, int height)
  {
    //Define your own resize method.
  }

  virtual void initialize()
  {
     gc = new OpenGLGC();
  }


public:
  MainView(OpenGLApplet& applet, int width, int height, const char* name)
  :OpenGLMainView(applet, width, height, name)
  {
  }

  ~MainView()
  {
  }
};
}

//
int main(int argc, char** argv) 
{
  try {
    ModuleFileName module;
    const char*  name = module.getAppName();
    OpenGLApplet applet(argc, argv);

    MainView view(applet, 400, 300, name);
    view.realize();
    applet.run();
    
  } catch (Exception& ex) {
    caught(ex);
  }
  return 0;
}


Last modified: 10 Feb 2017

Copyright (c) 2017 Antillia.com ALL RIGHTS RESERVED.