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: Size of glMaterialfv and glLightfv array

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Location
    Italy
    Posts
    12

    Size of glMaterialfv and glLightfv array

    I am using glMaterialfv and glLightfv to set the material and lights properties of an object.
    I have a doubt about the size of the array that have to be passed as argument, the documentation I'm reading doesn't say anything about that.
    For example:

    Code :
    glMaterialfv(GL_FRONT, GL_SHININESS, (const GLfloat[]) {1,0,0,0} );

    But what if I pass an array of 3 glFloat's? Can this be done? And how do I change the format to choose if I want to pass a RGBA array or RGB?

  2. #2
    Intern Newbie
    Join Date
    Nov 2012
    Posts
    33
    I hope your example is just that, and not any code you're actually using.

    glMaterialfv takes different arrays depending on the parameter name: in particular, GL_SHININESS takes an array of length 1, with the single value between 0 and 128.

    The rest (GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_EMISSION, GL_AMBIENT_AND_DIFFUSE) take arrays of length 4 (RGBA). The fourth element of the array is the alpha value.

    Depending on your binding there may be differences, but as far as I know, the C language binding only takes arrays of length 4. If you need just RGB, keep in mind that an RGBA array with alpha of 1.0f is the same thing.

    EDIT: I forgot to mention the parameter name GL_COLOR_INDEXES, which takes an array of length 3. However, this array does not represent an RGB color, but rather ambient, diffuse, and specular indexes for the OpenGL lighting model.
    Last edited by Aestivae; 12-03-2012 at 01:45 PM. Reason: Omission

Posting Permissions

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