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

Thread: Modifying texture color

  1. #1
    Junior Member Newbie Perlice's Avatar
    Join Date
    Jan 2013
    Location
    Verona, Italy
    Posts
    10

    Modifying texture color

    Hi!
    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:
    Click image for larger version. 

Name:	screenshot.jpg 
Views:	96 
Size:	7.2 KB 
ID:	963

    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!
    Click image for larger version. 

Name:	screenshot_red.jpg 
Views:	98 
Size:	5.8 KB 
ID:	964

    Here is the sun code:
    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 */
    	glPushAttrib(GL_ALL_ATTRIB_BITS);
    	glEnable(GL_TEXTURE_2D); /* enable 2D texture mapping */
     
    	glPushMatrix();
    		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);
    	glPopMatrix();
     
    	glDisable(GL_TEXTURE_2D); /* disable 2D texture mapping */
     
    	glPopAttrib();
    }

    Thanks

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    Hello,


    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.

  3. #3
    Junior Member Newbie Perlice's Avatar
    Join Date
    Jan 2013
    Location
    Verona, Italy
    Posts
    10
    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

  4. #4
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    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...

  5. #5
    Junior Member Newbie Perlice's Avatar
    Join Date
    Jan 2013
    Location
    Verona, Italy
    Posts
    10
    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

Tags for this Thread

Posting Permissions

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