http://www.opengl.or...n#Vertex_format
my question: why? what's the benefit of Example 2 ?
what's the difference of binding a buffer vs binding a buffer to a binding point ?
and is the vertex buffer binding from glBindVertexBuffer a VAO state ?
to render multiple vbo's with the same vertex layout i could use
glVertexAttribFormat(...)
glVertexAttribBinding(..., 0);
glVertexAttribFormat(...)
glVertexAttribBinding(..., 0);
glBindVertexBuffer(0,...) / draw / glBindVertexBuffer(0,...) / draw ... right ?
can i do the same with VertexAttributePointer ?
glVertexAttribPointer(...) glBindBuffer(...) draw() glBindBuffer(...) draw()
Example1
[source lang="java"]glBindBuffer(GL_ARRAY_BUFFER, buff);glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(baseOffset + offsetof(position, Vertex)));glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(baseOffset + offsetof(normal, Vertex)));glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), reinterpret_cast<void*>(baseOffset + offsetof(color, Vertex)));[/source]
Example2
[source lang="java"]glBindVertexBuffer(0, buff, baseOffset, sizeof(sizeof(Vertex)));glVertexAttribFormat(0, 3, GL_FLOAT, GL_FALSE, offsetof(position, Vertex));glVertexAttribBinding(0, 0);glVertexAttribFormat(1, 3, GL_FLOAT, GL_FALSE, offsetof(normal, Vertex));glVertexAttribBinding(1, 0);glVertexAttribFormat(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, offsetof(color, Vertex));glVertexAttribBinding(2, 0);[/source]
- Viewing Profile: Topics: oggs91
Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics
Community Stats
- Group Members
- Active Posts 45
- Profile Views 1,213
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
166
Neutral
User Tools
Contacts
oggs91 hasn't added any contacts yet.
Topics I've Started
glVertexAttribBinding()
20 September 2012 - 05:43 AM
VAO and similar in OpenGLES2.0 on android
04 September 2012 - 12:55 AM
hi
first a question to VAO in general, far as i know the vao stores some client states ... all client states?
it stores the currently bound buffers enabledvertexattribpointers right?
Code to generate a VAO (from http://www.swiftless.com/tutorials/opengl4/4-opengl-4-vao.html)
in this example.. isn't there a glEnableVertexAttrib(0); missing ? ..to enable the vertexattribpointer
does anything similar to vao's exist on OpengGlES2.0 (Android) ?
... or what would be a good alternative ?
first a question to VAO in general, far as i know the vao stores some client states ... all client states?
it stores the currently bound buffers enabledvertexattribpointers right?
Code to generate a VAO (from http://www.swiftless.com/tutorials/opengl4/4-opengl-4-vao.html)
glGenVertexArrays(1, &vaoID[0]); // Create our Vertex Array Object glBindVertexArray(vaoID[0]); // Bind our Vertex Array Object so we can use it glGenBuffers(1, vboID); // Generate our Vertex Buffer Object glBindBuffer(GL_ARRAY_BUFFER, vboID[0]); // Bind our Vertex Buffer Object glBufferData(GL_ARRAY_BUFFER, 18 * sizeof(GLfloat), vertices, GL_STATIC_DRAW); // Set the size and data of our VBO and set it to STATIC_DRAW glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0); // Set up our vertex attributes pointer glEnableVertexAttribArray(0); // Disable our Vertex Array Object glBindVertexArray(0); // Disable our Vertex Buffer Object
in this example.. isn't there a glEnableVertexAttrib(0); missing ? ..to enable the vertexattribpointer
does anything similar to vao's exist on OpengGlES2.0 (Android) ?
... or what would be a good alternative ?
k minimum spanning trees
06 June 2012 - 10:40 AM
this is for a small project at university:
we have to implement a java algorithm which produces a k-minimum spanning tree on a given graph (a minimum spanning tree with k nodes)
further we have to solve this with an algorithm based on branch and bound
my problem is to get useful heuristics for upper and lower bounds, to eliminate soon a lot of problems
my current approch works as following:
lower bound:
weight of currently fixed #e edges in graph + one adjacent edge to them + the weights of the k-1-e smallest edges
upper bound:
currently only set if a valid solution was found
we have to implement a java algorithm which produces a k-minimum spanning tree on a given graph (a minimum spanning tree with k nodes)
further we have to solve this with an algorithm based on branch and bound
my problem is to get useful heuristics for upper and lower bounds, to eliminate soon a lot of problems
my current approch works as following:
lower bound:
weight of currently fixed #e edges in graph + one adjacent edge to them + the weights of the k-1-e smallest edges
upper bound:
currently only set if a valid solution was found
Question: VertexAttributes
02 November 2011 - 10:05 AM
i've started to learn opengl, and got stuck on the vertexattribute thingy.
I basically know that i 'connect' my vertex data trough VertexArrayObjects with my Shader
But what happens if my shader has more "in" variables (don't know how to name it) than my VAO ==> the shader doesn't draw anything, no warning, no nothing is there any possibility to check in the shader if a "in" variable has been used or not ?!
for example if i comment these lines in my code out, my proggi draws nothing
can i do something like this in my vertex shader?:
or would it be possible to bind an empty buffer? so i could use the same shader for less attributes
i'm a bit confused about all that stuff x)
I basically know that i 'connect' my vertex data trough VertexArrayObjects with my Shader
But what happens if my shader has more "in" variables (don't know how to name it) than my VAO ==> the shader doesn't draw anything, no warning, no nothing is there any possibility to check in the shader if a "in" variable has been used or not ?!
/*GL.EnableVertexAttribArray(1); GL.BindBuffer(BufferTarget.ArrayBuffer, normalVboHandle); GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0); GL.BindAttribLocation(shader.shaderProgramHandle, 1, "in_normal");*/
for example if i comment these lines in my code out, my proggi draws nothing
can i do something like this in my vertex shader?:
#version 130
precision highp float;
uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;
in vec3 in_position;
in vec3 in_normal;
out vec3 normal;
void main(void)
{
//works only for orthogonal modelview
if(the in_normal was bound to an attribute location)
{
normal = (modelview_matrix * vec4(in_normal, 0)).xyz;
}
else
{
normal = vec3(0,0,0);}
gl_Position = projection_matrix * modelview_matrix * vec4(in_position, 1);}";or would it be possible to bind an empty buffer? so i could use the same shader for less attributes
i'm a bit confused about all that stuff x)
- Home
- » Viewing Profile: Topics: oggs91

Find content