You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

439 lines
8.0 KiB
C

//:Header:187, "llgfx_lines", 3b93fb52
//
// File: llgfx_lines.h
//
// G A M E.O.N.E - LOW LEVEL LIB V1.0
// Copyright (C) 2001 LEVEL ONE ENTERTAINMENT,
// Licensed under the terms of LGPL.
//:---------------------------------------------------------------------------
//:Description
//
#if !defined(LLGFX_LINES_INCLUDED)
#define LLGFX_LINES_INCLUDED
#include "lib_base.h"
#include "ll3d_math.h"
#include "llgfx.h"
//:> +------------------------------------+
//:>-------------------| Global Function Declarations |-------------------
//:> +------------------------------------+
//::25
// +------------------+
// | Adddirtyrect() |
// +------------------+
inline void Adddirtyrect(
int x1,
int y1,
int x2,
int y2);
//::24
// +--------------------+
// | llgfx_ClipLine() |
// +--------------------+
inline bool llgfx_ClipLine(
int &x1,
int &y1,
int &x2,
int &y2,
int xmin,
int ymin,
int xmax,
int ymax);
//::30
// +----------------------------+
// | llgfx_DrawGradientLine() |
// +----------------------------+
void llgfx_DrawGradientLine(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU32 startcolor,
TxU32 endcolor);
//::36
// +----------------------------+
// | llgfx_DrawGradientRect() |
// +----------------------------+
void llgfx_DrawGradientRect(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU32 startcolor,
TxU32 endcolor);
//::42
// +----------------------------+
// | llgfx_DrawGradientRect() |
// +----------------------------+
void llgfx_DrawGradientRect(
llgfx_id idx,
llgfx_sRECT *dstrect,
TxU32 startcolor,
TxU32 endcolor);
//::26
// +--------------------+
// | llgfx_DrawLine() |
// +--------------------+
void llgfx_DrawLine(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU32 color);
void llgfx_DrawLine(
llgfx_id idx,
float x1,
float y1,
float x2,
float y2,
TxU32 color);
//::27
// +-------------------------+
// | llgfx_DrawLineAlpha() |
// +-------------------------+
void llgfx_DrawLineAlpha(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU8 alpha,
TxU32 color);
//::31
// +-----------------------------------+
// | llgfx_DrawPatternGradientLine() |
// +-----------------------------------+
void llgfx_DrawPatternGradientLine(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU32 pattern,
TxU32 startcolor,
TxU32 endcolor);
//::37
// +-----------------------------------+
// | llgfx_DrawPatternGradientRect() |
// +-----------------------------------+
void llgfx_DrawPatternGradientRect(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU32 pattern,
TxU32 startcolor,
TxU32 endcolor);
//::43
// +-----------------------------------+
// | llgfx_DrawPatternGradientRect() |
// +-----------------------------------+
void llgfx_DrawPatternGradientRect(
llgfx_id idx,
llgfx_sRECT *dstrect,
TxU32 pattern,
TxU32 startcolor,
TxU32 endcolor);
//::29
// +---------------------------+
// | llgfx_DrawPatternLine() |
// +---------------------------+
void llgfx_DrawPatternLine(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU32 pattern,
TxU32 color);
//::28
// +--------------------------------+
// | llgfx_DrawPatternLineAlpha() |
// +--------------------------------+
void llgfx_DrawPatternLineAlpha(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU32 pattern,
TxU8 alpha,
TxU32 color);
//::34
// +---------------------------+
// | llgfx_DrawPatternRect() |
// +---------------------------+
void llgfx_DrawPatternRect(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU32 pattern,
TxU32 color);
//::40
// +---------------------------+
// | llgfx_DrawPatternRect() |
// +---------------------------+
void llgfx_DrawPatternRect(
llgfx_id idx,
llgfx_sRECT *dstrect,
TxU32 pattern,
TxU32 color);
//::35
// +--------------------------------+
// | llgfx_DrawPatternRectAlpha() |
// +--------------------------------+
void llgfx_DrawPatternRectAlpha(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU32 pattern,
TxU8 alpha,
TxU32 color);
//::41
// +--------------------------------+
// | llgfx_DrawPatternRectAlpha() |
// +--------------------------------+
void llgfx_DrawPatternRectAlpha(
llgfx_id idx,
llgfx_sRECT *dstrect,
TxU32 pattern,
TxU8 alpha,
TxU32 color);
//::32
// +--------------------+
// | llgfx_DrawRect() |
// +--------------------+
void llgfx_DrawRect(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU32 color);
//::38
// +--------------------+
// | llgfx_DrawRect() |
// +--------------------+
void llgfx_DrawRect(
llgfx_id idx,
llgfx_sRECT *dstrect,
TxU32 color);
//::33
// +-------------------------+
// | llgfx_DrawRectAlpha() |
// +-------------------------+
void llgfx_DrawRectAlpha(
llgfx_id idx,
int x1,
int y1,
int x2,
int y2,
TxU8 alpha,
TxU32 color);
//::39
// +-------------------------+
// | llgfx_DrawRectAlpha() |
// +-------------------------+
void llgfx_DrawRectAlpha(
llgfx_id idx,
llgfx_sRECT *dstrect,
TxU8 alpha,
TxU32 color);
//:> +-----------------------------------+
//:>-------------------| Global Function Definitions |--------------------
//:> +-----------------------------------+
//::25
// +------------------+
// | Adddirtyrect() |
// +------------------+
inline void Adddirtyrect(
int x1,
int y1,
int x2,
int y2)
{
llgfx_sRECT re;
if( x1 > x2 )
{
re.x1=x2;
re.x2=x1;
}
else
{
re.x1=x1;
re.x2=x2;
}
if( y1 > y2 )
{
re.y1=y2;
re.y2=y1;
}
else
{
re.y1=y1;
re.y2=y2;
}
re.x2++;
re.y2++;
llgfx_AddDirtyRect(re);
}
//::24
// +--------------------+
// | llgfx_ClipLine() |
// +--------------------+
inline bool llgfx_ClipLine(
int &x1,
int &y1,
int &x2,
int &y2,
int xmin,
int ymin,
int xmax,
int ymax)
{
bool Inside,Outside;
char ocu1,ocu2;
xmax--; ymax--;
#ifndef CLIP_LEFT
#define CLIP_LEFT 0x01
#define CLIP_TOP 0x02
#define CLIP_RIGHT 0x04
#define CLIP_BOTTOM 0x08
#define SetOutCodes(u, x, y) \
if (x < xmin) u = CLIP_LEFT; else u = 0; \
if (y < ymin) u |= CLIP_TOP; \
if (x > xmax) u |= CLIP_RIGHT; \
if (y > ymax) u |= CLIP_BOTTOM;
#endif
#define ISWAP(a,b) { int __tmp__ = a; a = b; b = __tmp__; }
#define CSWAP(a,b) { char __tmp__ = a; a = b; b = __tmp__; }
SetOutCodes (ocu1, x1, y1);
SetOutCodes (ocu2, x2, y2);
Inside = (ocu1 | ocu2) == 0;
Outside = (ocu1 & ocu2) != 0;
while ((!Outside) && (!Inside))
{
if (ocu1 == 0) // swap endpoints if necessary
{ // so that (x1,y1) needs to be clipped
ISWAP (x1, x2);
ISWAP (y1,y2);
CSWAP (ocu1, ocu2);
}
if (ocu1 & CLIP_LEFT) // clip left
{
y1 = y1 + ((y2 - y1) * (xmin - x1)) / (x2 - x1);
x1 = xmin;
}
else if (ocu1 & CLIP_TOP) // clip above
{
x1 = x1 + ((x2 - x1) * (ymin - y1)) / (y2 - y1);
y1 = ymin;
}
else if (ocu1 & CLIP_RIGHT) // clip right
{
y1 = y1 + ((y2 - y1) * (xmax - x1)) / (x2 - x1);
x1 = xmax;
}
else if (ocu1 & CLIP_BOTTOM) // clip below
{
x1 = x1 + ((x2 - x1) * (ymax - y1)) / (y2 - y1);
y1 = ymax;
}
SetOutCodes (ocu1, x1, y1); // update for (x1,y1)
Inside = (ocu1 | ocu2) == 0;
Outside = (ocu1 & ocu2) != 0;
}
return Outside;
}
// +--------------------+
// | llgfx_ClipLine() |
// +--------------------+
void llgfx_DrawFillRect( llgfx_id idx, int x1, int y1, int x2, int y2, TxU32 color );
void llgfx_DrawCircle( llgfx_id dstgfx, int x, int y, int radius, TxU32 color);
void llgfx_DrawCircle( llgfx_id dstgfx, float x, float y, float radius, TxU32 color);
void llgfx_DrawCircleAlpha( llgfx_id dstgfx, int x, int y, int radius, TxU8 alpha, TxU32 color);
void llgfx_DrawCircleAlpha( llgfx_id dstgfx, float x, float y, float radius, TxU8 alpha, TxU32 color);
void llgfx_BeginDrawLines(llgfx_id idx);
void llgfx_BeginDrawLines(llgfx_id idx, TxU32 color);
//void llgfx_AddLine( int x, int y);
//void llgfx_AddLine( int x, int y, TxU32 color);
void llgfx_EndDrawLines();
void llgfx_LineColor(TxU32 color);
#endif // LLGFX_LINES_INCLUDED