VIZ++ Class: OpenGLObject

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

Source code

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


//2016/07/01 Modified to include glew.h.

#pragma once

//2017/02/10
#include <GL/glew.h>

#include <viz++/Object.h>
#include <viz++/Exception.h>

#define GL_GLEXT_PROTOTYPES
#include <GL/wglew.h>

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>

namespace VIZ {

class OpenGLObject : public Object {

public:
  OpenGLObject()
  {
  }
  
  GLenum getError()
  {
    return glGetError();
  }

  const char* errorString()
  {
    const char* errString = "";
    GLenum err = getError();
    if (err != GL_NO_ERROR) {
      errString = (const char*)gluErrorString(err);
    }
    return errString;
  }

  //2017/02/10
  void* load(const char* name)
  {
    void* address = NULL;
    if (name && strlen(name) > 0) {
      address =  wglGetProcAddress((LPCSTR)name);
      if (address == NULL) {
        throw IException("Failed to load function : %s", name);
      }
    } else {
      throw IException("Invalid argument.");
    }
    return address;
  }
  
  //2017/02/10
  void checkError()
  {
    GLenum err = getError();
    if (err != GL_NO_ERROR) {
      const char* errString = (const char*)gluErrorString(err);
      throw Exception((int)err, "OpenGL error: %s", errString);
    }
  }
};

}


Last modified: 10 Feb 2017

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