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

Thread: setting color/material of textured object

  1. #1
    Intern Contributor
    Join Date
    Sep 2002
    Posts
    65

    setting color/material of textured object

    I need to paste a texture onto a sphere. I then want to give the sphere some color and have it with some emmisive and opacity components. I guess I need to use the texture functions?

    Any hints on how to do it?

    Thanks

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,096

    Re: setting color/material of textured object

    Well if you apply a texture say from a file, it texture will give it color.
    But if you can use just a colored sphere and change the material settings to get what you want.

    Here is example of material setting, you will need to have lighting enable also:

    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); // Adjust ambient
    glColor4f(0.5, 0.5, 0.5, 1.0); amount of change to ambient.
    glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
    glColor4f(0.0, 0.0, 0.0, 1.0);
    glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
    glColor4f(0.25, 0.25, 0.25, 1.0);
    glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
    glColor4f(1.0, 1.0, 1.0, 1.0);
    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 80.0);


    Hint the fouth value in the glColor, alpha value, lower the number the more transparent the object.

    Originally posted by mikemor:
    I need to paste a texture onto a sphere. I then want to give the sphere some color and have it with some emmisive and opacity components. I guess I need to use the texture functions?

    Any hints on how to do it?

    Thanks


    [This message has been edited by nexusone (edited 09-29-2002).]

  3. #3
    Intern Contributor
    Join Date
    Sep 2002
    Posts
    65

    Re: setting color/material of textured object

    Thanks! Thats what I needed.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    768

    Re: setting color/material of textured object

    note: if you don't set all the color materials (for instance, if you *only* setup ambient, diffuse and emissive) then you'd better call glEnable(GL_COLOR_MATERIAL) after the first call to glColorMaterial.

Posting Permissions

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