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 2 of 2

Thread: Speed of glProgramEnvParameter4fvARB

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2003
    Posts
    8

    Speed of glProgramEnvParameter4fvARB

    Hi,

    I've recently been replacing all my per-vertex setup code with vertex programs using ARB_vp. For each polygon I have a matrix to transform from world space to texture space for bump mapping, and so before rendering each polygon with glDrawElements, I do the following:
    Code :
    // Put poly's onb into vertex program constant memory
    glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 4, &poly->onb().tangent().x());
    glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 5, &poly->onb().binormal().x());
    glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 6, &poly->onb().normal().x());
    But I'm not sure about the speed of updating the vertex program constant memory, especially for every polygon. Is it fast? Is there a better way to update it? Can I set all three at once?

    And on a slightly different topic ... is it worth replacing the cpu per-vertex setup with a vertex program on cards like the GeForce 1? Because it would have to emulate the vp in software anyway ... and then couldn't use the hardware accelerated texture matrix and transform unit.

    Thanks in advance,
    Richard

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Jan 2001
    Location
    NVIDIA, Austin, TX
    Posts
    591

    Re: Speed of glProgramEnvParameter4fvARB

    The fastest way would be to have an array of tangents, an array of binormals, an array of normals, and an array of vertices. Then use standard OpenGL vertex arrays.

    something like this:

    glVertexAttribPointerARB(0, ..., vertices);
    glVertexAttribPointerARB(1, ..., tangent);
    glVertexAttribPointerARB(2, ..., binormal);
    glVertexAttribPointerARB(3, ..., normal);

    glEnableVertexAttribArrayARB(0);
    glEnableVertexAttribArrayARB(1);
    glEnableVertexAttribArrayARB(2);
    glEnableVertexAttribArrayARB(3);

    glDrawElements(...);

    glDisableVertexAttribArrayARB(0);
    glDisableVertexAttribArrayARB(1);
    glDisableVertexAttribArrayARB(2);
    glDisableVertexAttribArrayARB(3);


    [This message has been edited by jra101 (edited 02-10-2003).]

Posting Permissions

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