View Full Version : Modifying texture color

01-30-2013, 01:51 AM
I searched a lot around the Internet but I can't figure out how to change the color of a texture.
I'm drawing a sun using the texture file (.sgi) my professor gave me, if I set the emission color of the sphere to white this is the color I obtain:

So far the only thing I managed to do is to set the emission color to red so the sun now is dark red, but is there something else I can do to make the Sun more yellow? The green component keeps coming out!

Here is the sun code:

static GLfloat sunRed[]= {1.0, 0.0, 0.0, 1.0};
static GLfloat white[] = {1.0,1.0,1.0,1.0};
GLUquadric* a = gluNewQuadric();

/* save attributes */
glEnable(GL_TEXTURE_2D); /* enable 2D texture mapping */

glTranslatef(500, 50, 0);

glMaterialfv(GL_FRONT, GL_EMISSION, sunRed);
glBindTexture(GL_TEXTURE_2D, g_textureArray[0]);

gluQuadricTexture(a, GL_TRUE);

gluSphere(a, 100, 24, 24);

glDisable(GL_TEXTURE_2D); /* disable 2D texture mapping */



01-30-2013, 02:16 AM

may I ask why you don't just use a yellow texture for the sun? Also, are you limited to the fixed-function pipeline? IMHO the modern shader based pipeline can be more obvious in understanding how the shading works (as you code it yourself) and learning the fixed-function pipeline is a waste of time unless there are good reasons to be limited to a decade old hardware.

01-30-2013, 02:37 AM
Thanks for your reply :)
I'm at university and I'm following the course tutorial (I couldn't go to the lessons because of coinciding working times), but I'd like to learn more about this subject so.. what do you mean with "fixed-function pipeline" or "shader based pipeline", is there a guide to understand better the differences between the two pipelines?
I'm implementing a little project to pass the exam and I thought that there could be a reason if they gave me a green sun, that's why I obstinately kept the original texture, but maybe it's better if I look around the internet for a yellow texture :)

01-30-2013, 11:45 AM
With shaders you can implement some parts of the rendering pipeline yourself and be much more flexible. It might also be more clear what's going on. OpenGL introduced shaders in 2004 and you can't buy any GPU without shader support anymore (even you mobile phone might support them). I guess you are talking about a computer graphics course? I'm not sure it's a good sign they still teach the fixed function pipeline...

01-30-2013, 12:16 PM
Yes, it's a computer graphics course, I can't tell you exactly what they teach because I didn't follow the lessons so maybe they added something that i missed to the tutorial slides (the tutorial is the same of three years ago, it seems that they don't update it very often).. Now sadly I don't have enough time to "update" my little knowledge of OpenGL, but when I'll finish with the university (this is one of the last exams, yuppi!) I'm going to buy a decent opengl book and start all over again because I liked it very much!
For me it's pure magic to write code and make something appear in a window :)

Thank you very much for your answer and have a good evening :)