From 24513c7b075b71af832430f282b869913d06c628 Mon Sep 17 00:00:00 2001 From: avolkov Date: Sun, 27 Dec 2009 06:50:52 +0000 Subject: [PATCH] Migrate planet map shield tint to new drawing modes git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3476 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/libs/gfxlib.h | 1 + sc2/src/uqm/planets/plangen.c | 42 ++++++++++++++++------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/sc2/src/libs/gfxlib.h b/sc2/src/libs/gfxlib.h index 374ccb491..b99032016 100644 --- a/sc2/src/libs/gfxlib.h +++ b/sc2/src/libs/gfxlib.h @@ -317,6 +317,7 @@ typedef struct } DrawMode; #define DRAW_REPLACE_MODE MAKE_DRAW_MODE (DRAW_REPLACE, 0) +#define DRAW_FACTOR_1 0xff static inline DrawMode MAKE_DRAW_MODE (DrawKind kind, SWORD factor) diff --git a/sc2/src/uqm/planets/plangen.c b/sc2/src/uqm/planets/plangen.c index ba5b9cb10..e6c653b22 100644 --- a/sc2/src/uqm/planets/plangen.c +++ b/sc2/src/uqm/planets/plangen.c @@ -37,16 +37,6 @@ // an additive overlay for the shield effect #undef USE_ALPHA_SHIELD -// 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); - - #define SHIELD_GLOW_COMP 120 #define SHIELD_REFLECT_COMP 100 @@ -651,23 +641,27 @@ SetShieldThrobEffect (FRAME ShieldFrame, int offset, FRAME ThrobFrame) static void ApplyShieldTint (void) { - UBYTE a; - int blit_type; - FRAME tintFrame = pSolarSysState->Orbit.TintFrame; - DWORD p; + DrawMode mode, oldMode; + FRAME oldFrame; + Color tint; + RECT r; + // TopoFrame will be permanently changed + oldFrame = SetContextFGFrame (pSolarSysState->TopoFrame); + SetContextClipRect (NULL); + GetContextClipRect (&r); + + tint = BUILD_COLOR_RGBA (0xff, 0x00, 0x00, 0xff); #ifdef USE_ALPHA_SHIELD - a = 200; - blit_type = 0; + mode = MAKE_DRAW_MODE (DRAW_ALPHA, 150); #else - //additive_blit - a = 255; - blit_type = -1; + mode = MAKE_DRAW_MODE (DRAW_ADDITIVE, DRAW_FACTOR_1); #endif - p = frame_mapRGBA (tintFrame, 255, 0, 0, a); - fill_frame_rgb (tintFrame, p, 0, 0, 0, 0); - arith_frame_blit (tintFrame, NULL, pSolarSysState->TopoFrame, NULL, - 0, blit_type); + oldMode = SetContextDrawMode (mode); + SetContextForeGroundColor (tint); + DrawFilledRectangle (&r); + SetContextDrawMode (oldMode); + SetContextFGFrame (oldFrame); } static inline UBYTE @@ -1739,6 +1733,7 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame) old_seed = TFB_SeedRandom (pPlanetDesc->rand_seed); TopoContext = CreateContext ("Plangen.TopoContext"); + LockMutex (GraphicsLock); OldContext = SetContext (TopoContext); planet_orbit_init (); @@ -1953,6 +1948,7 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame) } SetContext (OldContext); + UnlockMutex (GraphicsLock); DestroyContext (TopoContext); TFB_SeedRandom (old_seed);