Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
So, I have returned. Hello once again. I saw a nice and dandy tutorial for loading attributes with shaders on learnopengles.com. But that uses a separate buffer. I was wondering if anyone could point me to an example or a tutorial (even better, an explanation!) on how to use vertex attributes in a packed buffer (e.g. X Y X NX NY NZ .)
package com.braindrool.game; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.fixedfunc.GLPointerFunc; public class Renderer implements GLEventListener { GL2 gl; Model model; Program program; int shaderProgram; Resourcer resourcer; int MVPMatrix; int LightPos; int Color; int Position; int Normal; float rotation; public void display(GLAutoDrawable drawable) { rotation += 0.01; int[] data = model.load(gl, "passion_flower.ply"); gl.glClearColor(0, 0.6f, 0, 1); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, data[0]); gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0); gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, data[1]); gl.glDrawElements(GL.GL_TRIANGLES, data[2], GL.GL_UNSIGNED_SHORT, 0); gl.glRotated(Math.sin(rotation) * 5, Math.cos(rotation) * 5, 0, 1);// Temp gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY); } public void dispose(GLAutoDrawable arg0) { } public void init(GLAutoDrawable drawable) { gl = drawable.getGL().getGL2(); model = new Model(); resourcer = new Resourcer(); program = new Program(gl); shaderProgram = program.program("ambient"); gl.glUseProgram(shaderProgram); MVPMatrix = gl.glGetUniformLocation(shaderProgram, "MVPMatrix"); LightPos = gl.glGetUniformLocation(shaderProgram, "LightPos"); Color = gl.glGetUniformLocation(shaderProgram, "Color"); Position = gl.glGetAttribLocation(shaderProgram, "Positon"); Normal = gl.glGetAttribLocation(shaderProgram, "Position"); gl.glUniform4f(Color, 0.5f, 0.5f, 0.5f, 0.5f); gl.glUniform3f(LightPos, 1f, 1f, 1f); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } } The uniform / attribute locations are done, but how to actually implement them I could use help with! Help appreciated ~ Braindrool |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Politely bumped.
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by Braindrool
Hi
I gave you a link to 2 classes used in my main project, just look at one of them that uses glInterleavedArrays.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Thanks! But silly question if I may ask, what link?
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
http://forum.jogamp.org/Requesting-help-with-VBO-s-tp4027348p4027349.html
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Heh, thanks.
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Thank you very much for the example, but one final question. How do you define the interleave format? I have an array containing the order of my properties. e.g. X Y Z R G B A NX NY NZ and so on from the file it reads.
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
As you can see in the source code, I use GL_T2F_V3F, it means 2 texture coordinates followed by 3 vertex coordinates. In your case, it would rather be GL_V3F_C4F_N3F but it doesn't exist, rather use GL2.GL_C4F_N3F_V3F and put the data into your direct NIO buffer in this order: R G B A NX NY NZ X Y Z. Another solution consists in using glVertexPointer, glColorPointer and glNormalPointer but with different values for the "stride" parameter, it would allow you to do exactly what you want, it is more flexible than glInterleavedArrays.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
You have my thanks and I greatly appreciate your efforts
![]() |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
Demoscene Passivist or Sven can answer this question better than me, I rarely use shaders. I remember you have to use glEnableVertexAttribArray, glVertexAttribPointer and glDisableVertexAttribArray.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Care enough to send a memo?
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
What do you mean by "memo"? Sorry, English is not my mother tongue and sometimes I don't understand what people mean despite my efforts.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I meant that could you send them a notice about this post? Or should I just private message them?
And if you don't mind me asking, what is your native tongue? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
I advise you to look at "Vertex Specification" on the official OpenGL website, there is a subsection about VAO. My mother tongue in French. Good night.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by Braindrool
On 12/14/2012 11:25 PM, Braindrool [via jogamp] wrote:
> I meant that could you send them a notice about this post? Or should I just > private message them? > I do read the posts here, of course. However, sometimes I prefer not to reply in case the request is not related to jogamp or our 'job description'. In your case, you requested our help in for basic OpenGL operations. You were already directed to use the many available OpenGL tutorials. Mind that such questions are not related to JOGL in particular and can be answered tool agnostic. Well, if others like to help you here .. that's fine, but myself currently has no time - so I am polite and explain my silence herewith. Sorry .. please use the many earch engines around .. you will find test code. ~Sven |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Fair enough.
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
The class JoglRenderer in JMonkeyEngine 3 uses VAOs. It creates one of them with glGenVertexArrays and it binds it with glBindVertexArray but this example is too much complicated for a newbie. Look at this:
http://www.opengl.org/wiki/Vertex_Array_Objects#Vertex_Array_Object Let me know whether something is not clear.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Happy to say that I've found an example of the exact issue I'm having, thank you for your patience
![]() |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
You're welcome. I have found that example using JOGL 2.0 on JavaGaming.org:
http://www.java-gaming.org/topics/vertex-arrays-and-interleaved-bytebuffers/28109/view.html
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |