Jump to content

  • Log In with Google      Sign In   
  • Create Account


Question: VertexAttributes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 oggs91   Members   -  Reputation: 233

Like
0Likes
Like

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

Sponsor:

#2 FXACE   Members   -  Reputation: 182

Like
0Likes
Like

Posted 03 November 2011 - 09:16 AM

You need to check the reference of glBindAttribLocation (I think rules of using this function (GL specific "glBindAttribLocation" and GL ES specific "GL.BindAttribLocation" are the same).

Also you can use GL.GetAttribLocation (rules are the same too).




Best wishes, FXACE.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS