PDA

View Full Version : Sphere Texturing



zak
10-06-2011, 17:38
Hi Petr, All
i refer to your example Tga_Masking in the TBGL_BonusPack_1_6_0_10 (http://www.thinbasic.com/index.php?option=com_jdownloads&Itemid=95&task=viewcategory&catid=5)can be found in this path: TBGL_BonusPack_1_6_0_10\SpecialEffects\Tga_Masking
it is a great example and can be utilized to encode secret messages such as yours hand written "alpha" word. i have tried it with another tga picture archaic.tga to give the impression of old memories in another universe, i found the picture on my hard disk with another name.
just before a minute i was about to ask you a question and now i found the solution, but i have decided to continue my post.
the question was that i want to put a sphere in the middle of this archaic device, but when i want to use the tbgl_color 0,255,255 before it all the archaic device colored with cyan color like the ball. but now i found that putting tbgl_color 255,255,255 ie color white at the beginning of the loop will cancel the cyan color effect.
i begins to read about alpha channel and its usage.
attached Petr example (the outside sphere only) with the archaic picture. or you can download the example from the TBGL_BonusPack_1_6_0_10 (http://www.thinbasic.com/index.php?option=com_jdownloads&Itemid=95&task=viewcategory&catid=5)
7278

Petr Schreiber
10-06-2011, 18:40
Hi Zak,

thanks for interesting modification, it looks good! Interesting thing is that you can encode multiple messages to single image via Alpha channel, and then control how much of them will be visible by carefully increasing/decreasing parameter for TBGL_AlphaFunc.

The root of your problem was the fact, that TBGL (and OpenGL) works like state machine - that means if you define color, it is not used just for next geometric primitive, but to all what follows until you change it to something else.

I see this OpenGL feature can be source of trouble in many situations, that is why I introduced TBGL-specific functions such as TBGL_PushStateProtect/TBGL_PopStateProtect and TBGL_PushState/TBGL_PopState. I will investigate if I can bring something similar related to color.


Petr