Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
acgl
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ACGL
acgl
Commits
d53f361c
Commit
d53f361c
authored
Aug 04, 2011
by
Robert Menzel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed mixed CRLF/LF to LF
parent
3a8b2ebe
Changes
39
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
3299 additions
and
3298 deletions
+3299
-3298
CMakeLists.txt
CMakeLists.txt
+87
-87
include/ACGL/GLUtils/Tools.hh
include/ACGL/GLUtils/Tools.hh
+111
-109
include/ACGL/Resource/ArrayBuffer.hh
include/ACGL/Resource/ArrayBuffer.hh
+176
-176
include/ACGL/Resource/ArrayBufferControl.hh
include/ACGL/Resource/ArrayBufferControl.hh
+85
-85
include/ACGL/Resource/ElementArrayBuffer.hh
include/ACGL/Resource/ElementArrayBuffer.hh
+114
-114
include/ACGL/Resource/ElementArrayBufferControl.hh
include/ACGL/Resource/ElementArrayBufferControl.hh
+75
-75
include/ACGL/Resource/FileManager.hh
include/ACGL/Resource/FileManager.hh
+141
-141
include/ACGL/Resource/FrameBuffer.hh
include/ACGL/Resource/FrameBuffer.hh
+201
-201
include/ACGL/Resource/FrameBufferControl.hh
include/ACGL/Resource/FrameBufferControl.hh
+70
-70
include/ACGL/Resource/NameManager.hh
include/ACGL/Resource/NameManager.hh
+111
-111
include/ACGL/Resource/RenderBuffer.hh
include/ACGL/Resource/RenderBuffer.hh
+58
-58
include/ACGL/Resource/RenderBufferControl.hh
include/ACGL/Resource/RenderBufferControl.hh
+56
-56
include/ACGL/Resource/Shader.hh
include/ACGL/Resource/Shader.hh
+88
-88
include/ACGL/Resource/ShaderControlFile.hh
include/ACGL/Resource/ShaderControlFile.hh
+48
-48
include/ACGL/Resource/ShaderProgram.hh
include/ACGL/Resource/ShaderProgram.hh
+120
-120
include/ACGL/Resource/ShaderProgramControlAutoFiles.hh
include/ACGL/Resource/ShaderProgramControlAutoFiles.hh
+35
-35
include/ACGL/Resource/Texture.hh
include/ACGL/Resource/Texture.hh
+236
-236
include/ACGL/Resource/TextureControl.hh
include/ACGL/Resource/TextureControl.hh
+87
-87
include/ACGL/Resource/TextureControlFileJPG.hh
include/ACGL/Resource/TextureControlFileJPG.hh
+54
-54
include/ACGL/Resource/Uniform.hh
include/ACGL/Resource/Uniform.hh
+86
-86
include/ACGL/Resource/VertexBuffer.hh
include/ACGL/Resource/VertexBuffer.hh
+131
-131
include/ACGL/Resource/VertexBufferControl.hh
include/ACGL/Resource/VertexBufferControl.hh
+82
-82
include/ACGL/Resource/VertexBufferControlFileOBJ.hh
include/ACGL/Resource/VertexBufferControlFileOBJ.hh
+38
-38
include/ACGL/Utils/Log.hh
include/ACGL/Utils/Log.hh
+120
-120
src/ACGL/GLUtils/Tools.cc
src/ACGL/GLUtils/Tools.cc
+50
-50
src/ACGL/Resource/ArrayBuffer.cc
src/ACGL/Resource/ArrayBuffer.cc
+26
-26
src/ACGL/Resource/ArrayBufferControl.cc
src/ACGL/Resource/ArrayBufferControl.cc
+24
-24
src/ACGL/Resource/FrameBuffer.cc
src/ACGL/Resource/FrameBuffer.cc
+13
-13
src/ACGL/Resource/FrameBufferControl.cc
src/ACGL/Resource/FrameBufferControl.cc
+22
-22
src/ACGL/Resource/Shader.cc
src/ACGL/Resource/Shader.cc
+101
-101
src/ACGL/Resource/ShaderControlFile.cc
src/ACGL/Resource/ShaderControlFile.cc
+42
-42
src/ACGL/Resource/ShaderProgram.cc
src/ACGL/Resource/ShaderProgram.cc
+60
-60
src/ACGL/Resource/ShaderProgramControlAutoFiles.cc
src/ACGL/Resource/ShaderProgramControlAutoFiles.cc
+29
-29
src/ACGL/Resource/TextureControlFileJPG.cc
src/ACGL/Resource/TextureControlFileJPG.cc
+34
-35
src/ACGL/Resource/TextureControlFileJPG_QImage.cc
src/ACGL/Resource/TextureControlFileJPG_QImage.cc
+25
-25
src/ACGL/Resource/VertexBuffer.cc
src/ACGL/Resource/VertexBuffer.cc
+48
-48
src/ACGL/Resource/VertexBufferControl.cc
src/ACGL/Resource/VertexBufferControl.cc
+40
-40
src/ACGL/Resource/VertexBufferControlFileOBJ.cc
src/ACGL/Resource/VertexBufferControlFileOBJ.cc
+320
-320
src/ACGL/Utils/Log.cc
src/ACGL/Utils/Log.cc
+55
-55
No files found.
CMakeLists.txt
View file @
d53f361c
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.6
)
################################################################################
# Global Settings
################################################################################
# Name of the Project
PROJECT
(
ACGL
)
INCLUDE
(
${
CMAKE_SOURCE_DIR
}
/cmake/CompileOptions.txt
)
# Specify dependencies
SET
(
NEED_ACGL_GLOBAL_EXTERN_DIR TRUE
)
INCLUDE
(
${
CMAKE_SOURCE_DIR
}
/cmake/GlobalAndLocalExternACGL.txt
)
# OpenGL Support
IF
(
NOT DEFINED OPENGL_SUPPORT
)
IF
(
NOT DEFINED OPENGL_SUPPORT_CORE_4_0
)
SET
(
OPENGL_SUPPORT_CORE_4_0 TRUE CACHE BOOL
""
)
ENDIF
()
IF
(
NOT DEFINED OPENGL_SUPPORT_ES_2_1
)
SET
(
OPENGL_SUPPORT_ES_2_1 TRUE CACHE BOOL
""
)
ENDIF
()
IF
(
OPENGL_SUPPORT_CORE_4_0
)
SET
(
OPENGL_SUPPORT_LIST
${
OPENGL_SUPPORT_LIST
}
GL_CORE_4_0
)
ENDIF
()
IF
(
OPENGL_SUPPORT_ES_2_1
)
SET
(
OPENGL_SUPPORT_LIST
${
OPENGL_SUPPORT_LIST
}
GL_ES_2_1
)
ENDIF
()
ELSE
()
SET
(
OPENGL_SUPPORT_LIST
${
OPENGL_SUPPORT
}
)
ENDIF
()
FOREACH
(
OPENGL_SUPPORT
${
OPENGL_SUPPORT_LIST
}
)
################################################################################
# Basic Configuration
################################################################################
# Name of the Project
PROJECT
(
AC
${
OPENGL_SUPPORT
}
)
# Where to find the cmake finders?
SET
(
CMAKE_MODULE_PATH
"
${
CMAKE_SOURCE_DIR
}
/cmake"
${
CMAKE_MODULE_PATH
}
)
# Target directory
SET
(
LIBRARY_OUTPUT_PATH
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/lib"
)
################################################################################
# Project Files
################################################################################
# Find all used files of certain file-types
FILE
(
GLOB_RECURSE SOURCE_FILES
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/*.cc"
)
FILE
(
GLOB_RECURSE INCLUDE_FILES
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/*.hh"
)
# Add ACGL to the include path
INCLUDE_DIRECTORIES
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
)
################################################################################
# External Libraries
################################################################################
# Qt
SET
(
QT_USE_QTOPENGL TRUE
)
FIND_PACKAGE
(
Qt4 REQUIRED
)
INCLUDE
(
${
QT_USE_FILE
}
)
SET
(
LIBRARIES
${
LIBRARIES
}
${
QT_LIBRARIES
}
)
# GLM
FIND_PACKAGE
(
GLM REQUIRED
)
INCLUDE_DIRECTORIES
(
${
GLM_INCLUDE_DIR
}
)
# GLEW
FIND_PACKAGE
(
GLEW REQUIRED
)
INCLUDE_DIRECTORIES
(
${
GLEW_INCLUDE_DIR
}
)
SET
(
LIBRARIES
${
LIBRARIES
}
${
GLEW_LIBRARIES
}
)
################################################################################
# Final Definition
################################################################################
# Define the Project, add all required sources and dependencies to it
ADD_LIBRARY
(
AC
${
OPENGL_SUPPORT
}${
COMPILE_POSTFIX
}
STATIC
${
SOURCE_FILES
}
${
INCLUDE_FILES
}
)
TARGET_LINK_LIBRARIES
(
AC
${
OPENGL_SUPPORT
}${
COMPILE_POSTFIX
}
${
LIBRARIES
}
)
ENDFOREACH
()
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.6
)
################################################################################
# Global Settings
################################################################################
# Name of the Project
PROJECT
(
ACGL
)
INCLUDE
(
${
CMAKE_SOURCE_DIR
}
/cmake/CompileOptions.txt
)
# Specify dependencies
SET
(
NEED_ACGL_GLOBAL_EXTERN_DIR TRUE
)
INCLUDE
(
${
CMAKE_SOURCE_DIR
}
/cmake/GlobalAndLocalExternACGL.txt
)
# OpenGL Support
IF
(
NOT DEFINED OPENGL_SUPPORT
)
IF
(
NOT DEFINED OPENGL_SUPPORT_CORE_4_0
)
SET
(
OPENGL_SUPPORT_CORE_4_0 TRUE CACHE BOOL
""
)
ENDIF
()
IF
(
NOT DEFINED OPENGL_SUPPORT_ES_2_1
)
SET
(
OPENGL_SUPPORT_ES_2_1 TRUE CACHE BOOL
""
)
ENDIF
()
IF
(
OPENGL_SUPPORT_CORE_4_0
)
SET
(
OPENGL_SUPPORT_LIST
${
OPENGL_SUPPORT_LIST
}
GL_CORE_4_0
)
ENDIF
()
IF
(
OPENGL_SUPPORT_ES_2_1
)
SET
(
OPENGL_SUPPORT_LIST
${
OPENGL_SUPPORT_LIST
}
GL_ES_2_1
)
ENDIF
()
ELSE
()
SET
(
OPENGL_SUPPORT_LIST
${
OPENGL_SUPPORT
}
)
ENDIF
()
FOREACH
(
OPENGL_SUPPORT
${
OPENGL_SUPPORT_LIST
}
)
################################################################################
# Basic Configuration
################################################################################
# Name of the Project
PROJECT
(
AC
${
OPENGL_SUPPORT
}
)
# Where to find the cmake finders?
SET
(
CMAKE_MODULE_PATH
"
${
CMAKE_SOURCE_DIR
}
/cmake"
${
CMAKE_MODULE_PATH
}
)
# Target directory
SET
(
LIBRARY_OUTPUT_PATH
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/lib"
)
################################################################################
# Project Files
################################################################################
# Find all used files of certain file-types
FILE
(
GLOB_RECURSE SOURCE_FILES
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/*.cc"
)
FILE
(
GLOB_RECURSE INCLUDE_FILES
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/*.hh"
)
# Add ACGL to the include path
INCLUDE_DIRECTORIES
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
)
################################################################################
# External Libraries
################################################################################
# Qt
SET
(
QT_USE_QTOPENGL TRUE
)
FIND_PACKAGE
(
Qt4 REQUIRED
)
INCLUDE
(
${
QT_USE_FILE
}
)
SET
(
LIBRARIES
${
LIBRARIES
}
${
QT_LIBRARIES
}
)
# GLM
FIND_PACKAGE
(
GLM REQUIRED
)
INCLUDE_DIRECTORIES
(
${
GLM_INCLUDE_DIR
}
)
# GLEW
FIND_PACKAGE
(
GLEW REQUIRED
)
INCLUDE_DIRECTORIES
(
${
GLEW_INCLUDE_DIR
}
)
SET
(
LIBRARIES
${
LIBRARIES
}
${
GLEW_LIBRARIES
}
)
################################################################################
# Final Definition
################################################################################
# Define the Project, add all required sources and dependencies to it
ADD_LIBRARY
(
AC
${
OPENGL_SUPPORT
}${
COMPILE_POSTFIX
}
STATIC
${
SOURCE_FILES
}
${
INCLUDE_FILES
}
)
TARGET_LINK_LIBRARIES
(
AC
${
OPENGL_SUPPORT
}${
COMPILE_POSTFIX
}
${
LIBRARIES
}
)
ENDFOREACH
()
include/ACGL/GLUtils/Tools.hh
View file @
d53f361c
...
...
@@ -3,112 +3,114 @@
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef ACGL_GLUTILS_TOOLS_HH
#define ACGL_GLUTILS_TOOLS_HH
#include <ACGL/ACGL.hh>
#include <ACGL/GL.hh>
namespace
ACGL
{
namespace
GLUtils
{
namespace
Tools
{
inline
GLint
getGLTypeSize
(
GLenum
_type
)
{
switch
(
_type
)
{
case
GL_BYTE
:
return
sizeof
(
GLubyte
);
case
GL_UNSIGNED_BYTE
:
return
sizeof
(
GLbyte
);
case
GL_SHORT
:
return
sizeof
(
GLshort
);
case
GL_UNSIGNED_SHORT
:
return
sizeof
(
GLushort
);
case
GL_INT
:
return
sizeof
(
GLint
);
case
GL_UNSIGNED_INT
:
return
sizeof
(
GLuint
);
case
GL_FLOAT
:
return
sizeof
(
GLfloat
);
case
GL_DOUBLE
:
return
sizeof
(
GLdouble
);
}
return
0
;
}
// for every OpenGL error enum this will return a human readable version of it
// similar to gluErrorString, but that function is not available on all plattforms
// (read: iOS)
const
GLubyte
*
acglErrorString
(
GLenum
err
);
/*
* This function can be used outside of the ACGL framework to check always(!) for
* OpenGL errors. It will print the errors and return the error code of the last one.
* Each OpenGL command can only throw one error, errors can only stack up if this
* function or glGetError was not called often enough (and some OpenGL implementations
* will forget old errors if new ones occur).
*/
#define openGLError() openGLError_( __FILE__, __LINE__ )
/*
* This function is used internally in ACGL - but not directly. It gets called from all
* other rare/common/critical error checks. The __FILE__ __LINE macros have to be used in
* those to get the correct values from the caller file, if we would use the macro
* above we could get the file/line from this file, which isn't helping.
*/
GLenum
openGLError_
(
const
char
*
_fileName
,
const
unsigned
long
_lineNumber
);
/*
* Inside of ACGL we distinguish between rare, common and critical errors. Each kind can be
* switched off which turns the function into nothing after compiler optimization. If an
* error check is turned off it will always behave as if there was no error, even if there
* is one...
*
* Per default a debug build enables critical and common errors, a release build only critical
* ones.
*
* We have two functions for each kind:
* openGL____Error() will print error messages and return the last error (or GL_NO_ERROR)
* openGL____ErrorOccured() will print error messages and retrun true if there was an error
*
* The definition of rare/common/critical is a bit fuzzy:
*
* critical: Errors which can occur even in a bug-free app, like out-of-memory errors.
* These checks are rare, stuff like glCreate calls get checked here.
* Tests for critical errors should not impact the performance of the app measurably.
*
* common: Errors which are quite common while developing. Misuse of the library etc.
* Setting uniforms which don't exist or shader compile errors are candidates for
* common errors. Places where OpenGL resources are calles by a string etc.
*
* rare: Errors which are so uncommon that we don't even check those ina normal debug build.
* Switching these on can impact performance as there can be alot of them. If theres a
* OpenGL error somewhere in the code, switch these checks on to find the correct spot.
*
* OpenGL error checks that are more complicated than just a glGetError call will be wrapped in the
* same defines, this can be used in application code as well.
*
*/
#ifdef ACGL_CHECK_CRITICAL_GL_ERRORS
# define openGLCriticalError() openGLError_( __FILE__, __LINE__ )
# define openGLCriticalErrorOccured() (openGLError_( __FILE__, __LINE__ ) != GL_NO_ERROR)
#else
inline
GLenum
openGLCriticalError
()
{
return
GL_NO_ERROR
;
}
inline
bool
openGLCriticalErrorOccured
()
{
return
false
;
}
#endif
#ifdef ACGL_CHECK_COMMON_GL_ERRORS
# define openGLCommonError() openGLError_( __FILE__, __LINE__ )
# define openGLCommonErrorOccured() (openGLError_( __FILE__, __LINE__ ) != GL_NO_ERROR)
#else
inline
GLenum
openGLCommonError
()
{
return
GL_NO_ERROR
;
}
inline
bool
openGLCommonErrorOccured
()
{
return
false
;
}
#endif
#ifdef ACGL_CHECK_RARE_GL_ERRORS
# define openGLRareError() openGLError_( __FILE__, __LINE__ )
# define openGLRareErrorOccured() (openGLError_( __FILE__, __LINE__ ) != GL_NO_ERROR)
#else
inline
GLenum
openGLRareError
()
{
return
GL_NO_ERROR
;
}
inline
bool
openGLRareErrorOccured
()
{
return
false
;
}
#endif
}
// Tools
}
// GLUtils
}
// ACGL
#endif // ACGL_GLUTILS_TOOLS_HH
#ifndef ACGL_GLUTILS_TOOLS_HH
#define ACGL_GLUTILS_TOOLS_HH
#include <ACGL/ACGL.hh>
#include <ACGL/GL.hh>
namespace
ACGL
{
namespace
GLUtils
{
namespace
Tools
{
inline
GLint
getGLTypeSize
(
GLenum
_type
)
{
switch
(
_type
)
{
case
GL_BYTE
:
return
sizeof
(
GLubyte
);
case
GL_UNSIGNED_BYTE
:
return
sizeof
(
GLbyte
);
case
GL_SHORT
:
return
sizeof
(
GLshort
);
case
GL_UNSIGNED_SHORT
:
return
sizeof
(
GLushort
);
case
GL_INT
:
return
sizeof
(
GLint
);
case
GL_UNSIGNED_INT
:
return
sizeof
(
GLuint
);
case
GL_FLOAT
:
return
sizeof
(
GLfloat
);
case
GL_DOUBLE
:
return
sizeof
(
GLdouble
);
}
return
0
;
}
// for every OpenGL error enum this will return a human readable version of it
// similar to gluErrorString, but that function is not available on all plattforms
// (read: iOS)
const
GLubyte
*
acglErrorString
(
GLenum
err
);
/*
* This function can be used outside of the ACGL framework to check always(!) for
* OpenGL errors. It will print the errors and return the error code of the last one.
* Each OpenGL command can only throw one error, errors can only stack up if this
* function or glGetError was not called often enough (and some OpenGL implementations
* will forget old errors if new ones occur).
*/
#define openGLError() openGLError_( __FILE__, __LINE__ )
/*
* This function is used internally in ACGL - but not directly. It gets called from all
* other rare/common/critical error checks. The __FILE__ __LINE macros have to be used in
* those to get the correct values from the caller file, if we would use the macro
* above we could get the file/line from this file, which isn't helping.
*/
GLenum
openGLError_
(
const
char
*
_fileName
,
const
unsigned
long
_lineNumber
);
/*
* Inside of ACGL we distinguish between rare, common and critical errors. Each kind can be
* switched off which turns the function into nothing after compiler optimization. If an
* error check is turned off it will always behave as if there was no error, even if there
* is one...
*
* Per default a debug build enables critical and common errors, a release build only critical
* ones.
*
* We have two functions for each kind:
* openGL____Error() will print error messages and return the last error (or GL_NO_ERROR)
* openGL____ErrorOccured() will print error messages and retrun true if there was an error
*
* The definition of rare/common/critical is a bit fuzzy:
*
* critical: Errors which can occur even in a bug-free app, like out-of-memory errors.
* These checks are rare, stuff like glCreate calls get checked here.
* Tests for critical errors should not impact the performance of the app measurably.
*
* common:
* Errors which are quite common while developing. Misuse of the library etc.
* Setting uniforms which don't exist or shader compile errors are candidates for
* common errors. Places where OpenGL resources are calles by a string etc.
*
* rare: Errors which are so uncommon that we don't even check those ina normal debug build.
* Switching these on can impact performance as there can be alot of them. If theres a
* OpenGL error somewhere in the code, switch these checks on to find the correct spot.
*
* OpenGL error checks that are more complicated than just a glGetError call will be wrapped in the
* same defines, this can be used in application code as well.
*
*/
#ifdef ACGL_CHECK_CRITICAL_GL_ERRORS
# define openGLCriticalError() openGLError_( __FILE__, __LINE__ )
# define openGLCriticalErrorOccured() (openGLError_( __FILE__, __LINE__ ) != GL_NO_ERROR)
#else
inline
GLenum
openGLCriticalError
()
{
return
GL_NO_ERROR
;
}
inline
bool
openGLCriticalErrorOccured
()
{
return
false
;
}
#endif
#ifdef ACGL_CHECK_COMMON_GL_ERRORS
# define openGLCommonError() openGLError_( __FILE__, __LINE__ )
# define openGLCommonErrorOccured() (openGLError_( __FILE__, __LINE__ ) != GL_NO_ERROR)
#else
inline
GLenum
openGLCommonError
()
{
return
GL_NO_ERROR
;
}
inline
bool
openGLCommonErrorOccured
()
{
return
false
;
}
#endif
#ifdef ACGL_CHECK_RARE_GL_ERRORS
# define openGLRareError() openGLError_( __FILE__, __LINE__ )
# define openGLRareErrorOccured() (openGLError_( __FILE__, __LINE__ ) != GL_NO_ERROR)
#else
inline
GLenum
openGLRareError
()
{
return
GL_NO_ERROR
;
}
inline
bool
openGLRareErrorOccured
()
{
return
false
;
}
#endif
}
// Tools
}
// GLUtils
}
// ACGL
#endif // ACGL_GLUTILS_TOOLS_HH
include/ACGL/Resource/ArrayBuffer.hh
View file @
d53f361c
...
...
@@ -3,179 +3,179 @@
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef ACGL_RESOURCE_ARRAYBUFFER_HH
#define ACGL_RESOURCE_ARRAYBUFFER_HH
#include <ACGL/GLUtils/Tools.hh>
#include <ACGL/Types.hh>
#include <ACGL/GL.hh>
#include <string>
#include <vector>
namespace
ACGL
{
namespace
Resource
{
class
ArrayBuffer
{
// ==================================================================================================== \/
// ============================================================================================ STRUCTS \/
// ==================================================================================================== \/
public:
//! Each attribute has a dimension (#components, e.g. normal with x/y/z => 3) and an offset in the stride (in bytes)
struct
Attribute
{
std
::
string
name
;
GLenum
type
;
GLint
dimension
;
GLint
offset
;
};
// ===================================================================================================== \/
// ============================================================================================ TYPEDEFS \/
// ===================================================================================================== \/
public:
typedef
std
::
vector
<
Attribute
>
AttributeVec
;
// ========================================================================================================= \/
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
ArrayBuffer
(
GLenum
_usage
=
GL_STATIC_DRAW
,
GLenum
_mode
=
GL_TRIANGLES
)
:
mContext
(
0
),
mUsage
(
_usage
),
mMode
(
_mode
),
mElements
(
0
),
mStride
(
0
),
mAttributes
()
{
glGenBuffers
(
1
,
&
mContext
);
}
virtual
~
ArrayBuffer
(
void
)
{
if
(
mContext
!=
0
)
glDeleteBuffers
(
1
,
&
mContext
);
}
// ==================================================================================================== \/
// ============================================================================================ GETTERS \/
// ==================================================================================================== \/
public:
inline
GLuint
getContext
(
void
)
const
{
return
mContext
;
}
inline
GLenum
getUsage
(
void
)
const
{
return
mUsage
;
}
inline
GLenum
getMode
(
void
)
const
{
return
mMode
;
}
inline
GLsizei
getElements
(
void
)
const
{
return
mElements
;
}
inline
GLsizei
getStride
(
void
)
const
{
return
mStride
;
}
inline
const
AttributeVec
&
getAttributes
(
void
)
const
{
return
mAttributes
;
}
// ==================================================================================================== \/
// ============================================================================================ SETTERS \/
// ==================================================================================================== \/
public:
inline
void
setUsage
(
GLenum
_usage
)
{
mUsage
=
_usage
;
}
inline
void
setMode
(
GLenum
_mode
)
{
mMode
=
_mode
;
}
// ==================================================================================================== \/
// ============================================================================================ METHODS \/
// ==================================================================================================== \/
public:
int_t
getAttributeIndexByName
(
const
std
::
string
&
_nameInArray
)
const
;
inline
void
attachAttribute
(
const
std
::
string
&
_name
,
GLenum
_type
,
GLint
_dimension
)
{
Attribute
attribute
=
{
_name
,
_type
,
_dimension
,
mStride
};
mStride
+=
GLUtils
::
Tools
::
getGLTypeSize
(
_type
)
*
_dimension
;
mAttributes
.
push_back
(
attribute
);
}
inline
void
removeAttributes
(
void
)
{
mStride
=
0
;
mAttributes
.
clear
();
}
// ===================================================================================================== \/
// ============================================================================================ WRAPPERS \/
// ===================================================================================================== \/
public:
void
render
(
void
)
const
;
void
draw
(
void
)
const
{
glDrawArrays
(
mMode
,
0
,
mElements
);
}
//! Bind this buffer
inline
void
bind
(
void
)
const
{
glBindBuffer
(
GL_ARRAY_BUFFER
,
mContext
);
}
inline
void
setPointer
(
AttributeVec
::
size_type
_indexInArray
,
GLuint
_indexInShader
)
const
{
glVertexAttribPointer
(
_indexInShader
,
mAttributes
[
_indexInArray
].
dimension
,
mAttributes
[
_indexInArray
].
type
,
GL_FALSE
,
mStride
,
reinterpret_cast
<
GLvoid
*>
(
mAttributes
[
_indexInArray
].
offset
));
}
inline
bool
setPointer
(
const
std
::
string
&
_nameInArray
,
GLuint
_indexInShader
)
const
{
int_t
index
=
getAttributeIndexByName
(
_nameInArray
);
if
(
index
==
-
1
)
return
false
;
setPointer
(
index
,
_indexInShader
);
return
true
;
}
//! Set data for this buffer
inline
void
setData
(
const
GLvoid
*
_pData
)
const
{
glBufferData
(
GL_ARRAY_BUFFER
,
mStride
*
mElements
,
_pData
,
mUsage
);
}
//! Set data for this buffer and change its size
inline
void
setData
(
const
GLvoid
*
_pData
,
GLsizei
_elements
)
{
mElements
=
_elements
;
glBufferData
(
GL_ARRAY_BUFFER
,
mStride
*
mElements
,
_pData
,
mUsage
);
}
// =================================================================================================== \/
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
protected:
GLuint
mContext
;
GLenum
mUsage
;
GLenum
mMode
;
GLsizei
mElements
;
GLsizei
mStride
;
AttributeVec
mAttributes
;
};
}
// Resource
}
// ACGL
#endif // ACGL_RESOURCE_ARRAYBUFFER_HH
#ifndef ACGL_RESOURCE_ARRAYBUFFER_HH
#define ACGL_RESOURCE_ARRAYBUFFER_HH
#include <ACGL/GLUtils/Tools.hh>
#include <ACGL/Types.hh>
#include <ACGL/GL.hh>
#include <string>
#include <vector>
namespace
ACGL
{
namespace
Resource
{
class
ArrayBuffer
{
// ==================================================================================================== \/
// ============================================================================================ STRUCTS \/
// ==================================================================================================== \/
public:
//! Each attribute has a dimension (#components, e.g. normal with x/y/z => 3) and an offset in the stride (in bytes)
struct
Attribute
{
std
::
string
name
;
GLenum
type
;
GLint
dimension
;
GLint
offset
;
};
// ===================================================================================================== \/
// ============================================================================================ TYPEDEFS \/
// ===================================================================================================== \/
public:
typedef
std
::
vector
<
Attribute
>
AttributeVec
;
// ========================================================================================================= \/
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
ArrayBuffer
(
GLenum
_usage
=
GL_STATIC_DRAW
,
GLenum
_mode
=
GL_TRIANGLES
)
:
mContext
(
0
),
mUsage
(
_usage
),
mMode
(
_mode
),
mElements
(
0
),
mStride
(
0
),
mAttributes
()
{
glGenBuffers
(
1
,
&
mContext
);
}
virtual
~
ArrayBuffer
(
void
)