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

Thread: how to make my vas to vars ?

  1. #1
    Junior Member Regular Contributor
    Join Date
    Dec 2002
    Posts
    155

    how to make my vas to vars ?

    at first, another question. will this work ?
    (i'm using gl4java, just ignore the gl.* and glEnum.*)

    Code :
       public void setStates(GLFunc gl)
       {
          gl.glEnableClientState(GLEnum.GL_VERTEX_ARRAY);
          if (hasNormals)
          {
             gl.glEnableClientState(GLEnum.GL_NORMAL_ARRAY);
          }
          if (hasColors)
          {
             gl.glEnableClientState(GLEnum.GL_COLOR_ARRAY);
          }
          if (hasFog)
          {
             gl.glEnableClientState(GLEnum.GL_FOG_COORDINATE_ARRAY_EXT);
          }
          if (hasUnit0TexCoords)
          {
             gl.glActiveTexture(0);
             gl.glEnableClientState(GLEnum.GL_TEXTURE_COORD_ARRAY);
          }
          if (hasUnit1TexCoords)
          {
             gl.glActiveTexture(1);
             gl.glEnableClientState(GLEnum.GL_TEXTURE_COORD_ARRAY);
          }
          if (hasUnit1TexCoords)
          {
             gl.glActiveTexture(2);
             gl.glEnableClientState(GLEnum.GL_TEXTURE_COORD_ARRAY);
          }
          if (hasUnit1TexCoords)
          {
             gl.glActiveTexture(3);
             gl.glEnableClientState(GLEnum.GL_TEXTURE_COORD_ARRAY);
          }
       }
    or do i have to use glActiveTextureARB ? whats the difference ?

    ---
    next question : i already have working vertex arrays. how can i make them faster by using vars ?
    can i still manipulate single elements inside this array ?
    -----
    final question :
    when i'm done, i want to use an interleaved array, storing all data that is needed, making use of indexed access, AND use all this as a var.
    is it possible, and if yes, how ?
    go vegan

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,052

    Re: how to make my vas to vars ?

    Donīt use VAR, itīs outdated.

    Use VBO (Vertex Buffer Objects) instead. Itīs much easier to implement, itīs an ARB extension and itīs the way drivers like the data most (because the drivers optimize it most, VAR will certainly get dropped in the near future.

    Here is some information on VBO: http://developer.nvidia.com/object/using_VBOs.html

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  3. #3
    Junior Member Regular Contributor
    Join Date
    Dec 2002
    Posts
    155

    Re: how to make my vas to vars ?

    i thought var and vbo is the same...

    well, ok....


    [This message has been edited by HamsterofDeath (edited 12-31-2003).]
    go vegan

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,652

    Re: how to make my vas to vars ?

    Three issues with your coude:
    1)Earlier calls to setstate() may have left some arrays enabled, so you must make sure to disable them if they're not needed.
    Code :
    public void setStates(GLFunc gl)
    {
      gl.glEnableClientState(GLEnum.GL_VERTEX_ARRAY);
      if (hasNormals)
      {
        gl.glEnableClientState(GLEnum.GL_NORMAL_ARRAY);
      }
    [B]  else
      {
        gl.glDisableClientState(GLEnum.GL_NORMAL_ARRAY);
      }[/B]
    .
    .
    .
    2)For setting array pointers and enables, you need to use glClientActiveTexture. glActiveTexture (w/o Client) routes texture bindings and texture environment state, not vertex array state.
    Code :
    if (hasUnit0TexCoords)
    {
      gl.gl[B]Client[/B]ActiveTexture(0);
      gl.glEnableClientState(GLEnum.GL_TEXTURE_COORD_ARRAY);
    }
    This will most likely require changes to other places in your code, wherever you set your texture coord pointers.

    3)"if (hasUnit1TexCoords)" occurs three times. C&P related typos, I guess

  5. #5
    Junior Member Regular Contributor
    Join Date
    Dec 2002
    Posts
    155

    Re: how to make my vas to vars ?

    1) i know. i have a disableStates()-function that is called after drawing
    2) thx
    3) c&p = evil, but : no, this is the only place where i set texture pointers so far
    -----
    2 questions remain :
    1. is there a small example creating a vbo, and manipulating vertex data inside the array ? is the usage of vbos equal when using ati/nvidia-cards ?
    2. i've build an interleaved array out of my vertex/normal/color etc.-arrays

    when telling opengl what the gaps between the elements are, i have to use
    Code :
    void glVertexPointer(
        GLint	 size,
        GLenum	 type,
        GLsizei	 stride,
        const GLvoid *pointer)
    in my case, gl.glVertexPointer(3,GL_FLOAT,?,myarray);

    3 is for 3 floats, x,y & z coordinate
    float means, the data is stored in floats
    ? is what i don't know.
    is it the number of array indices i'll have to add until i get from my old z to the next x ? or is it the number of floats between the old z and the new x ?
    if i store x,y,z,texx,texy,x2,y2,z2,texx2,texy2, is the stride value 2 or 3 ?
    go vegan

  6. #6
    Guest

    Re: how to make my vas to vars ?

    The only drawback of VBO : you need quite newer drivers (from about august 2003).

    VBO is completely independant of the hardware from the programmer point of view, so use them to get the most of the drivers' optimizations.

Posting Permissions

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