View Full Version : Vertex Attrib Array with OGLSL2
01-13-2004, 01:43 AM
Does anyone knows how Vertex Attrib Array works ?
Usually with ARB_vertex_program, I use to write
glVertexAttribPointerARB(6, 3, GL_FLOAT, GL_FALSE, 0, m_pT);
and access it from the shader code by writing
ATTRIB BiNormal = vertex.attrib;
But under OpenGL Shader Language (GL_ARB_shader_objects/GL_ARB_vertex_shader/GL_ARB_shading_language_100)
There is no equivalent (Just the 'attribute vec3')
Is someone tried to use Vertex Array Attrib in a OpenGL 2.0 code ?
01-13-2004, 03:25 AM
That's a bit different in GLslang. In GLslang you define your attribute like vec3:
attribute vec3 my_attrib;
Then you're able to get the vertex position using glGetAttribLocationARB like:
int position = glGetAttribLocationARB("my_attrib");
And than using you vertex arrays:
glVertexAttribPointerARB(position, 3, GL_FLOAT, GL_FALSE, 0, m_pT);
But you can also use glBindAttribLocationARB.
[This message has been edited by Corrail (edited 01-13-2004).]
01-15-2004, 12:53 AM
Ok it's appears to works (i've chose the 2nd solution) with the glBindAttribLocationARB.
Last question, I'm still finishing to convert my 'bump' code into OpenGL 2.0.
How works exactly, in the fragment shader code, the 'texture2D' function.
I want to write
uniform sampler2D tex0;
vec4 t0 = vec4(texture2D(tex0, vec2 (gl_TexCoord)));
But how to initialise the handle 'tex0' ?
Must be done by the code ?
or can I write tex0 = 0 ?
The texture2D and the sample2D documentation is a bit fuzzy about that
At least, I have my object rendering, with the normal colors, but no texture.
Also last thing, calling
glUniform4fARB each frame for updating an uniform vec4 constant seems make glError() returning an 'illegal operation'. Is the correct way to do that. (i've also noticed that calling glUseProgramObjectARB is required prior using glUniformARB).
01-15-2004, 02:01 AM
Uniform sampler initialization:
loc = glGetUniformLocationARB(obj, "tex0");
if (loc != -1)
The vec4 cast around the texture2D is not necessary.
glUniform4fARB() initializes float arrays of length 4, for bigger arrays use glUniform1fvARB().
You must use glUniform4fvARB() to set vec4 uniforms.
Yes, you must have called glUseProgramObjectARB(obj) or you don't have a current program which defines the uniform locations.
[This message has been edited by Relic (edited 01-15-2004).]
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.