• OpenGL ES 2, GLSL and Android: A question about Structs.
    4 replies, posted
I'm working on a simple engine for the Android Platform, using pure JDK (no native code). Problem is, I can seem to figure how the hell am I supossed to push structs into the GLSL Shader, so that I can start working with Light and stuff. Most of the code is there already, loading .obj files, basic touch events, textures, etc. Help or Documentation would be great, code snippets could help, but I'd rather have a good doc on it. (Please keep in mind that this is the FIRST TIME I'm using OpenGL)
You have to use Java [url=http://docs.oracle.com/javase/1.4.2/docs/api/java/nio/Buffer.html]Buffers[/url] and ByteBuffers and dick around with byte ordering. It's really not fun at all.
[QUOTE=ROBO_DONUT;33597847]You have to use Java [url=http://docs.oracle.com/javase/1.4.2/docs/api/java/nio/Buffer.html]Buffers[/url] and ByteBuffers and dick around with byte ordering. It's really not fun at all.[/QUOTE] So, I have to send a whole buffer at once? with all the variables ordered? Also, what procedure should I call to do that?
[QUOTE=JohnnyOnFlame;33598544]So, I have to send a whole buffer at once? with all the variables ordered? Also, what procedure should I call to do that?[/QUOTE] You don't [i]have[/i] to, but if you didn't want to, why are you using structs in the first place? Uniform Buffers are like any other kind of buffer, you create it with glCreateBuffer, bind with glBindBuffer, and load the data with glBufferData. You specify the binding within the program with glUniformBlockBinding() and when you're ready to use it, you call glBindBufferBase().
[QUOTE=ROBO_DONUT;33600005]You don't [i]have[/i] to, but if you didn't want to, why are you using structs in the first place?[/QUOTE] For the sake of code cleanliness. Stuff looks nasty as you start having lots of arrays for everything, and lights do tend to use quite a few variables. [editline]6th December 2011[/editline] I believe this thread can be closed already. For future references, here are the answer for anyone with the same doubts: [url]http://www.opengl.org/wiki/GLSL_Uniform#Uniform_management[/url]
Sorry, you need to Log In to post a reply to this thread.