Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 Index Palettes

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
Mr. Palette Posted - Mar 26 2003 : 2:07:49 PM
I'm trying to use an index palette to change the colors of the sprites in my game.

The DirectX7 SDK says to pass an array of bytes instead of an array of PALETTEENTRY types in the DirectDraw7.CreatePalette method, but I get type mismatch error.

An index palette is a palette that contains refrences to another palette's color table instead of a color table of its own.

6   L A T E S T    R E P L I E S    (Newest First)
Eric Coleman Posted - Mar 30 2003 : 10:45:32 AM
I have never used pallets in Direct Draw, but if you use the code I pasted above, you'll be able to use a PaletteEntry type as though it were an array of bytes. And thus create an indexed palette. That's all the help I can give you, I don't know of anyone that has used palettes (or even indexed palettes for that matter) in a Direct Draw program. This means that your only source of information will be the SDK, so you'll be doing something that no one else has done with VB. If you do get things working, you may want to consider writing a tutorial on it so other people can learn how to use indexed palettes.
Mr. Palette Posted - Mar 29 2003 : 1:43:58 PM
What I'm trying to do with this is set the colors of the sprites in my game to a team (some little men have a red shirt and others have a blue shirt but still come from the same surface). An index palette would be perfect for this. All you need to do is set a few entries on the sprite before you blit it.

Is it even possible to use these index palettes in VB?????

Or is there another way to do this???
Eric Coleman Posted - Mar 26 2003 : 7:34:17 PM
I see what you mean. Of course, this is not the only error in the SDK. Instead of using an indexed color palette, use a 256( or 254 ) color palette. If you want to change the colors of the sprites in your game, then use DirectDrawPalette.GetEntries and DirectDrawPalette.SetEntries to change the colors in the palette. This will change the colors in the game. Of course, you need to plan ahead to reserve entries in the palette for the sprites, or for color cycling.

Or if you still want to hack around with indexed color palletes, then you can create a 2-bit or 4-bit palette by packing the bytes into an array of PALETTEENTRY types. It would look something like this.

  
Dim PalBytes(0 To 0) As PALETTEENTRY  
  
'a 2-bit array will hve 4 entries, or 4 bytes.
'Notice the order, which is important. The SDK
'lists the structure order just like below, which is the
'byte order is is in memory. Of course, you may want
'to use CopyMemory to test the byte order to make sure.
With PalBytes(0)  
  .blue = byte1  
  .flags = byte2  
  .green = byte3  
  .red = byte4  
End With
  
'Or if you want a 4-bit, that would be 16 bytes.
'so you should use the following for 16 bytes.
Dim PalBytes(0 To 3) As PALETTEENTRY  
  
Amrazek Posted - Mar 26 2003 : 6:02:59 PM
What bit mode are you trying to use this in?
Mr. Palette Posted - Mar 26 2003 : 5:51:57 PM
Palette Types [Language: Visual Basic]
DirectDraw supports 1-bit (2 entry), 2-bit (4 entry), 4-bit (16 entry), and 8-bit (256 entry) palettes. A palette can only be attached to a surface that has a matching pixel format. For example, a 2-entry palette created with the DDPCAPS_1BIT flag can be attached only to a 1-bit surface created with the DDPF_PALETTEINDEXED1 flag.

Additionally, you can create palettes that don't contain a color table at all, known as index palettes. Instead of a color table, an index palette contains index values that represent locations in another palette's color table.

[Visual Basic]
To create an indexed palette, specify the DDPCAPS_8BITENTRIES flag when calling the DirectDraw7.CreatePalette method. For example, to create a 4-bit indexed palette, specify both the DDPCAPS_4BIT and DDPCAPS_8BITENTRIES flags. When you create an indexed palette, you pass an array of bytes rather than an array of PALETTEENTRY types.


I copied that from the SDK. (DirectDraw\DirectDraw Essentials\Palettes\Palette Types)

I get a type mismatch error when I try to pass the array of bytes instead of PALETTEENTRY types.
Eric Coleman Posted - Mar 26 2003 : 2:49:56 PM
I don't know where you see that in the SDK, but my copy of the SDK says to pass an "array of 2, 4, 16, or 256 PALETTEENTRY types[...]."

VBGamer © Go To Top Of Page
This page was generated in 0.08 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.