Page 1 of 2
How to programmicly convert rgb(255,255,255) to $FFFF00 ???
Posted: Tue Jan 04, 2005 3:23 am
by Shannara
Does anybody know how to programmicly convert rgb(255,255,255) to $FFFF00 ???
Posted: Tue Jan 04, 2005 3:53 am
by PolyVector
They should probably take bytes but... then it doesn't work correctly...
Code: Select all
Procedure RGB_24(r.l,g.l,b.l)
ProcedureReturn (r<<16)|(g<<8)|b
EndProcedure
Procedure RGB_16_565(r.l,g.l,b.l)
ProcedureReturn (r<<11)|(g<<5)|b
EndProcedure
Procedure RGB_16_555(r.l,g.l,b.l)
ProcedureReturn (r<<10)|(g<<5)|b
EndProcedure
Posted: Tue Jan 04, 2005 5:05 am
by Karbon
Skunk, check your sig, "development" is typo'd..
Posted: Tue Jan 04, 2005 7:25 am
by PolyVector
Thanks Karbon... Must have mashed the keyboard when I added the png...

Posted: Tue Jan 04, 2005 5:54 pm
by Shannara
Well, what I am basically trying to do is color vertices per Danillo's sample near the bottom of
viewtopic.php?t=8938
Code: Select all
Procedure SetSprite3DColor(sprite,a,b,c,d)
;
; set a color for the 4 Sprite3D corners
;
*p.PB_Sprite3D
;!extrn _PB_Sprite3D_ObjectsArea
!MOV dword EBX,[_PB_Sprite3D_ObjectsArea]
!MOV dword EAX,136
!MUL dword [ESP]
!ADD dword EBX,EAX
!MOV dword [ESP+20],EBX
*p\Vertice[0]\color = $FF000000+a
*p\Vertice[1]\color = $FF000000+b
*p\Vertice[2]\color = $FF000000+c
*p\Vertice[3]\color = $FF000000+d
EndProcedure
And in the example, it is called by ...
Code: Select all
SetSprite3DColor(1,$FFFF00,$FF0000,$0000FF,$00FFFF)
So I am trying to have it pass RGB values, which I am assuming needs to be HEXed before passed or so. Thus the reason for the need of programmically hex the RGB values.
With what you have above, may work, if I could figure out what video card format the card runs on

I think ...
Posted: Tue Jan 04, 2005 7:36 pm
by BalrogSoft
Hi Shannara, did you tried to use RGB?
RGB(Blue, Green, Red)
RGB format for Direct3D is a inverted RGB.
Posted: Tue Jan 04, 2005 7:45 pm
by Shannara
Yep, but that does not work.
Posted: Tue Jan 04, 2005 8:00 pm
by BalrogSoft
Hi, i forget that first byte of a RGB value on Direct3D is transparency, use this code:
RGB(Blue, Green, Red) + (Transparency << 24)
I think that it must to work, because RGB not set transparency (is 0 for using RGB, you must set transparency byte)
Posted: Tue Jan 04, 2005 8:06 pm
by Shannara
Unfortuinately, no go

For example, if you replace the SetSprite3DColor line with
Code: Select all
SetSprite3DColor(1,RGB(255, 255, 255) + (255 << 24) ,$FF0000,$0000FF,$00FFFF)
It will be a blank texture. so I dont think that is working properly, even if I change the transparency to 0. I do not know if it is Danilo's code or the RGB thing isnt working properly.
Posted: Tue Jan 04, 2005 8:21 pm
by BalrogSoft
I tried Danilo code and works perfectly on my computer, with inverted colors:
SetSprite3DColor(1,RGB(0,255,255),RGB(0,0,255),RGB(0,255,0),RGB(255,255,0))
Posted: Tue Jan 04, 2005 8:24 pm
by Shannara
Not here
Code: Select all
SetSprite3DColor(1,RGB(255, 0, 255) ,RGB(255, 0, 0),RGB(255, 255, 0),RGB(255, 0, 200))
It gives a blank white texture.
Ok, if we cant figure this out, the I'll know it's a bug in Danilo's code.
Ah, it turns out that his compiled exe uses different code then what is provided in the source ..
Danilo, if your reading this, please provide the code used in the EXE. Since the EXE works but the source code does not.
Posted: Tue Jan 04, 2005 8:32 pm
by BalrogSoft
With some graphic cards sprites must have a specific size, 32x32, 128x128, 256x256, check the size of the sprites, you can use directly Direct3D, i made an example:
viewtopic.php?t=13590
Posted: Tue Jan 04, 2005 8:35 pm
by Shannara
Okay, that doesnt really help me. My video card takes all sizes up to at least 256x256 so I know it's danilo's code. Plus its using the same image as daniloo, i'm only running his sample code. The exe works, which uses that image, but the source code itself does not.
Posted: Wed Jan 05, 2005 2:59 am
by PolyVector
so neither RGB_16_565() or RGB_16_555() worked? That's strange, I read that those were the two main 16bit color formulas on a mircosoft site...
Posted: Wed Jan 05, 2005 3:51 am
by Shannara
PolyVector wrote:so neither RGB_16_565() or RGB_16_555() worked? That's strange, I read that those were the two main 16bit color formulas on a mircosoft site...
The matter is, the code posted is not the code that was used to compile the EXE in the sample. The exe works perfectly, the code provided is faulty.
I never tried the procedures you just now posted, since nobody ever posted them before you

But it still stands. If the code was the code used in the EXE then the code would work.
Anyways, I PM'd him even though he havent been on the forums since October 2004.
Until then, anybody have a way to change the colors of the four corners of a Sprite3D?