Results 1 to 14 of 14

Thread: Palette Animation

  1. #1

    Thread Starter
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181

    Palette Animation

    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)
    Last edited by /\/\isanThr0p; Jun 21st, 2001 at 02:44 PM.
    Sanity is a full time job

    Puh das war harter Stoff!

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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:
    1. Dim byteRGB() As PALETTEENTRY
    2.     Dim pDescriptor As DirectDrawPalette
    3.     Dim R(255) As Byte
    4.     Dim G(255) As Byte
    5.     Dim B(255) As Byte
    6.     Dim LNG(255) As Long
    7.     Dim It As Integer
    8.        
    9.     Set pDescriptor = [Surface].GetPalette
    10.     pDescriptor.GetEntries 0, 256, byteRGB()
    11.        
    12.     For It = 0 To 255
    13.         R(It) = byteRGB(It).red
    14.         G(It) = byteRGB(It).green
    15.         B(It) = byteRGB(It).blue
    16.         LNG(It) = RGB(byteRGB(It).red, byteRGB(It).green, byteRGB(It).blue)
    17.     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.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3

    Thread Starter
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    thanks

    that far it's all clear how can I animate that? I want it to change continiously.
    Sanity is a full time job

    Puh das war harter Stoff!

  4. #4

    Thread Starter
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    Hey
    ahm does that only work with 8 bit mode or surface?
    Sanity is a full time job

    Puh das war harter Stoff!

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Works only w/8bit surfaces
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6

    Thread Starter
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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?
    Sanity is a full time job

    Puh das war harter Stoff!

  7. #7
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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 )

    You should rotate it like this once you get the palette:

    VB Code:
    1. 'To rotate the first 8 colors
    2.  
    3. Dim Temp As Long
    4. Temp = Pal(0)
    5.  
    6. For i = 0 to 6
    7.   Pal(i) = Pal(i + 1)
    8. Next i
    9.  
    10. 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
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  8. #8

    Thread Starter
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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?
    Sanity is a full time job

    Puh das war harter Stoff!

  9. #9

    Thread Starter
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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!
    Sanity is a full time job

    Puh das war harter Stoff!

  10. #10
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  11. #11
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    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

  12. #12

    Thread Starter
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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.
    Sanity is a full time job

    Puh das war harter Stoff!

  13. #13
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457


    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...
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  14. #14

    Thread Starter
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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.
    Sanity is a full time job

    Puh das war harter Stoff!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width