mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Optimise pixel drawing
This commit is contained in:
parent
3986c28725
commit
89a58888b8
1 changed files with 14 additions and 6 deletions
20
src/am_map.c
20
src/am_map.c
|
|
@ -205,6 +205,7 @@ static boolean followplayer = true; // specifies whether to follow the player ar
|
||||||
typedef void (*AMDRAWFLINEFUNC) (const fline_t *fl, INT32 color);
|
typedef void (*AMDRAWFLINEFUNC) (const fline_t *fl, INT32 color);
|
||||||
static AMDRAWFLINEFUNC AM_drawFline;
|
static AMDRAWFLINEFUNC AM_drawFline;
|
||||||
|
|
||||||
|
static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc);
|
||||||
static void AM_drawFline_soft(const fline_t *fl, INT32 color);
|
static void AM_drawFline_soft(const fline_t *fl, INT32 color);
|
||||||
|
|
||||||
static void AM_activateNewScale(void)
|
static void AM_activateNewScale(void)
|
||||||
|
|
@ -712,6 +713,17 @@ static boolean AM_clipMline(const mline_t *ml, fline_t *fl)
|
||||||
}
|
}
|
||||||
#undef DOOUTCODE
|
#undef DOOUTCODE
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draws a pixel.
|
||||||
|
//
|
||||||
|
static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc)
|
||||||
|
{
|
||||||
|
UINT8 *dest = screens[0];
|
||||||
|
if (xx < 0 || yy < 0 || xx >= vid.width || yy >= vid.height)
|
||||||
|
return; // off the screen
|
||||||
|
dest[(yy*vid.rowbytes) + (xx * vid.bpp)] = (cc & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Classic Bresenham w/ whatever optimizations needed for speed
|
// Classic Bresenham w/ whatever optimizations needed for speed
|
||||||
//
|
//
|
||||||
|
|
@ -733,8 +745,6 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PUTDOT(xx,yy,cc) V_DrawFill(xx,yy,1,1,cc|V_NOSCALESTART);
|
|
||||||
|
|
||||||
dx = fl->b.x - fl->a.x;
|
dx = fl->b.x - fl->a.x;
|
||||||
ax = 2 * (dx < 0 ? -dx : dx);
|
ax = 2 * (dx < 0 ? -dx : dx);
|
||||||
sx = dx < 0 ? -1 : 1;
|
sx = dx < 0 ? -1 : 1;
|
||||||
|
|
@ -751,7 +761,7 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
|
||||||
d = ay - ax/2;
|
d = ay - ax/2;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
PUTDOT(x, y, color)
|
AM_drawPixel(x, y, color);
|
||||||
if (x == fl->b.x)
|
if (x == fl->b.x)
|
||||||
return;
|
return;
|
||||||
if (d >= 0)
|
if (d >= 0)
|
||||||
|
|
@ -768,7 +778,7 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
|
||||||
d = ax - ay/2;
|
d = ax - ay/2;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
PUTDOT(x, y, color)
|
AM_drawPixel(x, y, color);
|
||||||
if (y == fl->b.y)
|
if (y == fl->b.y)
|
||||||
return;
|
return;
|
||||||
if (d >= 0)
|
if (d >= 0)
|
||||||
|
|
@ -780,8 +790,6 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
|
||||||
d += ax;
|
d += ax;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef PUTDOT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue