PDA

View Full Version : Is there some kind of color keying?



Michael Hartlef
23-08-2007, 06:32
Hi Petr,

in DirectX you have the colorkey parameter when you draw a sprite. With it you can tell directX not to draw a certain color. IS there something like this in OpenGL/TBGL?
They sprites I have don't have an alpha value and all blending parameters I tried don't work fine with them.

Michael Clease
23-08-2007, 08:50
I found this for SDL

http://utilitybase.com/ref/?keyword=SDL_SetColorKey&funcgroup=SDL&action=Search

SDL could be a powerful addition to TB.

ErosOlmi
23-08-2007, 10:36
José Roca has done a great job in his forum http://www.jose.it-berater.org/ porting many technology into Power Basic. As you know Power Basic wrappers or in general include files are very compatible with thinBasic so it should not be so difficult to port into thinBasic. In particular SDL can be found here: http://www.jose.it-berater.org/smfforum/index.php?board=148.0

Have fun.
Eros

_________________________________________________
The most important features thinBasic does not support when dealing with external libs are: callback functions, pointers dereferencing, MACROs.

Regarding callback functions, there is no way to do it in thinBasic. The only way I can see to wrap them is to build a thinBasic module.
Regarding pointer dereferencing (DIM p AS LONG PTR ... and than ... @p to accedd LONG value) can be simulated using DIM ... AT and than SETAT command. It is not much elegant but can give some help in particular situations.
Regarding MACROs, they can be converted into thinBasic functions.

Michael Hartlef
23-08-2007, 11:54
I want to use TBGL and OpenGL.

ErosOlmi
23-08-2007, 12:08
Abraxas, I'm wrong or the image here http://community.thinbasic.com/index.php?topic=1094.msg7346#msg7346
is a thinBasic script? If yes you seems using sprites with transparent color but maybe not real sprites but using alpha.

Sorry but I do not know anything about sprite programming.

Michael Clease
23-08-2007, 12:32
Mike download the source for sdl and look to see how they do it with OpenGL.

Eros as far sprties are concerned i dont think that pcs have sprites mines just a quad


' ---------------------------------
' ------ Draw Main Character --------
'
sub DrawMyGuy()
TBGL_PUSHMATRIX
TBGL_Translate Play1.X,Play1.Y,Play1.Z

TBGL_ColorAlpha 255, 255, 255, 0
TBGL_UseBlend 1
TBGL_BlendFunc %GL_SRC_ALPHA , %GL_ONE_MINUS_SRC_ALPHA
TBGL_BindTexture 12
TBGL_UseTexture 01 ' Turn on textures

TBGL_BeginPoly %GL_QUADS ' Starts polygon definition based on 4 vertexes
TBGL_Color 255,255,255 ' Sets RGB color
TBGL_TexCoord2d Play1.CurFrame*0.125,0 ' Sets texture coordinate
TBGL_Vertex 0, 0, 0 ' Adds vertex
TBGL_TexCoord2d Play1.CurFrame*0.125+Play1.Facing,0
TBGL_Vertex 48, 0, 0
TBGL_TexCoord2d Play1.CurFrame*0.125+Play1.Facing,1
TBGL_Vertex 48, 48, 0
TBGL_TexCoord2d Play1.CurFrame*0.125,1
TBGL_Vertex 0, 48, 0
TBGL_EndPoly ' Ends polygon definition
TBGL_POPMATRIX
TBGL_UseTexture 0 ' Turn on textures
TBGL_UseBlend 0

END SUB

Ive just read my code and i think its these 3 lines that mikes after.

TBGL_ColorAlpha 255, 255, 255, 0
TBGL_UseBlend 1
TBGL_BlendFunc %GL_SRC_ALPHA , %GL_ONE_MINUS_SRC_ALPHA

Petr Schreiber
23-08-2007, 12:57
Mike,

I will alpha mask the sprites for you if you need it ( TGA ).

Other solution ( which I do not like too much ) is to have sprite + sprite mask ( B&W ). Then you can blend two images over and get the same effect.

Third option - develop new way to load BMPs with optionally specified RGB for transparency ( will set alpha internally ).


What do you think,
Petr

P.S. Again late reply, but good that any reply. I was on bike in the wood and there was hunt for animals, I almost had to do Matrix moves to avoid bullets. Not recommended experience :(

ErosOlmi
23-08-2007, 13:07
Hey Petr, take care :-\ My father was an animal hunter in his youth but I hate hunting!

Option 3 of course will add more power to TBGL
I've seen some system interpreting the first upper/left pixel as transparent color automatically but this can be a limit.

Petr Schreiber
23-08-2007, 13:14
Hi,

it did not sound as Berettas so I presume it was not your father :)
I also do not like hunts. Twice from today as I really felt hunted.

Top-left pixels is I think in GameMaker which my brother used quite a lot, but I do not like this system too much.

TBGL 0.2.1.0 is far away now, but if we could agree on the third option:


tbgl_LoadTexture TexName, TexID, TexFilter[, AnisotropyLevel[, transpR, transpG, transB]]

or


tbgl_LoadTexture TexName, TexID, TexFilter[, AnisotropyLevel[, transpRGB]]


I could release 0.2.0.1 just with this improvement quite fast.


Bye,
Petr

Michael Hartlef
23-08-2007, 13:35
Hi,

it did not sound as Berettas so I presume it was not your father :)
I also do not like hunts. Twice from today as I really felt hunted.

Top-left pixels is I think in GameMaker which my brother used quite a lot, but I do not like this system too much.

TBGL 0.2.1.0 is far away now, but if we could agree on the third option:


tbgl_LoadTexture TexName, TexID, TexFilter[, AnisotropyLevel[, transpR, transpG, transB]]

or


tbgl_LoadTexture TexName, TexID, TexFilter[, AnisotropyLevel[, transpRGB]]


I could release 0.2.0.1 just with this improvement quite fast.


Bye,
Petr


I think the second is better. I can create Sprites will alpha easily with my Photoshop 6 but I thought that there might be a way in code. Thanks guys for all the suggestions.

Petr, is AnisotropyLevel documented inside the help file. I never saw this before

Cheers
Michael

Petr Schreiber
23-08-2007, 13:47
Hi Mike,

no, anisotropy as well as %TBGL_TEX_ANISO will be new in TBGL 0.2.1.
It has brutal ( read great ) impact on image quality.

I am not sure for what did you decided, so this ?:


tbgl_LoadTexture TexName, TexID, TexFilter[, AnisotropyLevel[, transpRGB]]



Bye,
Petr

Michael Hartlef
23-08-2007, 14:45
Yes, that one. :)

Petr Schreiber
23-08-2007, 15:23
Then please have it :)

See help for TBGL_LoadTexture for more details.
Hope this is how you wanted it, see sample.
Anisotropic level is hot stuff, in case TBGL will run on older hardware it will fall back to MIPMAP automatically.

What is advantage of anisotropic filtering ? Watch sides of cube in sample when they are almost perpendicular to screen.
With mipmaps you will get blurry pulp, with aniso sharp image.

Sample shows masking of orange and black color.

Enjoy, hope no bugs,
Petr

Correct version uploaded

Petr Schreiber
23-08-2007, 15:39
I posted bad DLL version, now corrected

Petr

Michael Hartlef
23-08-2007, 15:45
Man, that's cool. Can't wait to try it tonight. THANK YOU!!!!

ErosOlmi
23-08-2007, 16:12
Sorry, I forgot to say that Petr is in a Nirvana programming period.
You can ask him whatever on TBGL and he will make before you will finish to ask.

Please take advantages from this till Nirvana will be with him !!!

;D

Petr Schreiber
23-08-2007, 16:53
;D

kryton9
23-08-2007, 22:00
Petr that is really cool. Modern art, now if we could make a holographic projector, I would have the nicest modern art sculptures in the world :)

Petr Schreiber
23-08-2007, 22:10
:)

it is 5 seconds art, texture was taken by my precious Canon long time ago, and that squares and black smudge were few clicks :D


Bye,
Petr