Hello Johannes,

On 03/27/2014 10:07 AM, Johannes wrote:
finally, the UBOs are making their first movements... :-)

cool!

I have uploaded my files to

http://wikisend.com/download/389584/UniformBufferObjChunk.zip

Could you please take a look and give me some feedback. I have added
some examples and it works on both of my working platforms (NVidia and AMD).

Probably, I did have missed some finer details and I have not yet given
to much of a thought to performance and optimization. However, I'm
convinced that this could be a way to provide OpenSG with UBOs.

looks good to me, some nitpicks I noticed while looking through the code:
- would it be possible to derive UniformBufferObjStd140Chunk from UniformBufferObjChunk to share some code (perhaps by adding a virtual updateBuffer() function that gets called from handleGL)? Not sure if it's worth the effort. - in OSGGLEXT.h the #defines osgMaxUniformBlockSize etc. should be outside #ifndef GL_ARB_uniform_buffer_object, otherwise if you have a GL header on your system that already knows about the extension you don't get the OpenSG defines. [1] - it might be convenient to have a templated add and set function in UniformBufferObjChunk to avoid having to repeat the type in the function name.
Thanks for working on the UBO support!

        Cheers,
                Carsten

[1] see attached patch
diff --git a/Source/Base/Base/OSGGLEXT.h b/Source/Base/Base/OSGGLEXT.h
index 94c08f3..d706641 100644
--- a/Source/Base/Base/OSGGLEXT.h
+++ b/Source/Base/Base/OSGGLEXT.h
@@ -2436,6 +2436,10 @@ typedef ptrdiff_t GLsizeiptrARB;
 #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER  0x8A46
 #define GL_INVALID_INDEX                                0xFFFFFFFFu
 
+#endif /* GL_ARB_uniform_buffer_object */
+
+// keep these outside the ifndef GL_ARB_uniform_buffer_object block for systems
+// with GL headers that define the extension
 #define osgMaxUniformBlockSize                          16384
 #define osgMaxVertexUniformBlocks                          12
 #define osgMaxFragmentUniformBlocks                        12
@@ -2443,6 +2447,5 @@ typedef ptrdiff_t GLsizeiptrARB;
 #define osgMaxCombinedUniformBlocks                        36
 #define osgMaxUniformBufferBindings                        36
 
-#endif /* GL_ARB_uniform_buffer_object */
 /*! \}                                                                 */
 #endif /* _OSGGL_H_ */
diff --git a/Source/System/State/Base/OSGUniformBufferObjChunk.cpp b/Source/System/State/Base/OSGUniformBufferObjChunk.cpp
index ef5ec94..549816b 100644
--- a/Source/System/State/Base/OSGUniformBufferObjChunk.cpp
+++ b/Source/System/State/Base/OSGUniformBufferObjChunk.cpp
@@ -91,7 +91,7 @@ UInt32 UniformBufferObjChunk::_funcBindBufferBase          = Win::invalidFunctio
 UInt32 UniformBufferObjChunk::_funcGetUniformBlockIndex    = Win::invalidFunctionID;
 UInt32 UniformBufferObjChunk::_funcGetActiveUniformBlockiv = Win::invalidFunctionID;
 UInt32 UniformBufferObjChunk::_funcGetActiveUniformsiv     = Win::invalidFunctionID;
-UINT32 UniformBufferObjChunk::_funcGetUniformIndices       = Win::invalidFunctionID;
+UInt32 UniformBufferObjChunk::_funcGetUniformIndices       = Win::invalidFunctionID;
 
 /***************************************************************************\
  *                           Class methods                                 *
------------------------------------------------------------------------------
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to