directdraw surfaces
Hello,
Does anyone know how to fade a surfaces in directdraw (not d3d) down to either black or white?
It's not reverse engineering, unless you get caught.
Yes you can, very easily in fact. Not sure how, cause I haven''t ever done it. I know theres some kind of gamma command. That would be good for fading. I bet it would be slow though if your hardware didn''t support it and it had to emulate it. Now this I''m talking about is all for 24bit, 32bit, and 16bit. If your in 8bit, fading is a piece of cake. just fade the palette.
Hi Armera
If you're in 8 Bit mode you only have to change and then set the palette entries. You should find out by yourself how the entries have to be changed to fade in or out.
If you use 16 Bit or higher Bit modes than the easiest and fastest way to do it is to use the IDirectDrawGammaControl interface. Query your primary surface for that interface like this:
IDirectDrawGammaControl *pGC = NULL;
pPrimary->QueryInterface(IID_IDirectDrawGammaControl, (LPVOID*)&pGC);
If the QueryInterface call failed than the users hardware doesn't support this feature and you have to do it completely by yourself because this won't be emulated in software.
But if you got the interface you can use it like this:
DDGAMMARAMP ddgr;
for (int i = 0; i < 256; i++)
{
ddgr.red = ddgr.green = ddgr.blue = i * 257;
}
pGC->SetGammaRamp(0, &ddgr);
This will set the gamma ramp to normal so a pixel with RGB(255, 0, 0) will be put to the screen with exactly this color.
But if you set the gamma ramp as follows:
for (float i = 0; i < 256; i++)
{
ddgr.red = ddgr.green = ddgr.blue = (WORD)(i * 128.5);<br>}<br><br>pGC->SetGammaRamp(0, &ddgr);<br><br>A pixel with RGB(255, 0, 0) will be RGB(128, 0, 0) on the screen. Please look in the DX7SDK documentation for further details about this topic. </i> <br><br>Edited by - VirtualNext on 1/12/00 6:42:36 AM
If you're in 8 Bit mode you only have to change and then set the palette entries. You should find out by yourself how the entries have to be changed to fade in or out.
If you use 16 Bit or higher Bit modes than the easiest and fastest way to do it is to use the IDirectDrawGammaControl interface. Query your primary surface for that interface like this:
IDirectDrawGammaControl *pGC = NULL;
pPrimary->QueryInterface(IID_IDirectDrawGammaControl, (LPVOID*)&pGC);
If the QueryInterface call failed than the users hardware doesn't support this feature and you have to do it completely by yourself because this won't be emulated in software.
But if you got the interface you can use it like this:
DDGAMMARAMP ddgr;
for (int i = 0; i < 256; i++)
{
ddgr.red = ddgr.green = ddgr.blue = i * 257;
}
pGC->SetGammaRamp(0, &ddgr);
This will set the gamma ramp to normal so a pixel with RGB(255, 0, 0) will be put to the screen with exactly this color.
But if you set the gamma ramp as follows:
for (float i = 0; i < 256; i++)
{
ddgr.red = ddgr.green = ddgr.blue = (WORD)(i * 128.5);<br>}<br><br>pGC->SetGammaRamp(0, &ddgr);<br><br>A pixel with RGB(255, 0, 0) will be RGB(128, 0, 0) on the screen. Please look in the DX7SDK documentation for further details about this topic. </i> <br><br>Edited by - VirtualNext on 1/12/00 6:42:36 AM
Okay the users hardware doesnt support it so what is the next best way to do it?
It's not reverse engineering, unless you get caught.
January 12, 2000 01:21 PM
Well if your hardware doesn''t support it I think you can still use the gamma control but you will have to emulate it.
Also...
I''ve found that the gamma control only works in full-screen mode. I don''t know of any way to do a fade in a 16bpp+ windowed mode, short of messing with every single pixel on the screen.
Mason McCuskey
Spin Studios - home of Quaternion, 2000 GDC Indie Games Fest Finalist!
www.spin-studios.com
I''ve found that the gamma control only works in full-screen mode. I don''t know of any way to do a fade in a 16bpp+ windowed mode, short of messing with every single pixel on the screen.
Mason McCuskey
Spin Studios - home of Quaternion, 2000 GDC Indie Games Fest Finalist!
www.spin-studios.com
Founder, Cuttlefish Industries
The Cuttlefish Engine lets anyone develop great games for iPad, iPhone, Android, WP7, the web, and more!
The Cuttlefish Engine lets anyone develop great games for iPad, iPhone, Android, WP7, the web, and more!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement