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

Thread: glColorPointer question

  1. #1
    Guest

    glColorPointer question

    Hello, i want to use the function glColorPointer, but i dont know how to specify what color to use.
    I've got this so far
    glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &colorRed );

    The problem is, is that &colorRed is still an unidentified object. Cause i dont know how to make it point to a color.
    Any idea how to do this?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,749

    Re: glColorPointer question

    Take a good opengl programming book or at least see good tutorials about gl, check nehe on a search engine for example.

  3. #3
    Junior Member Regular Contributor songho's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    247

    Re: glColorPointer question

    <Fluxx>,
    The array of color components can specify the color of each vertex in vertex array. For example, if you have 3 vertices in your vertex array to create a triangle, you will have vertex coords array with 3 of (xyz) elements and color array with 3 of (r,g,b,a) elements. (same number of elements in vertex array)

    Code :
    GLfloat vertices[] = { v1x, v1y, v1z,
                           v2x, v2y, v2z,
                           v3x, v3y, v3z };
    GLubyte colors[] = { v1r, v1g, v1b, v1a,
                         v2r, v2g, v2b, v2a,
                         v3r, v3g, v3b, v3a };
    If you want to set all vertices to red;
    Code :
    GLubyte colors[] = { 255, 0, 0, 255,
                         255, 0, 0, 255,
                         255, 0, 0, 255 };
    In redering time, you can call glColorPointer() like this;
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
    ==song==

Posting Permissions

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