Archived

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

kenwi

Color + Texture = Weird (!!?)

Recommended Posts

kenwi    122
I''m experimenting a little with texturing and stuff.. And yesterday I made a room with some texture on all the walls.. And I made a little box in the middle of the room spinning around.. I didn''t want to texture it, so I figured out I just put the wonderfull glColor3f making it green... Yeah, in my dreams.. When I ran the program the box was green alright, but so was the entire room!(?).. It still had the proper texture, but it had this green layer on it.. Really weird I thought, I plundered some with the code, but the same result ever goddamn time i compiled. So, for you hardcore programmers; =) Can''t I do texturing and making colors on some other things at the same time? If I can, how? Yeah It can be a neat effect sometime having the green layer over it all, but that''s not what I want to do at this time. I tried to have some 2d text as well, and color it too.. but the entire room turned out green.. I wanted to have the text green, so it''s distinct from the rest of the world... Not I have to have it untextured, and it''s black or a very dark grey/brown color, so I can barely see the text. Please do some explaining for me Thanks in advance! Kenneth Wilhelmsen Download my little game project HERE -------------------------- He who joyfully marches to music in rank and file has already earned my contempt. He has been given a large brain by mistake, since for him the spinal cord would fully suffice. This disgrace to civilization should be done away with at once. Heroism at command, senseless brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder

Share this post


Link to post
Share on other sites
Wavarian    850
Actually, everytime you make a call to the glColor*f() function, you change an opengl state that sets all objects to that defined colour. What you need to do, is reset this colour state after.

ie.

glColor3f(0,0,1) //green
DrawGreenObject;

glColor3f(1,1,1) //reset colour to pure white
DrawAllOtherObjects;

Share this post


Link to post
Share on other sites
Waldoo    122
Ya I got same problem that is why I came here. But I got new problem after I corrected my script as wAVaRiaN suggested to fix the glcolor3f. When I switched my textured object into transparent the white color remain and only black color on texture map transparented. It is more like color keying. Is there a way to limit glColor3f on a single 3D object without affecting to anything else?

Waldoo

Share this post


Link to post
Share on other sites
_DarkWIng_    602
you have to realize OpenGL is a state machine. Color is just a ste in it. Once you set it to some color, that same color will be used until you specify another one. So after drawing your object with green change it to white and everything should be OK

Waldoo : if you use alpha blending you should use :
glColor4f( red, green, blue, ALPHA );

There are more worlds than the one that you hold in your hand...

Share this post


Link to post
Share on other sites
davidsporn    126
Hi !

I got the same problem when I first use the Nehe BaseCode v2.

The rule to be sure to have exactly what you want is :
Specify your settings (including Texture, then color if appliable, blending, lighting,..., whatever your think you should force to get the proper result)


//Draw the room
//1. Ensure you have the right texture
glBindTexture(my_room_texture);
//my_room_texture is a texture from a picture, so no color to set
DrawMyRoom();

//Draw the cube
//1. Ensure you have the right texture
glBindTexture(0);
//2. Texture 0 is a solid colored texture, so
//you should specify the color
glColor3f(0,0,1); //green
DrawMyCube();


----
David Sporn AKA Sporniket

Share this post


Link to post
Share on other sites
_DarkWIng_    602
if you want solid color cube you dont need solit texture.. just disable texturing and use colors only. glDisable( GL_TEXTURE_2D );

There are more worlds than the one that you hold in your hand...

Share this post


Link to post
Share on other sites
kenwi    122
This is a old post from me? Why are people giving it life again, stop posting! =)

Kenneth Wilhelmsen
Try my little 3D Engine project, and mail me the FPS. WEngine
Or just visit my site
--------------------------
He who joyfully marches to music in rank and file has already earned my contempt. He has
been given a large brain by mistake, since for him the spinal cord would fully suffice. This
disgrace to civilization should be done away with at once. Heroism at command, senseless
brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder

Share this post


Link to post
Share on other sites