Advertisement Jump to content
Sign in to follow this  
oggs91

OpenGL Question: VertexAttributes

This topic is 2635 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!