• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

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

kieren_j

Alpha sprite blitting

11 posts in this topic

Yup! It doesn't work, never has, and I doubt if it ever will (MS have been promising alpha support forever, but it's still not there.... Maybe with DX9231, who knows).

So, it's time to get your hands dirty and code it yourself !

/Niels

0

Share this post


Link to post
Share on other sites
DirectDraw doesn't support it in Hardware.

It "was" going to be in DX7, but turns out they decided against it.
Like I said, I have the ZIP file of a cool example that shows Sprites as D3D Quads rendered with alpha blending.

If you want it, just email me at:
rbenson@earthlink.net

Keeb

0

Share this post


Link to post
Share on other sites
No that's OK.
I have another question - I cant get the dwRotationAngle to work either - in fact it doesnt even blit at all!! I use DDBLT_ROTATIONANGLE or whatever it is, but - no luck.
Anybody got some code?
0

Share this post


Link to post
Share on other sites
Another great DirectDraw feature. There's no software emulation for rotating, so if its not supported by your hardware, you're out of luck.

BlueNexus

0

Share this post


Link to post
Share on other sites
I wanted to use that operation as well but like BlueNexus said it's only in Hardware and many of the good cards don't even support it. Better get cozy with Sin() and Cos()

Keeb

0

Share this post


Link to post
Share on other sites
DirectX is really a great name... "DirectAccess" - That is exactly all you get: Direct access to the framebuffer and HW features. The Docs spend quite a few pages talking HAL and HEL, just a shame that HEL never showed up ... Which leaves me wondering if you really needed a COM interface to get a pointer to a piece of memory.. Oh well ...

/Niels

0

Share this post


Link to post
Share on other sites
Can anyone point me to some good reference material for writing my own blitter with alpha channel?

Thanks,
Marcus

0

Share this post


Link to post
Share on other sites
Search on gamedev, there was an article - using MMX or something.
The thing is my card -DOES- support rotation, but has anybody got some demo code?
0

Share this post


Link to post
Share on other sites
hmmm... i think it is the old alpha problem again...

Ok, guys. Look at http://cust.nol.at/ppee/ for a quick end to this problem. The code is for 16 bit, but if you look closer it will be easy to transport it for 24 or 32.

Bye.

0

Share this post


Link to post
Share on other sites
Here I am a nice guy!

// Container structure for RGB masks
typedef struct _RGBMASK
{
ULONG rgbRed;
ULONG rgbGreen;
ULONG rgbBlue;
} RGBMASK;

// Container structure for (5,6,5 or 5,5,5 and masking)
typedef struct _RGB16
{
RGBQUAD depth;
RGBQUAD amount;
RGBQUAD position;
RGBMASK mask;
} RGB16;

extern RGB16 rgb16;

extern int RedMask, GreenMask, BlueMask; // RGB Masks
extern int RedPos, GreenPos, BluePos; // RGB Positions

#define RED(p) (p >> RedPos) // Extracts Red color
#define GREEN(p) ((p & GreenMask) >> GreenPos) // Extracts Green color
#define BLUE(p) (p & BlueMask) // Extracts Blue color
#define RGB16(r, g, b) ((r << RedPos) | (g << GreenPos) | b) // Creates RGB pixel even if card is in 555 or 565

void DDGetPixelFormat()
{
DDSURFACEDESC2 ddsd; // DirectDraw Surface Description
BYTE shiftcount; // Shift Counter

// Get a surface despriction.
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_PIXELFORMAT;
FrontSurf->Surface->GetSurfaceDesc(&ddsd);
// Fill in the masking values for extracting colors.
rgb16.mask.rgbRed = ddsd.ddpfPixelFormat.dwRBitMask;
rgb16.mask.rgbGreen = ddsd.ddpfPixelFormat.dwGBitMask;
rgb16.mask.rgbBlue = ddsd.ddpfPixelFormat.dwBBitMask;

// Get red surface information.
shiftcount = 0;
while(!(ddsd.ddpfPixelFormat.dwRBitMask & 1))
{
ddsd.ddpfPixelFormat.dwRBitMask >>= 1;
shiftcount++;
}
rgb16.depth.rgbRed = (BYTE)ddsd.ddpfPixelFormat.dwRBitMask;
rgb16.position.rgbRed = shiftcount;
rgb16.amount.rgbRed = (ddsd.ddpfPixelFormat.dwRBitMask == 0x1f) ? 3 : 2;

// Get green surface information.
shiftcount = 0;
while(!(ddsd.ddpfPixelFormat.dwGBitMask & 1))
{
ddsd.ddpfPixelFormat.dwGBitMask >>= 1;
shiftcount++;
}
rgb16.depth.rgbGreen =(BYTE)ddsd.ddpfPixelFormat.dwGBitMask;
rgb16.position.rgbGreen = shiftcount;
rgb16.amount.rgbGreen = (ddsd.ddpfPixelFormat.dwGBitMask == 0x1f) ? 3 : 2;

// Get Blue surface information.
shiftcount = 0;
while(!(ddsd.ddpfPixelFormat.dwBBitMask & 1))
{
ddsd.ddpfPixelFormat.dwBBitMask >>= 1;
shiftcount++;
}
rgb16.depth.rgbBlue =(BYTE)ddsd.ddpfPixelFormat.dwBBitMask;
rgb16.position.rgbBlue = shiftcount;
rgb16.amount.rgbBlue = (ddsd.ddpfPixelFormat.dwBBitMask == 0x1f) ? 3 : 2;
// Fill in variables so we dont' have to access the structure anymore.
RedMask = rgb16.mask.rgbRed; // Red Mask
GreenMask = rgb16.mask.rgbGreen; // Green Mask
BlueMask = rgb16.mask.rgbBlue; // Blue Mask
RedPos = rgb16.position.rgbRed; // Red Position
GreenPos = rgb16.position.rgbGreen; // Green Position
BluePos = rgb16.position.rgbBlue; // Blue Position
}

//This will blit the src color you pass to it with the background color at x,y location, you can have 256 levels of alpha. The math is already optimized but doing pixel by pixel is overkill you must find a way to optimize even more
int DDPlotAlphaPixel(int pX, int pY, int pR, int pG, int pB, int pA, G16SURFACEPTR pSurf)
{
int Alpha = pA;

USHORT src = RGB16(pR,pG,pB);
USHORT dest = ((USHORT*)pSurf->Buffer)[pX + (pY*pSurf->Pitch>>1)];

dest = ((RedMask & ((dest & RedMask) + ((int)(((int)(src & RedMask) - (int)(dest & RedMask)) * Alpha) >>8))) |
(GreenMask & ((dest & GreenMask) + ((int)(((int)(src & GreenMask) - (int)(dest & GreenMask)) * Alpha) >>8))) |
(BlueMask & ((dest & BlueMask) + ((int)(((int)(src & BlueMask) - (int)(dest & BlueMask)) * Alpha) >>8))));

((USHORT*)pSurf->Buffer)[pX + (pY*pSurf->Pitch>>1)] = dest;

return(1);
}

// Does additive blending meanning. Good for doing explosions and stuff. What you do is you draw the explosions in you bitmao on a black background. After when you blit you add the background color that you got at x,y location on you screen to the bitmap. So black wich is 0 plus the color at x,y location gives the same color but. lets say the back ground color plus yellow somewhere in you fire will give the mixed color. This wau you wont have a black ora around your sprite explosion when you blit on a non black background.
int DDAddToPixel(int pX, int pY, int pR, int pG, int pB, G16SURFACEPTR pSurf)
{
USHORT tdest = 0;
USHORT t;

USHORT src = ((USHORT*)pSurf->Buffer)[pX + (pY*pSurf->Pitch>>1)];
USHORT dest = RGB16(pR,pG,pB);

t = (src & RedMask) + (dest & RedMask);
if(t > RedMask) t = RedMask;
tdest |= t;

t = (src & GreenMask) + (dest & GreenMask);
if(t > GreenMask) t = GreenMask;
tdest |= t;

t = (src & BlueMask) + (dest & BlueMask);
if(t > BlueMask) t = BlueMask;
tdest |= t;

((USHORT*)pSurf->Buffer)[pX + (pY*pSurf->Pitch>>1)] = tdest;

return(1);
}

0

Share this post


Link to post
Share on other sites
Hi, I can't seem to get the "alpha" feature of IDirectDrawSurface3->Blt to work...it just blits it opaque or not at all.
Anybody else experianced this / got some example code?

thanks

0

Share this post


Link to post
Share on other sites