How to programmicly convert rgb(255,255,255) to $FFFF00 ???

Just starting out? Need help? Post your questions and find answers here.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

How to programmicly convert rgb(255,255,255) to $FFFF00 ???

Post by Shannara »

Does anybody know how to programmicly convert rgb(255,255,255) to $FFFF00 ???
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post 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
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Skunk, check your sig, "development" is typo'd..
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

Thanks Karbon... Must have mashed the keyboard when I added the png... :)
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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 ...
BalrogSoft
Enthusiast
Enthusiast
Posts: 203
Joined: Sat Apr 26, 2003 6:33 pm
Location: Spain
Contact:

Post by BalrogSoft »

Hi Shannara, did you tried to use RGB?

RGB(Blue, Green, Red)

RGB format for Direct3D is a inverted RGB.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Yep, but that does not work.
BalrogSoft
Enthusiast
Enthusiast
Posts: 203
Joined: Sat Apr 26, 2003 6:33 pm
Location: Spain
Contact:

Post 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)
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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.
BalrogSoft
Enthusiast
Enthusiast
Posts: 203
Joined: Sat Apr 26, 2003 6:33 pm
Location: Spain
Contact:

Post 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))
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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.
BalrogSoft
Enthusiast
Enthusiast
Posts: 203
Joined: Sat Apr 26, 2003 6:33 pm
Location: Spain
Contact:

Post 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
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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.
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post 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...
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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?
Post Reply