Login  Register

Re: Uniform Buffers mapping and size

Posted by Sven Gothel on Jun 14, 2013; 2:53am
URL: https://forum.jogamp.org/Uniform-Buffers-mapping-and-size-tp4029403p4029412.html

On 06/13/2013 09:23 PM, zzuegg [via jogamp] wrote:
> From the OpenGL side (Not ES) everything needed for UBO is already here. The
> question was how do i actually pass the values to the GPU, probably trough a
> bytebuffer. Well i am implementing it and hopefully the mapping (from
> bytebuffer to glsl struct) get's done automatically.

yes .. that is the point.

I.e. in the native code world, I assume you simply pass
the pointer to a c-structure and push the sizeof(struct)
down to the GPU while adjusting alignment - right ..

<https://www.opengl.org/wiki/Uniform_Buffer_Object>
<https://www.opengl.org/wiki/Buffer_Object#Binding_indexed_targets>

Hence you might want to use GlueGen's StructAccessor
to map a c-struct to java.
The Platform's MachineDescriptor will give you information
about the alignment.

Usually you would do that in a tedious way, i.e.
configure gluegen for your few c-structs, etc.

To ease this process, I have [finally] merged and enhanced
the Annotated Processor (APT) once written by Michael Bien
into gluegen.jar.

<http://jogamp.org/git/?p=gluegen.git;a=commit;h=a7802a2ab90a68ecbba962149a335f975fce24e7>

Within this commit, you can see how the new unit test is being processed,
i.e. added ant recipe for APT .. should work seamless.
  -> TestStructGen01.java, TestStruct01.h

Having this tool, you should be able to write your uniform structure
in a little c-struct file and map it automatic to java.

Now .. your task would be to use the GL3 spec properly
and add a unit test in our JOGL package:

   com.jogamp.opengl.test.junit.jogl.demos.gl3

would be _very_ much appreciated!

Cheers, Sven



signature.asc (911 bytes) Download Attachment