Commit 72a6b89c authored by Christopher Tenter's avatar Christopher Tenter

new opengl objects in acg

git-svn-id: 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a40cf07a
This diff is collapsed.
......@@ -63,6 +63,7 @@
#include <iostream>
#include <fstream>
#include <string>
#include <map>
// C
#include <cstdio>
......@@ -117,7 +118,7 @@ private:
#if defined(GL_ARB_vertex_buffer_object)
class VertexBufferObject
class ACGDLLEXPORT VertexBufferObject
......@@ -171,6 +172,57 @@ public:
/* Vertex array object
A VAO is a state collection for vertex, index buffers and vertex attribute locations.
It basically stores all vertex and index buffer related opengl states.
Maybe Vertex- or GeometryInputState is a more fitting name for this class..
opengl-core: 3.0
setup VAO:
usual opengl setup of vertex and indexbuffer and attribute locations
draw with VAO:
class VertexArrayObject
virtual ~VertexArrayObject();
// check hardware support
static bool isSupported();
void bind();
void unbind();
// implicitly called on bind(), but can be used to reset the VAO
void init();
// opengl object id
GLuint id() const {return id_;}
bool is_valid() const {return id_ != 0;}
operator GLuint() const {return id_;}
GLuint id_;
static int supportStatus_;
//== CLASS DEFINITION =========================================================
......@@ -251,6 +303,7 @@ public:
void setUnit(GLenum u) {unit = u;}
GLenum getUnit() const { return unit; }
GLenum getTarget() const {return target;}
// test for shader_image_load_store support
static bool supportsImageLoadStore();
......@@ -288,6 +341,15 @@ public:
// initialize and set texture data via glTexImage2D
void setData(GLint _level, GLint _internalFormat, GLsizei _width, GLsizei _height, GLenum _format, GLenum _type, const GLvoid* _data);
// specify storage of texture (OpenGL 4.2)
// use setData with a nullptr instead if 4.2 is not available
void setStorage(GLsizei _levels, GLenum _internalFormat, GLsizei _width, GLsizei _height);
// initialize and load from file
// supports png, jpg etc. (any format that can be loaded by qt)
// additionally supports dds if the gli library is available while building ACG
bool loadFromFile(const std::string& _filename, GLenum _minFilter = GL_NEAREST_MIPMAP_LINEAR, GLenum _magFilter = GL_LINEAR);
// use texture as image load/store (equivalent of unordered access buffers in dx11)
// allows data scattering operations in shader ie. random read/write access
// ref:
......@@ -303,6 +365,10 @@ public:
GLenum getFormat() const {return format_;}
GLenum getType() const {return type_;}
// read data back to sysmem
bool getData(GLint _level, void* _dst);
bool getData(GLint _level, std::vector<char>& _dst);
GLsizei width_, height_;
......@@ -401,6 +467,10 @@ public:
GLenum getFormat() const {return fmt_;}
// read buffer data back to sysmem
bool getBufferData(void* _dst);
bool getBufferData(std::vector<char>& _dst);
int bufferSize_;
......@@ -645,6 +715,114 @@ private:
//== CLASS DEFINITION =========================================================
Timer query:
Performance counter for profiling GPU timings
opengl-core: 3.2
.. gl-calls
GLuint64 ns = counter.elapsedNs();
\note elapsedX() methods synchronize CPU and GPU, so this has a performance hit on CPU side
class ACGDLLEXPORT QueryCounter
virtual ~QueryCounter();
void restart();
void stop();
/// elapsed gpu time since restart() in nanosecs
GLuint64 elapsedNs();
/// elapsed gpu time in millisecs
GLuint64 elapsedMs();
/// elapsed gpu time in seconds
float elapsedSecs();
/// check hw support
static bool isSupported();
GLuint queryObjects_[2];
int state_; // -1 : not started, 0 : started, 1 : stopped
static int supportStatus_;
//== CLASS DEFINITION =========================================================
Shader storage buffer object:
Similar to uniform buffer object and also texture buffer.
Can be read and written to from within shaders.
Also, the size of a SSBO is typically only bounded by the physical VRAM limitation,
so it should be used for large data sets or unknown sized arrays.
opengl-core: 4.3
init on application-side with data:
ssbo.upload(datasize, dataptr, GL_DYNAMIC_DRAW);
bind to a binding index:
in shader:
layout (stdxxx, binding = idx) buffer mySSBO
vec4 v4;
vec4 v_unbounded[];
class ACGDLLEXPORT ShaderStorageBufferObject : public VertexBufferObject
virtual ~ShaderStorageBufferObject();
// use this to bind to a shader binding point
void bind(GLuint _index);
// check hardware support
static bool isSupported();
// get hw caps
static int getMaxBindings();
static int getMaxBlocksize();
static int getMaxCombinedShaderBlocks();
static void queryCaps();
// hw caps
static int supportStatus_;
static int maxBlockSize_;
static int maxBindings_;
static int maxCombinedShaderBlocks_;
} // namespace ACG
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment