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
c2fe617c
Commit
c2fe617c
authored
Apr 03, 2012
by
Robert Menzel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for vertex array divisor
parent
2e0b0057
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
10 deletions
+17
-10
include/ACGL/OpenGL/Objects/ArrayBuffer.hh
include/ACGL/OpenGL/Objects/ArrayBuffer.hh
+5
-4
src/ACGL/OpenGL/Objects/ArrayBuffer.cc
src/ACGL/OpenGL/Objects/ArrayBuffer.cc
+9
-6
src/ACGL/OpenGL/Objects/VertexArrayObject.cc
src/ACGL/OpenGL/Objects/VertexArrayObject.cc
+3
-0
No files found.
include/ACGL/OpenGL/Objects/ArrayBuffer.hh
View file @
c2fe617c
...
...
@@ -78,6 +78,7 @@ public:
GLint
size
;
// #elements per attribute, size in bytes would be: size*sizeof(type)
GLuint
offset
;
// offset in bytes into the array
GLboolean
normalized
;
// int types can get normalzed to 0..1 / -1..1 by GL, useful e.g. for colors
GLuint
divisor
;
// vertex divisor for instancing, supported since OpenGL 3.3
};
// ===================================================================================================== \/
...
...
@@ -109,7 +110,7 @@ public:
// ==================================================================================================== \/
public:
//! elements is the number of vertices
(unless this AB should get interpreted in a strange way
):
//! elements is the number of vertices
or instances (if the divisor is != 0
):
inline
GLsizei
getElements
(
void
)
const
{
return
(
GLsizei
)
(
mStride
==
0
?
0
:
(
mSize
/
mStride
));
}
//! size in bytes of all attributes that make up one element (vertex):
...
...
@@ -126,16 +127,16 @@ public:
// ==================================================================================================== \/
public:
//! Adds the attribute at the end of the existing attributes, stride gets computed automatically
void
defineAttribute
(
const
std
::
string
&
_name
,
GLenum
_type
,
GLint
_size
,
GLboolean
_normalized
=
GL_FALSE
);
void
defineAttribute
(
const
std
::
string
&
_name
,
GLenum
_type
,
GLint
_size
,
GLboolean
_normalized
=
GL_FALSE
,
GLuint
_divisor
=
0
);
//! Adds the attribute at the end of the existing attributes, stride gets computed automatically
//! + extra padding in bytes at the end
void
defineAttributeWithPadding
(
const
std
::
string
&
_name
,
GLenum
_type
,
GLint
_size
,
GLuint
_padding
,
GLboolean
_normalized
=
GL_FALSE
);
void
defineAttributeWithPadding
(
const
std
::
string
&
_name
,
GLenum
_type
,
GLint
_size
,
GLuint
_padding
,
GLboolean
_normalized
=
GL_FALSE
,
GLuint
_divisor
=
0
);
//! Adds an attribute defined by an offset: this way an attribute can get added at arbitrary
//! locations in the stride. If it's added at the end, the stride gets resized. This way attributes can even
//! overlap, hope you know what you're doing...
void
defineAttributeWithOffset
(
const
std
::
string
&
_name
,
GLenum
_type
,
GLint
_size
,
GLuint
_offset
,
GLboolean
_normalized
=
GL_FALSE
);
void
defineAttributeWithOffset
(
const
std
::
string
&
_name
,
GLenum
_type
,
GLint
_size
,
GLuint
_offset
,
GLboolean
_normalized
=
GL_FALSE
,
GLuint
_divisor
=
0
);
//! Takes care of a valid stride size and adds the attribute
void
defineAttribute
(
const
Attribute
&
_attribute
);
...
...
src/ACGL/OpenGL/Objects/ArrayBuffer.cc
View file @
c2fe617c
...
...
@@ -12,10 +12,11 @@ void ArrayBuffer::defineAttribute(
const
std
::
string
&
_name
,
GLenum
_type
,
GLint
_size
,
GLboolean
_normalized
)
GLboolean
_normalized
,
GLuint
_divisor
)
{
GLuint
offset
=
mStride
;
Attribute
attribute
=
{
_name
,
_type
,
_size
,
offset
,
_normalized
};
Attribute
attribute
=
{
_name
,
_type
,
_size
,
offset
,
_normalized
,
_divisor
};
defineAttribute
(
attribute
);
}
...
...
@@ -24,10 +25,11 @@ void ArrayBuffer::defineAttributeWithPadding(
GLenum
_type
,
GLint
_size
,
GLuint
_padding
,
GLboolean
_normalized
)
GLboolean
_normalized
,
GLuint
_divisor
)
{
GLuint
offset
=
mStride
;
Attribute
attribute
=
{
_name
,
_type
,
_size
,
offset
,
_normalized
};
Attribute
attribute
=
{
_name
,
_type
,
_size
,
offset
,
_normalized
,
_divisor
};
defineAttribute
(
attribute
);
// defineAttribute will shift the mStride to the end of this attribute, so we only have to
// add the explicit padding:
...
...
@@ -39,9 +41,10 @@ void ArrayBuffer::defineAttributeWithOffset(
GLenum
_type
,
GLint
_size
,
GLuint
_offset
,
GLboolean
_normalized
)
GLboolean
_normalized
,
GLuint
_divisor
)
{
Attribute
attribute
=
{
_name
,
_type
,
_size
,
_offset
,
_normalized
};
Attribute
attribute
=
{
_name
,
_type
,
_size
,
_offset
,
_normalized
,
_divisor
};
defineAttribute
(
attribute
);
}
...
...
src/ACGL/OpenGL/Objects/VertexArrayObject.cc
View file @
c2fe617c
...
...
@@ -209,6 +209,9 @@ void VertexArrayObject::setAttributePointer( GLuint _index )
mAttributes
[
_index
].
arrayBuffer
->
getStride
(),
reinterpret_cast
<
GLvoid
*>
(
arrayBufferAttribute
.
offset
)
);
#if (ACGL_OPENGL_VERSION >= 33)
glVertexAttribDivisor
(
_index
,
arrayBufferAttribute
.
divisor
);
#endif
glEnableVertexAttribArray
(
_index
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment