Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Vertex Attrib Array with OGLSL2

  1. #1
    Junior Member Regular Contributor execom_rt's Avatar
    Join Date
    Jul 2000
    Location
    Canada
    Posts
    237

    Vertex Attrib Array with OGLSL2

    Does anyone knows how Vertex Attrib Array works ?
    Usually with ARB_vertex_program, I use to write

    glEnableVertexAttribArrayARB(6);
    glVertexAttribPointerARB(6, 3, GL_FLOAT, GL_FALSE, 0, m_pT);

    and access it from the shader code by writing

    ATTRIB BiNormal = vertex.attrib[6];

    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 ?

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2002
    Location
    Austria
    Posts
    328

    Re: Vertex Attrib Array with OGLSL2

    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:

    glEnableVertexAttribArrayARB(position);
    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).]
    There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

    There is another theory which states that this has already happened...

  3. #3
    Junior Member Regular Contributor execom_rt's Avatar
    Join Date
    Jul 2000
    Location
    Canada
    Posts
    237

    Re: Vertex Attrib Array with OGLSL2

    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[0])));

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

  4. #4
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: Vertex Attrib Array with OGLSL2

    Uniform sampler initialization:
    loc = glGetUniformLocationARB(obj, "tex0");
    if (loc != -1)
    {
    glUniform1iARB(loc, yourTextureUnitID);
    }

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •