Jump to content

  • Log In with Google      Sign In   
  • Create Account

oggs91

Member Since 01 Sep 2010
Offline Last Active Yesterday, 06:33 AM

Topics I've Started

glVertexAttribBinding()

20 September 2012 - 05:43 AM

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]

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)
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

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 ?!



/*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)

Gameprogramming in general, what language engine and framework do you prefer

06 September 2011 - 01:51 AM

Gameprogramming in general, what language engine and framework do you prefer?

Right now i'm digging trough all 3d frameworks, engines and preferred languages to use them.
Beginning with Ogre3D / C++, really liked it, but for the sake of simplicity i tried to avoid c++ in future,
after ogre3d i got used to jmonkeyengine / java, It's a really good engine, but when i discovered c# i saw it as a java with some great new features,
so i decided to try XNA, but only directx9 bääh :S i switched to opentk / c# and i'm still learning it...

so tell me what's you favorites :) ?

if you choose "Other" in poll please post what you are preferring =)

PARTNERS