VIZ++ Class: OpenGLRenderBuffersEXT
|
Source code
/*
* OpenGLRenderBuffersEXT.h
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
#pragma once
#ifdef GL_EXT_framebuffer_object
#include <viz++/opengl/OpenGLObject.h>
namespace VIZ {
class OpenGLRenderBuffersEXT :public OpenGLObject {
private:
GLsizei size;
GLuint* buffers;
protected:
void generate(GLsizei size, GLuint* buffers)
{
static PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT = NULL;
if (glGenRenderbuffersEXT == NULL) {
glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)load("glGenRenderbuffersEXT");
}
glGenRenderbuffersEXT(size, buffers);
}
//destroy renderbuffer
void destroy()
{
static PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = NULL;
if (glDeleteRenderbuffersEXT == NULL) {
glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)load("glDeleteRenderbuffersEXT");
}
glDeleteRenderbuffersEXT(size, buffers);
}
void bind(GLenum target, GLuint buffer)
{
static PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL;
if (glBindRenderbufferEXT == NULL) {
glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)load("glBindRenderbufferEXT");
}
glBindRenderbufferEXT(target, buffer);
}
public:
OpenGLRenderBuffersEXT(GLsizei n)
:OpenGLObject(),
size(n),
buffers(NULL)
{
if (size < 1) {
throw IException("Invalid parameters. size=%d", size);
}
buffers = new GLuint[size];
generate(size, buffers);
}
~OpenGLRenderBuffersEXT()
{
destroy();
delete [] buffers;
buffers = NULL;
}
GLuint getNth(int n)
{
if (n >= 0 && n < size) {
return buffers[n];
} else {
throw IException("Invalid nth parameter %d", n);
}
}
void bindNth(GLenum target, int n)
{
if (n >= 0 && n < size) {
bind(target, buffers[n]);
} else {
throw IException("Invalid nth parameter %d", n);
}
}
void getParameteriv(GLenum target, GLenum pname, GLint* params)
{
static PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT = NULL;
if (glGetRenderbufferParameterivEXT == NULL) {
glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)load("glGetRenderbufferParameterivEXT");
}
glGetRenderbufferParameterivEXT(target, pname, params);
}
GLboolean isRenderbuffer(GLuint buffer)
{
static PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT = NULL;
if (glIsRenderbufferEXT == NULL) {
glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)load("glIsRenderbufferEXT");
}
return glIsRenderbufferEXT(buffer);
}
void storage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
{
static PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = NULL;
if (glRenderbufferStorageEXT == NULL) {
glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)load("glRenderbufferStorageEXT");
}
glRenderbufferStorageEXT(target, internalformat, width, height);
}
};
}
#endif
Last modified: 10 Feb 2017
Copyright (c) 2009-2017 Antillia.com ALL RIGHTS RESERVED.