I have heard about palette animation a lot and I think I could have use for that. Is there a good place where I can learn how to make a palette animation in Direct Draw (7)
Printable View
I have heard about palette animation a lot and I think I could have use for that. Is there a good place where I can learn how to make a palette animation in Direct Draw (7)
Well, for starters, it's really easy to populate 3 byte arrays/long array with the colours shown on the pallette, shown below:
VB Code:
Dim byteRGB() As PALETTEENTRY Dim pDescriptor As DirectDrawPalette Dim R(255) As Byte Dim G(255) As Byte Dim B(255) As Byte Dim LNG(255) As Long Dim It As Integer Set pDescriptor = [Surface].GetPalette pDescriptor.GetEntries 0, 256, byteRGB() For It = 0 To 255 R(It) = byteRGB(It).red G(It) = byteRGB(It).green B(It) = byteRGB(It).blue LNG(It) = RGB(byteRGB(It).red, byteRGB(It).green, byteRGB(It).blue) Next It
To get the colours that you need for getlockedarray methods, just call on R(), G(), and B(). For other operations (API) use the LNG array.
thanks
that far it's all clear how can I animate that? I want it to change continiously.
Hey
ahm does that only work with 8 bit mode or surface?
Works only w/8bit surfaces
ok
I tried to make the palette of the surface 8 bit by doing that but it still gives me an automation error (DDerr_generic)
sur.ddsd.ddpfPixelFormat.lRGBBitCount = 8
what do I have to do?
There's a very good sample that includes direct access to video memory and palette rotation in the DX MSDK, it's called DDBlend.
But you shouldn't create your own palette like that: you'll notice it's much easier to load it from a file so you can modify it as you wish (eg.: you'll notice that Starcraft's palette is very irregular, like it has 6 gradations for metal colors, a few more for dirt ground etc; you should do this instead of making a general palette that may have colors you don't need and not have the colors you need :p )
You should rotate it like this once you get the palette:
VB Code:
'To rotate the first 8 colors Dim Temp As Long Temp = Pal(0) For i = 0 to 6 Pal(i) = Pal(i + 1) Next i Pal(i + 1) = Temp
Ok, to make it work for other colors, you can just replace the 0s with the first color and 7 with the last one. Good luck :)
ok thanks for that
but how can I create a 8 bit surface
do I just have to save the file in 8 bit or what?
Ok I played around with the blend example.
I think I cant work it without setting the display mode to 8bit. That is impossible for me though, because I just want to animate the background for a 3d game. I cant set the game to 8 bit only for that.
Thanks anyways. If anyone has a solution please help!
That's even easier: just save the image as 8-bits (most graphics programs let you choose your palette), and edit the palette of the surface where you have the image in the game, using the code I gave you.
There's no problem about blting it to a 24-bits surface ;)
Yes, DX will do this job for you. Also you can load 24bit surfaces and blt to a 8bit buffer, DX will convert the colors...
meaning: Your buffers dont have to be the same color depth
Well sounds all just great. The only problem is I cant make it. I loaded an 8bit picture (pallete optimal) to a surface without doing anything special. Well when I try to get the palette I get an automation error. I dont know what I have to do. The game is in 16 bit. I cant use anything else because of the crappy graphicsboard I got here.
:confused:
Well, there's something that wasn't suposed to happen :)
I never tried to do that, but I thought that if it was possible to do it with the primary surface, it was possible with all of them...
buhuuuuuuu
so what should I do? A static background to my 3d Pong sounds extremely boring to me.
HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Any Ideas that dont take to much memory and CPU power are very welcome.