#### Archived

This topic is now archived and is closed to further replies.

# Using Color and Textures At The Same Time

This topic is 5884 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi there! This has prob been asked a million times but.... the search is out soooo..... I just wanna know how I can use textures and color at the same time like...


glColor3f(0.5f,0.5f,0.5f)

glBegin(GL_TRIANGLE_STRIP);

glTexCoord2d(1,0);

glVertex3fv(br.xyz);
glTexCoord2d(0,0);

glVertex3fv(bl.xyz);
glTexCoord2d(1,1);

glVertex3fv(tr.xyz);
glTexCoord2d(0,1);

glVertex3fv(tl.xyz);

glEnd();


This is the code I use and the textures work but the color is alway white!

##### Share on other sites
did you remember to glEnable(GL_TEXTURE_2D)?

-eldee
;another space monkey;
[ Forced Evolution Studios ]

##### Share on other sites
yes the textures work the color doesn''t

##### Share on other sites
I came across this problem, too, and I think the solution had to do with materials. If you are using LIGHTs, I think you have to define MATERIALs that reflect the correct colors.

Try abandonning glColor all together and instead define meterials that reflect the colors you want, ie, if you want a red cube, define a material that reflects red light and enable it instead of calling glColor. You should then be able to bind a texture to the cube, and still have the red light get reflected back.

Remember, there are 3 types of light, and each are reflected with different aspects of the MATERIAL.

I''m not sure, but I think that will solve the problem...

##### Share on other sites
Yes, I hadn''t thought about materials, that would work huh? But I know there is a way to use colors and textures at the same time and I would really prefer to use them since I don''t wanna calc normals for all the particles, well I guess they are billboards so only one calc per frame.. but still I wanna use colors and I know that it can be done. DOES ANYONE KNOW????

##### Share on other sites
In nehe''s tutorial 19 he uses color and texture.. I can''t get it to work! There has to be a way doens''t anyone know? Please!?

##### Share on other sites
Try this -> glEnable(GL_COLOR_MATERIAL).
Without this gl doesn''t use colors if lighting is enabled.

##### Share on other sites
I just disabled lighting and that was all I needed to do! I''m gonna use materials are some point though as they are more flexable! Thanks for the advice everyone!

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 13
• 92
• 11
• ### Forum Statistics

• Total Topics
632973
• Total Posts
3009625
• ### Who's Online (See full list)

There are no registered users currently online

×