Results 1 to 6 of 6

Thread: Loop color data?

  1. #1

    Loop color data?

    So I have 10,000 lines and I'm trying to reduce the amount of color data I have on my card.

    So right now I have 20,000 vertexs for the 10,000 lines, * 4, so 80,000 color floats. Is this really necessary? I use the same colors on all 10,000 lines. If it was a single color, I would just use a glColor4f(), but it's two colors - one for each vertex. Can I do this with 8 floats? I have this all in a VBO. Is there any way I can tell the color pointer to use the same two vertex colors on all 10,000 lines? Or can I put this in my shader and have it toggle a bool or something between the two colors? Seems like a big waste of video card memory.

    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, highlines_vbo[0]);
    gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0);
    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, highlines_vbo[1]);
    gl.glColorPointer(4, GL.GL_FLOAT, 0, 0);
    gl.glDrawArrays(GL.GL_LINES, 0, highlines);

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2011

    Re: Loop color data?

    Well, it seems that an easy solution is to use different indices for different attributes. But it is not possible with OpenGL.

    What kind of hardware you are running on?
    10k color attributes is a piece of cake for most graphics hardware today.

  3. #3

    Re: Loop color data?

    10k could be much higher.. depends on the data. Could be 1,000,000. Wasn't aware of a way with the color pointer, but thought perhaps there was some trick or that a varying could be toggled by the vertex shader, so each vertex would flip between 1 & 0. In doing so, I could use a simple if statement to assign the color in the shader. But I'm not that familiar on what is writable in the shader that could be passed to the next vertex. I know a varying can pass to the fragment shader, but wasn't sure about it being passed to the next vertex.

  4. #4

    Re: Loop color data?

    You can create a 1D texture.
    Provide 1D texcoord for each vertex and there you go. You save 3 floats per vertex.

  5. #5

    Re: Loop color data?

    Thanks - That would surely save on memory.

  6. #6
    Newbie OpenGL Pro
    Join Date
    Jan 2007

    Re: Loop color data?

    You could also use unsigned bytes for the colours instead of floats; that would reduce the overhead to one quarter of what it was. An equal saving to V-man's proposal.

Similar Threads

  1. Replies: 1
    Last Post: 05-31-2012, 01:57 AM
  2. Copy Color data
    By Addoula in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 08-11-2009, 06:18 AM
  3. Pulling color data from texture coordinates
    By Pepretual in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 08-08-2008, 03:57 AM
  4. glColorPointer with monochrome color data.
    By JCipriani2 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-03-2008, 02:45 PM
  5. extract color data from texture
    By mstepp in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-30-2001, 08:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean