3.3.19 BufferedColoredRegularIcosahedron

  In OZ++2.0.23, we have also added new classes OpenGLBufferARB, OpenGLBufferedShapd, OpenGLIndexBufferARB, and OpenGLVertexBufferARB to 'oz++/openglarb/' folder to support GL_ARB_vertex_buffer_object extension in GLEW.
  We have also added 'ContextVersion' to PulldownMenu for 'HELP' of DefaultMenubar.



The HelpDialog for 'ContextVersion' shows properties of GL_VERSION, GL_RENDERER, GL_VERSION, and GL_SHADER_LANGUAGE, as show below.



  The following is a very simple sample program to draw OpenGLColoredRegularIcosahedron by using above classes.



//
//BufferedColoredRegularIcosahedron.cpp
//Copyright (c) 2016 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.

#include <oz++/opengl/OpenGLMainView.h>
#include <oz++/opengl/OpenGLView.h>
#include <oz++/opengl/OpenGLGC.h>

#include <oz++/opengl/OpenGLColoredRegularIcosahedron.h>

#include <oz++/openglarb/OpenGLBufferedShape.h>


namespace OZ {

class MainView :public OpenGLMainView {

private:
  //Inner class starts.
  class SimpleView: public OpenGLView {
  private:
    OpenGLGC gc;
    SmartPtr<OpenGLColoredRegularIcosahedron>   hedron;
    SmartPtr<OpenGLBufferedShape>   shape;
 
  public:
  virtual void display()
  {
    if (shape) { 
      gc.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      gc.loadIdentity();
      gc.clearColor(0.8, 0.8, 0.8, 1.0);

      try {
        //Draw the first shape1.
        gc.pushMatrix();
          gc.translate(0.0f,0.0f,1.0f);  
          gc.lookAt(4.0, 12.0, 15.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); 
          shape->draw(&gc);
        gc.popMatrix();

      } catch (Exception& ex) {
        caught(ex); 
      }
    }
  }
 
  virtual void resize(int w, int h)
  {
    if (w == 0 || h == 0) {
      return;
    }
    gc.matrixMode(GL_PROJECTION);
    gc.loadIdentity();
    gc.perspective(16.0, (double)w / (double)h, 0.5, 40.0); 

    gc.matrixMode(GL_MODELVIEW);
  }

  virtual void initialize()
  {
    gc.enable( GL_DEPTH_TEST);

    try {
      Color3<GLfloat> vertexColors[] = {
        
        { 1.0f, 0.0f, 0.0f},
        { 0.0f, 1.0f, 0.0f}, 
        { 0.0f, 0.0f, 1.0f}, 
        { 1.0f, 1.0f, 0.0f},
        { 0.0f, 1.0f, 1.0f},
        { 1.0f, 0.0f, 1.0f},
        { 1.0f, 0.0f, 0.0f},
        { 0.0f, 1.0f, 0.0f}, 
        { 0.0f, 0.0f, 1.0f}, 
        { 1.0f, 1.0f, 0.0f},
        { 0.0f, 1.0f, 1.0f},
        { 1.0f, 0.0f, 1.0f},        
      };
      hedron = new OpenGLColoredRegularIcosahedron(vertexColors, SizeOf(vertexColors));
      
      shape = new OpenGLBufferedShape(hedron);
    
    } catch (Exception& ex) {
      caught(ex);
    }
  }

  public:
    SimpleView(OpenGLMainView* parent, const char* name, Args& args)
    :OpenGLView(parent, name, args)
    {
    } 

    ~SimpleView()
    {
    }
  };  
  //Inner class ends.
  
private:
  SmartPtr<SimpleView>  view;

public:
  MainView(OpenGLApplication& applet, const char* name, Args& args)
  :OpenGLMainView(applet, name, args) 
  {
    Args ar;
    ar.set(XmNopenGLBufferType, (XtArgVal)getBufferType());
    view = new SimpleView(this, "", ar);
  }

  ~MainView()
  {
  }
};
}

//
int main(int argc, char** argv) 
{
  try {    
    const char*  name = argv[0];
    OpenGLApplication applet(name, argc, argv);

    Args args;
    args.set(XmNwidth,  480);
    args.set(XmNheight, 480);
    
    MainView view(applet, name, args);
    view.realize();

    applet.run();
    
  } catch (Exception& ex) {
    caught(ex);
  }
  return 0;
}



Last modified: 1 Jan 2017

 Last modified: 1 Jan 2017

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