Skip to main content
GameDev.net gamedev.net
🔒 Locked

Texture changes colors

Started by kefa Apr 23, 2003 at 8:31 AM 4 replies 300+ views
Original Post
kefa
kefa
Hi! I am new to OpenGL. I made a simple demo. 2 cubes rotating in space. First cube si bigger and textured. Second cube is half so big, without texture just colored(blue) and is inside the bigger one. They have the same center and rotate simultaneously(same speed and angle). I have blending turned on. The problem is that the bigger cube has a texture on it, but the texture is in blue shades(the color of the smaller one). when I don''t render the inner cube, everything is fine. I tried to turn off depth buffer or blending, drawing first the smaller one, the bigger one, but it''s always so. Thanx for any respond.
blizzard999
blizzard999
Try this

	
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);


or

	
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

SetColor4f(1.0f, 1.0f, 1.0f, 1.0f);

// Draw Cube




I think that you use the default GL_MODULATE that is very useful and nice but not what you want...
kefa
kefa
Thanx for help. I will try it. But I have discovered where were the troubles. I have to call glcolor4f(1.0,1.0,1.0,1.0) before drawing the bigger cube. Than it works. I don''t know why, but it''s just so.
blizzard999
blizzard999
It works because you are in MODULATE mode so if the texel is

texel = tR, tG, tB, tA it is modulated by your color
color = cR, cG, cB, cA

where RGBA are the components

the pixel you write to the screen is given by (there are different models...)

pixel = tR*cR, tG*cG, tB*cB, tA*cA

if cR = cG = cB = cA = 1

you have pixel = texel.

The same result it''s possible with GL_REPLACE (no modulation)

mhays
mhays
OpenGL is still blending with the blue color from before. You never got it out of the "blue state"

M
--------------------------------------------------"I have never let my schooling interfere with my education. " --- M.TwainMarcus Hayswww.phrenicgames.com
mhays
mhays
OpenGL is still blending with the blue color from before. You never got it out of the "blue state"

M
--------------------------------------------------"I have never let my schooling interfere with my education. " --- M.TwainMarcus Hayswww.phrenicgames.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.