VIZ++ Class: OpenGLLists

 VIZ++ Class Library  VIZ++ Samples  VIZ++ ClassTree 

Source code

/*
 * OpenGLLists.h 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


#pragma once

#include <viz++/opengl/OpenGLObject.h>
#include <viz++/Exception.h>

namespace VIZ {

class OpenGLLists :public OpenGLObject {
private:
  GLuint  base;
  GLsizei range;

public:
  OpenGLLists(GLsizei range)
  :base(0),
   range(range)
  {
    if (range <= 0) {
      throw IException("Invalid range :%d", range);
    }

    base = glGenLists(range);
    if (base == 0) {
      throw IException("Failed to glGenLists range=%d", range); 
    } 
  }

  ~OpenGLLists()
  {
    glDeleteLists(base, range); 
  }

  GLuint getBase()
  {
    return base;
  }

  void call(GLsizei n, GLenum type, const GLvoid* lists) 
  {
    glListBase(base);
    glCallLists(n, type, lists); 
  }
};
}


Last modified: 10 Feb 2017

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