Migrate planet scan tint to new drawing modes

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3477 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-12-27 07:23:28 +00:00
parent 24513c7b07
commit 8df76e7440
2 changed files with 28 additions and 32 deletions
+27 -31
View File
@@ -33,16 +33,6 @@
// It still doesn't look right though (it is too bright)
#define USE_ADDITIVE_SCAN_BLIT
// XXX: these are currently defined in libs/graphics/sdl/3do_getbody.c
// they should be sorted out and cleaned up at some point
extern DWORD frame_mapRGBA (FRAME FramePtr, UBYTE r, UBYTE g,
UBYTE b, UBYTE a);
extern void fill_frame_rgb (FRAME FramePtr, DWORD color, int x0, int y0,
int x, int y);
extern void arith_frame_blit (FRAME srcFrame, const RECT *rsrc,
FRAME dstFrame, const RECT *rdst, int num, int denom);
static int rotFrameIndex;
static int rotDirection;
static bool throbShield;
@@ -246,29 +236,35 @@ static void
renderTintFrame (Color tintColor)
{
PLANET_ORBIT *Orbit = &pSolarSysState->Orbit;
DWORD pix;
int denom;
FRAME topoFrame = SetAbsFrameIndex (Orbit->TintFrame, 0);
FRAME tintFrame = SetAbsFrameIndex (Orbit->TintFrame, 1);
CONTEXT oldContext;
DrawMode mode, oldMode;
STAMP s;
RECT r;
// render a solid color frame we will use for tinting
#ifdef USE_ADDITIVE_SCAN_BLIT
tintColor.r /= 2;
tintColor.g /= 2;
tintColor.b /= 2;
denom = -1;
#else
tintColor.a = 128;
denom = 0;
#endif
pix = frame_mapRGBA (tintFrame, tintColor.r, tintColor.g, tintColor.b,
tintColor.a);
fill_frame_rgb (tintFrame, pix, 0, 0, 0, 0);
oldContext = SetContext (OffScreenContext);
SetContextFGFrame (Orbit->TintFrame);
SetContextClipRect (NULL);
// get the rect of the whole context (or our frame really)
GetContextClipRect (&r);
// copy the topo frame to the tint frame
s.origin.x = 0;
s.origin.y = 0;
s.frame = pSolarSysState->TopoFrame;
DrawStamp (&s);
// copy topoFrame
arith_frame_blit (pSolarSysState->TopoFrame, NULL, topoFrame, NULL, 0, 0);
// apply the tint
arith_frame_blit (tintFrame, NULL, topoFrame, NULL, 0, denom);
#ifdef USE_ADDITIVE_SCAN_BLIT
mode = MAKE_DRAW_MODE (DRAW_ADDITIVE, DRAW_FACTOR_1 / 2);
#else
mode = MAKE_DRAW_MODE (DRAW_ALPHA, DRAW_FACTOR_1 / 2);
#endif
oldMode = SetContextDrawMode (mode);
SetContextForeGroundColor (tintColor);
DrawFilledRectangle (&r);
SetContextDrawMode (oldMode);
SetContext (oldContext);
}
// tintColor.a is ignored
@@ -289,7 +285,7 @@ DrawPlanet (int tintY, Color tintColor)
}
else
{ // apply different scan type tints
FRAME tintFrame = SetAbsFrameIndex (Orbit->TintFrame, 0);
FRAME tintFrame = Orbit->TintFrame;
int height = GetFrameHeight (tintFrame);
if (!sameColor (tintColor, Orbit->TintColor))
+1 -1
View File
@@ -1296,7 +1296,7 @@ planet_orbit_init (void)
Orbit->SphereFrame = CaptureDrawable (CreateDrawable (
WANT_PIXMAP | WANT_ALPHA, DIAMETER, DIAMETER, 2));
Orbit->TintFrame = CaptureDrawable (CreateDrawable (
WANT_PIXMAP | WANT_ALPHA, MAP_WIDTH, MAP_HEIGHT, 2));
WANT_PIXMAP, MAP_WIDTH, MAP_HEIGHT, 1));
Orbit->ObjectFrame = 0;
Orbit->WorkFrame = 0;
Orbit->lpTopoData = HCalloc (MAP_WIDTH * MAP_HEIGHT);