Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


Transparency in VGA


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 [GaNoN]   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 November 1999 - 12:44 AM

I am creating a VGA game in DJGGP and are wondering how I could efficiently do transparency. I don't really know how to make the palette to do this. This is the code I have written.

#include
#include
#include
#include
#include

typedef unsigned char byte;
byte *vram;
int i;

void SetGraphMode();
void DisplayVram();
void spalette(int colour,int red,int green,int blue);

void SetGraphMode(){
__dpmi_regs regs;
regs.x.ax = 0x13;
__dpmi_int(0x10,®s);
};

void DisplayVram(){
dosmemput(vram,64000,0xa0000);
}

void main(){
SetGraphMode();
vram = (byte*)malloc(64000);
memset(vram,0,64000);
for(i=0;i<10;i++){
spalette(i,int(6.1*i),0,0);
}
for(i=0;i<10;i++){
spalette(i+10,0,int(6.1*i),0);
}
for(i=0;i<10;i++){
spalette(i+20,0,0,int(6.1*i));
}
for(i=0;i<10;i++){
spalette(i+30,int(6.1*i),int(6.1*i),0);
}
for(i=0;i<10;i++){
spalette(i+40,int(6.1*i),0,int(6.1*i));
}
for(i=0;i<10;i++){
spalette(i+50,0,int(6.1*i),int(6.1*i));
}
for(i=0;i<60;i++){
spalette(i+60,int(6.1*i),int(6.1*i),int(6.1*i));
}
for(i = 0;i<80;i++){
vram[i]=i;
}
DisplayVram();
bioskey(0);
}

void spalette(int colour,int red,int green,int blue){
__dpmi_regs regs;
regs.x.ax=0x1010;
regs.x.bx=colour;
regs.h.dh=red;
regs.h.ch=green;
regs.h.cl=blue;
__dpmi_int(0x10,®s);
}

If ne1 could suggest a good way plz reply


Sponsor:

#2 Starfall   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 November 1999 - 11:46 PM

There's a pretty good tutorial on exactly this over at FlipCode. Check it out here.

Good luck!

Starfall


#3 Niels   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 November 1999 - 12:44 AM

To do full fledged alpha blending in 8-bit color you'd essentially need a 256x256 CLUT
for each transparency level (I.e. a table that for each possible source and destination pair hold the new pixel color for each possible alpha value). This amounts to 256x256x256 = 16MB of CLUT. If you're looking to do a 50/50 blend, a single 256x256 clut is sufficient.

Obviously tradeoffs can be made. For example, ordering your palette so that colors that "nearly match" are close to each other, you can treat them as identical when blending, reducing each CLUT to e.g. 64x64 entries (Entry 0 covers colors 0,1,2 and 3, Entry 1 covers 4,5,6 and 7). Limiting the amount of alpha levels also help. 16 levels or less is enough for some applications. I.e. 64x64x16=64K of CLUT.

Finally, may I suggest that true color IS the only way to get the really "crisp" look.

/Niels





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS