• Advertisement

Archived

This topic is now archived and is closed to further replies.

Doing fades and such in 16-bit using look-ups

This topic is 6215 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to use this article on GDNet to do a fade using look-up tables. Although I understand the premise, I am not really sure about the implementation. Here's where I initialize the lookup table. The idea is that the first element is the colors and the second is 20 the increments of the fade.
    

USHORT clut[65537][21];

int clutx, cluty;

for (clutx=0; clutx<65536; clutx++)   
{
  for (cluty=0; cluty<20; cluty++)        
  {
	  clut[clutx][cluty] =(int) (clutx * (float)(cluty/20));    
  }
}
  



Here's the function that does the lookup and does the fade.

      
void ApplyFade(int pct, USHORT* fadebuffer, int pitch)
{
  int x, y;
  USHORT* temp = fadebuffer;
  int jump = pitch - 200;
  int index;

  for (y=0; y<200; y++)
  {
    for (x=0; x<200; x++, temp++) // move pointer to next pixel each time

    {
	  index=pct/5;
     *temp = clut[*temp][index];
    }

    // move pointer to beginning of next line

    temp+=jump;
  }
}
    
All that happens is it crashes back to windows when I perform the fade. Is this code anywhere near correct?
Need help? Well, go FAQ yourself.
What a plight we who try to make a story-based game have...writers of conventional media have words, we have but binary numbers
Edited by - Nazrix on February 17, 2001 6:41:06 PM

Share this post


Link to post
Share on other sites
Advertisement
I''m at work at the moment, getting paid to sit on my ass and do nothing, but when I get home I''ll send you some code. It''s not exactly the fastest thing in the world but it works... maybe we can figure out how to speed it up a bit.

-Ironblayde
 Aeon Software

Down with Tiberia!!

Share this post


Link to post
Share on other sites
Iron,

Great

I''ll look forward to that. A long time ago, you explained this a bit. As helpful as it was, I am still a bit shaky about it.



Need help? Well, go FAQ yourself.
What a plight we who try to make a story-based game have...writers of conventional media have words, we have but binary numbers

Share this post


Link to post
Share on other sites

  • Advertisement