- Cleaned up iVis a bit by "commonalizing" it.

- Added a WZ_DEPRECATED macro (lib/framework/macros.h) to mark deprecated functions.
  (See http://websvn.kde.org/trunk/KDE/kdelibs/kdemacros.h.in?view=markup -> KDE_DEPRECATED for usage.)

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@406 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2006-03-18 01:59:59 +00:00
parent 01665a8ed6
commit fe689a39ec
11 changed files with 586 additions and 1900 deletions

View File

@ -38,6 +38,8 @@ FILE *unix_fopen(const char *filename, const char *mode);
#define EnterCriticalSection(x)
#define LeaveCriticalSection(x)
#include "macros.h"
#include "types.h"
#include "debug.h"
#include "mem.h"

7
lib/framework/macros.h Normal file
View File

@ -0,0 +1,7 @@
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))
# define WZ_DEPRECATED __attribute__ ((__deprecated__))
#elif defined(_MSVC_VER) && (_MSC_VER >= 1300)
# define WZ_DEPRECATED __declspec(deprecated)
#else
# define WZ_DEPRECATED
#endif

View File

@ -7,28 +7,16 @@
*/
/***************************************************************************/
#include "ivi.h"
#include "pieclip.h"
#include "frame.h"
#include "piedef.h"
#include "piestate.h"
#include "rendmode.h"
#include "ivi.h"
/***************************************************************************/
/*
* Local Definitions
* Global Variables
*/
/***************************************************************************/
/***************************************************************************/
/*
* Local Variables
*/
/***************************************************************************/
static BOOL bClipSpecular = TRUE;
static UDWORD videoBufferWidth = 640,videoBufferHeight = 480;
extern iSurface *psRendSurface;
/***************************************************************************/
/*
@ -38,62 +26,15 @@ static UDWORD videoBufferWidth = 640,videoBufferHeight = 480;
static int _xtclip_edge2d(iVertex *s1, iVertex *s2, iVertex *clip);
static int _ytclip_edge2d(iVertex *s1, iVertex *s2, iVertex *clip);
static int _xclip_edge2d(iVertex *s1, iVertex *s2, iVertex *clip);
static int _yclip_edge2d(iVertex *s1, iVertex *s2, iVertex *clip);
static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip);
static int pie_ClipYT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip);
/***************************************************************************/
/*
* Source
*/
/***************************************************************************/
BOOL pie_SetVideoBuffer(UDWORD width, UDWORD height)
{
videoBufferWidth = width;
videoBufferHeight = height;
return(TRUE);
}
/***************************************************************************/
UDWORD pie_GetVideoBufferWidth(void)
{
return(videoBufferWidth);
}
/***************************************************************************/
UDWORD pie_GetVideoBufferHeight(void)
{
return(videoBufferHeight);
}
/***************************************************************************/
void pie_Set2DClip(int x0, int y0, int x1, int y1)
{
/* if (pie_GetRenderEngine() == ENGINE_GLIDE)
{
grClipWindow((FxU32)x0,(FxU32)y0,(FxU32)x1,(FxU32)y1);
}
else if (pie_GetRenderEngine() == ENGINE_D3D)
{
D3DSetClipWindow(x0,y0,x1,y1);
}
else
*/
{
psRendSurface->clip.left = x0;
psRendSurface->clip.top = y0;
psRendSurface->clip.right = x1;
psRendSurface->clip.bottom = y1;
}
}
//*************************************************************************
int pie_PolyClipTex2D(int npoints, iVertex *points, iVertex *clip)
{
static iVertex xclip[iV_POLY_MAX_POINTS+4];
iVertex *p0, *p1;
int n1, n, i;
@ -126,128 +67,10 @@ int pie_PolyClipTex2D(int npoints, iVertex *points, iVertex *clip)
}
//*************************************************************************
// New clipper that clips rgb lighting values
int pie_ClipTextured(int npoints, PIEVERTEX *points, PIEVERTEX *clip, BOOL bSpecular)
{
static PIEVERTEX xclip[iV_POLY_MAX_POINTS+4];
PIEVERTEX *p0, *p1;
int n1, n, i;
bClipSpecular = bSpecular;
p0 = &points[0];
p1 = &points[1];
for (i=0, n1=0; i<npoints; i++, p0++, p1++) {
if (i==(npoints-1))
p1 = &points[0];
if ((p0->sx == 1<<15) || (p0->sy == -1<<15))//check for invalid points jps19aug97
return 0;
n1 += pie_ClipXT(p0,p1,&xclip[n1]);
}
p0 = &xclip[0];
p1 = &xclip[1];
for (i=0, n=0; i<n1; p0++, p1++, i++) {
if (i==(n1-1))
p1 = &xclip[0];
n += pie_ClipYT(p0,p1,&clip[n]);
}
return n;
}
//*************************************************************************
/* Alex - much faster tri clipper - won't clip owt else tho' */
int pie_ClipTexturedTriangleFast(PIEVERTEX *v1, PIEVERTEX *v2, PIEVERTEX *v3, PIEVERTEX *clipped, BOOL bSpecular)
{
static PIEVERTEX xClip[iV_POLY_MAX_POINTS+4]; // plus 4 hopefully is limit?
static PIEVERTEX *p0,*p1;
UDWORD numPreY,numAll;
UDWORD i;
bClipSpecular = bSpecular;
numPreY = 0;
if( (v1->sx > LONG_TEST) OR (v1->sy > LONG_TEST) )
{
/* bomb out for out of range points */
return(0);
}
numPreY += pie_ClipXT(v1,v2,&xClip[numPreY]);
if( (v2->sx > LONG_TEST) OR (v2->sy > LONG_TEST) )
{
/* bomb out for out of range points */
return(0);
}
numPreY += pie_ClipXT(v2,v3,&xClip[numPreY]);
if( (v3->sx > LONG_TEST) OR (v3->sy > LONG_TEST) )
{
/* bomb out for out of range points */
return(0);
}
numPreY += pie_ClipXT(v3,v1,&xClip[numPreY]);
/* We've now clipped against x axis - now for Y */
p0 = &xClip[0];
p1 = &xClip[1];
for (i=0, numAll=0; i<numPreY; p0++, p1++, i++) {
if (i==(numPreY-1))
p1 = &xClip[0];
numAll += pie_ClipYT(p0,p1,&clipped[numAll]);
}
return numAll;
}
//*************************************************************************
int iV_PolyClip2D(int npoints, iVertex *points, iVertex *clip)
{
static iVertex xclip[iV_POLY_MAX_POINTS+4];
iVertex *p0, *p1;
int n1, n, i;
p0 = &points[0];
p1 = &points[1];
for (i=0, n1=0; i<npoints; i++, p0++, p1++) {
if (i==(npoints-1))
p1 = &points[0];
n1 += _xclip_edge2d(p0,p1,&xclip[n1]);
}
p0 = &xclip[0];
p1 = &xclip[1];
for (i=0, n=0; i<n1; p0++, p1++, i++) {
if (i==(n1-1))
p1 = &xclip[0];
n += _yclip_edge2d(p0,p1,&clip[n]);
}
return n;
}
/***************************************************************************/
static int _xtclip_edge2d(iVertex *s1, iVertex *s2, iVertex *clip)
{
int n, dx;
int32 t;
@ -363,168 +186,9 @@ static int _xtclip_edge2d(iVertex *s1, iVertex *s2, iVertex *clip)
}
/***************************************************************************/
// New version that clips rgb lighting values
static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
{
int n, dx;
int32 t;
n = 1;
if (s2->sx >= s1->sx) {
if (s1->sx < psRendSurface->clip.left) {
if (s2->sx <= psRendSurface->clip.left) return 0;
dx = s2->sx - s1->sx;
if (dx != 0)
clip->sy = s1->sy + (s2->sy - s1->sy) * (psRendSurface->clip.left - s1->sx) / dx;
else
clip->sy = s1->sy;
clip->sx = psRendSurface->clip.left;
// clip uv
t = ((clip->sx - s1->sx)<<iV_DIVSHIFT) / dx;
clip->tu = s1->tu + ((t * (s2->tu - s1->tu)) >> iV_DIVSHIFT);
clip->tv = s1->tv + ((t * (s2->tv - s1->tv)) >> iV_DIVSHIFT);
clip->sz = s1->sz + ((t * (s2->sz - s1->sz)) >> iV_DIVSHIFT);
clip->light.byte.r = s1->light.byte.r + ((t * (s2->light.byte.r - s1->light.byte.r)) >> iV_DIVSHIFT);
clip->light.byte.g = s1->light.byte.g + ((t * (s2->light.byte.g - s1->light.byte.g)) >> iV_DIVSHIFT);
clip->light.byte.b = s1->light.byte.b + ((t * (s2->light.byte.b - s1->light.byte.b)) >> iV_DIVSHIFT);
clip->light.byte.a = s1->light.byte.a + ((t * (s2->light.byte.a - s1->light.byte.a)) >> iV_DIVSHIFT);
if (bClipSpecular)
{
clip->specular.byte.r = s1->specular.byte.r + ((t * (s2->specular.byte.r - s1->specular.byte.r)) >> iV_DIVSHIFT);
clip->specular.byte.g = s1->specular.byte.g + ((t * (s2->specular.byte.g - s1->specular.byte.g)) >> iV_DIVSHIFT);
clip->specular.byte.b = s1->specular.byte.b + ((t * (s2->specular.byte.b - s1->specular.byte.b)) >> iV_DIVSHIFT);
clip->specular.byte.a = s1->specular.byte.a + ((t * (s2->specular.byte.a - s1->specular.byte.a)) >> iV_DIVSHIFT);
}
} else
*clip = *s1;
if (s2->sx > psRendSurface->clip.right) {
if (s1->sx > psRendSurface->clip.right) return 0;
clip++;
dx = s2->sx - s1->sx;
if (dx != 0)
clip->sy = s2->sy - (s2->sy - s1->sy) * (s2->sx - psRendSurface->clip.right) / dx;
else
clip->sy = s2->sy;
clip->sx = psRendSurface->clip.right;
// clip uv
t = ((clip->sx - s1->sx)<<iV_DIVSHIFT) / dx;
clip->tu = s1->tu + ((t * (s2->tu - s1->tu)) >> iV_DIVSHIFT);
clip->tv = s1->tv + ((t * (s2->tv - s1->tv)) >> iV_DIVSHIFT);
clip->sz = s1->sz + ((t * (s2->sz - s1->sz)) >> iV_DIVSHIFT);
clip->light.byte.r = s1->light.byte.r + ((t * (s2->light.byte.r - s1->light.byte.r)) >> iV_DIVSHIFT);
clip->light.byte.g = s1->light.byte.g + ((t * (s2->light.byte.g - s1->light.byte.g)) >> iV_DIVSHIFT);
clip->light.byte.b = s1->light.byte.b + ((t * (s2->light.byte.b - s1->light.byte.b)) >> iV_DIVSHIFT);
clip->light.byte.a = s1->light.byte.a + ((t * (s2->light.byte.a - s1->light.byte.a)) >> iV_DIVSHIFT);
if (bClipSpecular)
{
clip->specular.byte.r = s1->specular.byte.r + ((t * (s2->specular.byte.r - s1->specular.byte.r)) >> iV_DIVSHIFT);
clip->specular.byte.g = s1->specular.byte.g + ((t * (s2->specular.byte.g - s1->specular.byte.g)) >> iV_DIVSHIFT);
clip->specular.byte.b = s1->specular.byte.b + ((t * (s2->specular.byte.b - s1->specular.byte.b)) >> iV_DIVSHIFT);
clip->specular.byte.a = s1->specular.byte.a + ((t * (s2->specular.byte.a - s1->specular.byte.a)) >> iV_DIVSHIFT);
}
n = 2;
}
return n;
} else {
if (s1->sx > psRendSurface->clip.right) {
if (s2->sx >= psRendSurface->clip.right) return 0;
dx = s1->sx - s2->sx;
if (dx != 0)
clip->sy = s1->sy - (s1->sy - s2->sy) * (s1->sx - psRendSurface->clip.right) / dx;
else
clip->sy = s1->sy;
clip->sx = psRendSurface->clip.right;
// clip uv
t = ((clip->sx - s1->sx)<<iV_DIVSHIFT) / dx;
clip->tu = s1->tu + ((t * (s1->tu - s2->tu)) >> iV_DIVSHIFT);
clip->tv = s1->tv + ((t * (s1->tv - s2->tv)) >> iV_DIVSHIFT);
clip->sz = s1->sz + ((t * (s1->sz - s2->sz)) >> iV_DIVSHIFT);
clip->light.byte.r = s1->light.byte.r + ((t * (s1->light.byte.r - s2->light.byte.r)) >> iV_DIVSHIFT);
clip->light.byte.g = s1->light.byte.g + ((t * (s1->light.byte.g - s2->light.byte.g)) >> iV_DIVSHIFT);
clip->light.byte.b = s1->light.byte.b + ((t * (s1->light.byte.b - s2->light.byte.b)) >> iV_DIVSHIFT);
clip->light.byte.a = s1->light.byte.a + ((t * (s1->light.byte.a - s2->light.byte.a)) >> iV_DIVSHIFT);
if (bClipSpecular)
{
clip->specular.byte.r = s1->specular.byte.r + ((t * (s1->specular.byte.r - s2->specular.byte.r)) >> iV_DIVSHIFT);
clip->specular.byte.g = s1->specular.byte.g + ((t * (s1->specular.byte.g - s2->specular.byte.g)) >> iV_DIVSHIFT);
clip->specular.byte.b = s1->specular.byte.b + ((t * (s1->specular.byte.b - s2->specular.byte.b)) >> iV_DIVSHIFT);
clip->specular.byte.a = s1->specular.byte.a + ((t * (s1->specular.byte.a - s2->specular.byte.a)) >> iV_DIVSHIFT);
}
} else
*clip = *s1;
if (s2->sx < psRendSurface->clip.left) {
if (s1->sx < psRendSurface->clip.left) return 0;
clip++;
dx = s1->sx - s2->sx;
if (dx != 0)
clip->sy = s2->sy + (s1->sy - s2->sy) * (psRendSurface->clip.left - s2->sx) / dx;
else
clip->sy = s2->sy;
clip->sx = psRendSurface->clip.left;
// clip uv
t = ((clip->sx - s1->sx)<<iV_DIVSHIFT) / dx;
clip->tu = s1->tu + ((t * (s1->tu - s2->tu)) >> iV_DIVSHIFT);
clip->tv = s1->tv + ((t * (s1->tv - s2->tv)) >> iV_DIVSHIFT);
clip->sz = s1->sz + ((t * (s1->sz - s2->sz)) >> iV_DIVSHIFT);
clip->light.byte.r = s1->light.byte.r + ((t * (s1->light.byte.r - s2->light.byte.r)) >> iV_DIVSHIFT);
clip->light.byte.g = s1->light.byte.g + ((t * (s1->light.byte.g - s2->light.byte.g)) >> iV_DIVSHIFT);
clip->light.byte.b = s1->light.byte.b + ((t * (s1->light.byte.b - s2->light.byte.b)) >> iV_DIVSHIFT);
clip->light.byte.a = s1->light.byte.a + ((t * (s1->light.byte.a - s2->light.byte.a)) >> iV_DIVSHIFT);
if (bClipSpecular)
{
clip->specular.byte.r = s1->specular.byte.r + ((t * (s1->specular.byte.r - s2->specular.byte.r)) >> iV_DIVSHIFT);
clip->specular.byte.g = s1->specular.byte.g + ((t * (s1->specular.byte.g - s2->specular.byte.g)) >> iV_DIVSHIFT);
clip->specular.byte.b = s1->specular.byte.b + ((t * (s1->specular.byte.b - s2->specular.byte.b)) >> iV_DIVSHIFT);
clip->specular.byte.a = s1->specular.byte.a + ((t * (s1->specular.byte.a - s2->specular.byte.a)) >> iV_DIVSHIFT);
}
n = 2;
}
return n;
}
}
//*************************************************************************
static int _ytclip_edge2d(iVertex *s1, iVertex *s2, iVertex *clip)
{
register int n, dy;
int32 t;
@ -640,350 +304,10 @@ static int _ytclip_edge2d(iVertex *s1, iVertex *s2, iVertex *clip)
return n;
}
}
//*************************************************************************
// New version - clips rgb lighting values
static int pie_ClipYT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
{
register int n, dy;
int32 t;
n = 1;
if (s2->sy >= s1->sy) {
if (s1->sy < psRendSurface->clip.top) {
if (s2->sy <= psRendSurface->clip.top) return 0;
dy = s2->sy - s1->sy;
if (dy != 0)
clip->sx = s1->sx + (s2->sx - s1->sx) * (psRendSurface->clip.top - s1->sy) / dy;
else
clip->sx = s1->sx;
clip->sy = psRendSurface->clip.top;
// clip uv
t = ((clip->sy - s1->sy)<<iV_DIVSHIFT) / dy;
clip->tu = s1->tu + ((t * (s2->tu - s1->tu)) >> iV_DIVSHIFT);
clip->tv = s1->tv + ((t * (s2->tv - s1->tv)) >> iV_DIVSHIFT);
clip->sz = s1->sz + ((t * (s2->sz - s1->sz)) >> iV_DIVSHIFT);
clip->light.byte.r = s1->light.byte.r + ((t * (s2->light.byte.r - s1->light.byte.r)) >> iV_DIVSHIFT);
clip->light.byte.g = s1->light.byte.g + ((t * (s2->light.byte.g - s1->light.byte.g)) >> iV_DIVSHIFT);
clip->light.byte.b = s1->light.byte.b + ((t * (s2->light.byte.b - s1->light.byte.b)) >> iV_DIVSHIFT);
clip->light.byte.a = s1->light.byte.a + ((t * (s2->light.byte.a - s1->light.byte.a)) >> iV_DIVSHIFT);
if (bClipSpecular)
{
clip->specular.byte.r = s1->specular.byte.r + ((t * (s2->specular.byte.r - s1->specular.byte.r)) >> iV_DIVSHIFT);
clip->specular.byte.g = s1->specular.byte.g + ((t * (s2->specular.byte.g - s1->specular.byte.g)) >> iV_DIVSHIFT);
clip->specular.byte.b = s1->specular.byte.b + ((t * (s2->specular.byte.b - s1->specular.byte.b)) >> iV_DIVSHIFT);
clip->specular.byte.a = s1->specular.byte.a + ((t * (s2->specular.byte.a - s1->specular.byte.a)) >> iV_DIVSHIFT);
}
} else
*clip = *s1;
if (s2->sy > psRendSurface->clip.bottom) {
if (s1->sy > psRendSurface->clip.bottom) return 0;
clip++;
dy = s2->sy - s1->sy;
if (dy != 0)
clip->sx = s2->sx - (s2->sx - s1->sx) * (s2->sy - psRendSurface->clip.bottom) / dy;
else
clip->sx = s2->sx;
clip->sy = psRendSurface->clip.bottom;
// clip uv
t = ((clip->sy - s1->sy)<<iV_DIVSHIFT) / dy;
clip->tu = s1->tu + ((t * (s2->tu - s1->tu)) >> iV_DIVSHIFT);
clip->tv = s1->tv + ((t * (s2->tv - s1->tv)) >> iV_DIVSHIFT);
clip->sz = s1->sz + ((t * (s2->sz - s1->sz)) >> iV_DIVSHIFT);
clip->light.byte.r = s1->light.byte.r + ((t * (s2->light.byte.r - s1->light.byte.r)) >> iV_DIVSHIFT);
clip->light.byte.g = s1->light.byte.g + ((t * (s2->light.byte.g - s1->light.byte.g)) >> iV_DIVSHIFT);
clip->light.byte.b = s1->light.byte.b + ((t * (s2->light.byte.b - s1->light.byte.b)) >> iV_DIVSHIFT);
clip->light.byte.a = s1->light.byte.a + ((t * (s2->light.byte.a - s1->light.byte.a)) >> iV_DIVSHIFT);
if (bClipSpecular)
{
clip->specular.byte.r = s1->specular.byte.r + ((t * (s2->specular.byte.r - s1->specular.byte.r)) >> iV_DIVSHIFT);
clip->specular.byte.g = s1->specular.byte.g + ((t * (s2->specular.byte.g - s1->specular.byte.g)) >> iV_DIVSHIFT);
clip->specular.byte.b = s1->specular.byte.b + ((t * (s2->specular.byte.b - s1->specular.byte.b)) >> iV_DIVSHIFT);
clip->specular.byte.a = s1->specular.byte.a + ((t * (s2->specular.byte.a - s1->specular.byte.a)) >> iV_DIVSHIFT);
}
n = 2;
}
return n;
} else {
if (s1->sy > psRendSurface->clip.bottom) {
if (s2->sy >= psRendSurface->clip.bottom) return 0;
dy = s1->sy - s2->sy;
if (dy != 0)
clip->sx = s1->sx - (s1->sx - s2->sx) * (s1->sy - psRendSurface->clip.bottom) / dy;
else
clip->sx = s1->sx;
clip->sy = psRendSurface->clip.bottom;
// clip uv
t = ((clip->sy - s1->sy)<<iV_DIVSHIFT) / dy;
clip->tu = s1->tu + ((t * (s1->tu - s2->tu)) >> iV_DIVSHIFT);
clip->tv = s1->tv + ((t * (s1->tv - s2->tv)) >> iV_DIVSHIFT);
clip->sz = s1->sz + ((t * (s1->sz - s2->sz)) >> iV_DIVSHIFT);
clip->light.byte.r = s1->light.byte.r + ((t * (s1->light.byte.r - s2->light.byte.r)) >> iV_DIVSHIFT);
clip->light.byte.g = s1->light.byte.g + ((t * (s1->light.byte.g - s2->light.byte.g)) >> iV_DIVSHIFT);
clip->light.byte.b = s1->light.byte.b + ((t * (s1->light.byte.b - s2->light.byte.b)) >> iV_DIVSHIFT);
clip->light.byte.a = s1->light.byte.a + ((t * (s1->light.byte.a - s2->light.byte.a)) >> iV_DIVSHIFT);
if (bClipSpecular)
{
clip->specular.byte.r = s1->specular.byte.r + ((t * (s1->specular.byte.r - s2->specular.byte.r)) >> iV_DIVSHIFT);
clip->specular.byte.g = s1->specular.byte.g + ((t * (s1->specular.byte.g - s2->specular.byte.g)) >> iV_DIVSHIFT);
clip->specular.byte.b = s1->specular.byte.b + ((t * (s1->specular.byte.b - s2->specular.byte.b)) >> iV_DIVSHIFT);
clip->specular.byte.a = s1->specular.byte.a + ((t * (s1->specular.byte.a - s2->specular.byte.a)) >> iV_DIVSHIFT);
}
} else
*clip = *s1;
if (s2->sy < psRendSurface->clip.top) {
if (s1->sy < psRendSurface->clip.top) return 0;
clip++;
dy = s1->sy - s2->sy;
if (dy != 0)
clip->sx = s2->sx + (s1->sx - s2->sx) * (psRendSurface->clip.top - s2->sy) / dy;
else
clip->sx = s2->sx;
clip->sy = psRendSurface->clip.top;
// clip uv
t = ((clip->sy - s1->sy)<<iV_DIVSHIFT) / dy;
clip->tu = s1->tu + ((t * (s1->tu - s2->tu)) >> iV_DIVSHIFT);
clip->tv = s1->tv + ((t * (s1->tv - s2->tv)) >> iV_DIVSHIFT);
clip->sz = s1->sz + ((t * (s1->sz - s2->sz)) >> iV_DIVSHIFT);
clip->light.byte.r = s1->light.byte.r + ((t * (s1->light.byte.r - s2->light.byte.r)) >> iV_DIVSHIFT);
clip->light.byte.g = s1->light.byte.g + ((t * (s1->light.byte.g - s2->light.byte.g)) >> iV_DIVSHIFT);
clip->light.byte.b = s1->light.byte.b + ((t * (s1->light.byte.b - s2->light.byte.b)) >> iV_DIVSHIFT);
clip->light.byte.a = s1->light.byte.a + ((t * (s1->light.byte.a - s2->light.byte.a)) >> iV_DIVSHIFT);
if (bClipSpecular)
{
clip->specular.byte.r = s1->specular.byte.r + ((t * (s1->specular.byte.r - s2->specular.byte.r)) >> iV_DIVSHIFT);
clip->specular.byte.g = s1->specular.byte.g + ((t * (s1->specular.byte.g - s2->specular.byte.g)) >> iV_DIVSHIFT);
clip->specular.byte.b = s1->specular.byte.b + ((t * (s1->specular.byte.b - s2->specular.byte.b)) >> iV_DIVSHIFT);
clip->specular.byte.a = s1->specular.byte.a + ((t * (s1->specular.byte.a - s2->specular.byte.a)) >> iV_DIVSHIFT);
}
n = 2;
}
return n;
}
}
static int _xclip_edge2d(iVertex *s1, iVertex *s2, iVertex *clip)
{
int n, dx;
n = 1;
if (s2->x >= s1->x) {
if (s1->x < psRendSurface->clip.left) {
if (s2->x <= psRendSurface->clip.left) return 0;
dx = s2->x - s1->x;
if (dx != 0)
clip->y = s1->y + (s2->y - s1->y) * (psRendSurface->clip.left - s1->x) / dx;
else
clip->y = s1->y;
clip->x = psRendSurface->clip.left;
} else
*clip = *s1;
if (s2->x > psRendSurface->clip.right) {
if (s1->x > psRendSurface->clip.right) return 0;
clip++;
dx = s2->x - s1->x;
if (dx != 0)
clip->y = s2->y - (s2->y - s1->y) * (s2->x - psRendSurface->clip.right) / dx;
else
clip->y = s2->y;
clip->x = psRendSurface->clip.right;
n = 2;
}
return n;
} else {
if (s1->x > psRendSurface->clip.right) {
if (s2->x >= psRendSurface->clip.right) return 0;
dx = s1->x - s2->x;
if (dx != 0)
clip->y = s1->y - (s1->y - s2->y) * (s1->x - psRendSurface->clip.right) / dx;
else
clip->y = s1->y;
clip->x = psRendSurface->clip.right;
} else
*clip = *s1;
if (s2->x < psRendSurface->clip.left) {
if (s1->x < psRendSurface->clip.left) return 0;
clip++;
dx = s1->x - s2->x;
if (dx != 0)
clip->y = s2->y + (s1->y - s2->y) * (psRendSurface->clip.left - s2->x) / dx;
else
clip->y = s2->y;
clip->x = psRendSurface->clip.left;
n = 2;
}
return n;
}
}
//*************************************************************************
static int _yclip_edge2d(iVertex *s1, iVertex *s2, iVertex *clip)
{
register int n, dy;
n = 1;
if (s2->y >= s1->y) {
if (s1->y < psRendSurface->clip.top) {
if (s2->y <= psRendSurface->clip.top) return 0;
dy = s2->y - s1->y;
if (dy != 0)
clip->x = s1->x + (s2->x - s1->x) * (psRendSurface->clip.top - s1->y) / dy;
else
clip->x = s1->x;
clip->y = psRendSurface->clip.top;
} else
*clip = *s1;
if (s2->y > psRendSurface->clip.bottom) {
if (s1->y > psRendSurface->clip.bottom) return 0;
clip++;
dy = s2->y - s1->y;
if (dy != 0)
clip->x = s2->x - (s2->x - s1->x) * (s2->y - psRendSurface->clip.bottom) / dy;
else
clip->x = s2->x;
clip->y = psRendSurface->clip.bottom;
n = 2;
}
return n;
} else {
if (s1->y > psRendSurface->clip.bottom) {
if (s2->y >= psRendSurface->clip.bottom) return 0;
dy = s1->y - s2->y;
if (dy != 0)
clip->x = s1->x - (s1->x - s2->x) * (s1->y - psRendSurface->clip.bottom) / dy;
else
clip->x = s1->x;
clip->y = psRendSurface->clip.bottom;
} else
*clip = *s1;
if (s2->y < psRendSurface->clip.top) {
if (s1->y < psRendSurface->clip.top) return 0;
clip++;
dy = s1->y - s2->y;
if (dy != 0)
clip->x = s2->x + (s1->x - s2->x) * (psRendSurface->clip.top - s2->y) / dy;
else
clip->x = s2->x;
clip->y = psRendSurface->clip.top;
n = 2;
}
return n;
}
}
int pie_ClipFlat2dLine(SDWORD x0, SDWORD y0, SDWORD x1, SDWORD y1)
{
if ((x0 > LONG_TEST) OR (y0 > LONG_TEST) )
{
/* bomb out for out of range points */

View File

@ -7,13 +7,7 @@
*/
/***************************************************************************/
#include "frame.h"
#include "piestate.h"
#include "piedef.h"
#include "tex.h"
/***************************************************************************/
/*
@ -21,197 +15,13 @@
*/
/***************************************************************************/
SDWORD pieStateCount = 0;
BOOL bSwirls = FALSE;
BOOL bWave = FALSE;
/***************************************************************************/
/*
* Local Definitions
*/
/***************************************************************************/
typedef enum COLOUR_MODE
{
COLOUR_FLAT_CONSTANT,
COLOUR_FLAT_ITERATED,
COLOUR_TEX_ITERATED,
COLOUR_TEX_CONSTANT
}
COLOUR_MODE;
typedef enum TEX_MODE
{
TEX_LOCAL,
TEX_NONE
}
TEX_MODE;
typedef enum ALPHA_MODE
{
ALPHA_ITERATED,
ALPHA_CONSTANT
}
ALPHA_MODE;
typedef struct _renderState
{
REND_ENGINE rendEngine;
BOOL bHardware;
DEPTH_MODE depthBuffer;
BOOL translucent;
BOOL additive;
FOG_CAP fogCap;
BOOL fogEnabled;
BOOL fog;
UDWORD fogColour;
TEX_CAP texCap;
SDWORD texPage;
REND_MODE rendMode;
BOOL bilinearOn;
BOOL keyingOn;
COLOUR_MODE colourCombine;
TEX_MODE texCombine;
ALPHA_MODE alphaCombine;
TRANSLUCENCY_MODE transMode;
UDWORD colour;
#ifdef STATES
BOOL textured;
UBYTE lightLevel;
#endif
UBYTE DDrawDriverName[256];
UBYTE D3DDriverName[256];
} RENDER_STATE;
/***************************************************************************/
/*
* Local Variables
*/
/***************************************************************************/
RENDER_STATE rendStates;
/***************************************************************************/
/*
* Local ProtoTypes
*/
/***************************************************************************/
static void pie_SetColourCombine(COLOUR_MODE colCombMode);
static void pie_SetTexCombine(TEX_MODE texCombMode);
static void pie_SetAlphaCombine(ALPHA_MODE alphaCombMode);
static void pie_SetTranslucencyMode(TRANSLUCENCY_MODE transMode);
//static void pie_SetAlphaCombine(BOOL trans);
extern RENDER_STATE rendStates;
/***************************************************************************/
/*
* Source
*/
/***************************************************************************/
void pie_SetDefaultStates(void)//Sets all states
{
// pie_SetFogColour(0x00B08f5f);//nicks colour
//fog off
rendStates.fogEnabled = FALSE;// enable fog before renderer
rendStates.fog = FALSE;//to force reset to false
pie_SetFogStatus(FALSE);
pie_SetFogColour(0x00000000);//nicks colour
//depth Buffer on
rendStates.depthBuffer = FALSE;//to force reset to true
pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
//set render mode
pie_SetTranslucent(TRUE);
pie_SetAdditive(TRUE);
//basic gouraud textured rendering
rendStates.texCombine = TEX_NONE;//to force reset to GOURAUD_TEX
pie_SetTexCombine(TEX_LOCAL);
rendStates.colourCombine = COLOUR_FLAT_CONSTANT;//to force reset to GOURAUD_TEX
pie_SetColourCombine(COLOUR_TEX_ITERATED);
rendStates.alphaCombine = ALPHA_ITERATED;//to force reset to GOURAUD_TEX
pie_SetAlphaCombine(ALPHA_CONSTANT);
rendStates.transMode = TRANS_ALPHA;//to force reset to DECAL
pie_SetTranslucencyMode(TRANS_DECAL);
//chroma keying on black
rendStates.keyingOn = FALSE;//to force reset to true
pie_SetColourKeyedBlack(TRUE);
//bilinear filtering
rendStates.bilinearOn = FALSE;//to force reset to true
pie_SetBilinear(TRUE);
}
/***************************************************************************/
/***************************************************************************/
void pie_ResetStates(void)//Sets all states
{
SDWORD temp;
// pie_SetFogColour(0x00B08f5f);//nicks colour
rendStates.fog = !rendStates.fog;//to force reset
pie_SetFogStatus(!rendStates.fog);
//depth Buffer on
temp = rendStates.depthBuffer;
rendStates.depthBuffer = -1;//to force reset
pie_SetDepthBufferStatus(temp);
//set render mode
// pie_SetTranslucent(TRUE);
// pie_SetAdditive(TRUE);
//basic gouraud textured rendering
temp = rendStates.texCombine;
rendStates.texCombine = -1;//to force reset
pie_SetTexCombine(temp);
temp = rendStates.colourCombine;
rendStates.colourCombine = -1;//to force reset
pie_SetColourCombine(temp);
temp = rendStates.alphaCombine;
rendStates.alphaCombine = -1;//to force reset
pie_SetAlphaCombine(temp);
temp = rendStates.transMode;
rendStates.transMode = -1;//to force reset
pie_SetTranslucencyMode(temp);
//chroma keying on black
temp = rendStates.keyingOn;
rendStates.keyingOn = -1;//to force reset
pie_SetColourKeyedBlack(temp);
//bilinear filtering
temp = rendStates.bilinearOn;
rendStates.bilinearOn = -1;//to force reset
pie_SetBilinear(temp);
}
/***************************************************************************/
/***************************************************************************/
void pie_SetRenderEngine(REND_ENGINE rendEngine)
{
rendStates.rendEngine = rendEngine;
{
rendStates.bHardware = FALSE;
}
}
REND_ENGINE pie_GetRenderEngine(void)
{
return rendStates.rendEngine;
}
BOOL pie_Hardware(void)
{
return rendStates.bHardware;
}
/***************************************************************************/
/***************************************************************************/
void pie_SetDepthBufferStatus(DEPTH_MODE depthMode)
{
@ -223,106 +33,6 @@ void pie_SetDepthBufferStatus(DEPTH_MODE depthMode)
#endif
}
//***************************************************************************
//
// pie_SetTranslucent(BOOL val);
//
// Global enable/disable Translucent effects
//
//***************************************************************************
void pie_SetTranslucent(BOOL val)
{
rendStates.translucent = val;
}
BOOL pie_Translucent(void)
{
return rendStates.translucent;
}
//***************************************************************************
//
// pie_SetAdditive(BOOL val);
//
// Global enable/disable Additive effects
//
//***************************************************************************
void pie_SetAdditive(BOOL val)
{
rendStates.additive = val;
}
BOOL pie_Additive(void)
{
return rendStates.additive;
}
//***************************************************************************
//
// pie_SetCaps(BOOL val);
//
// HIGHEST LEVEL enable/disable modes
//
//***************************************************************************
void pie_SetFogCap(FOG_CAP val)
{
rendStates.fogCap = val;
}
FOG_CAP pie_GetFogCap(void)
{
return rendStates.fogCap;
}
void pie_SetTexCap(TEX_CAP val)
{
rendStates.texCap = val;
}
TEX_CAP pie_GetTexCap(void)
{
return rendStates.texCap;
}
//***************************************************************************
//
// pie_EnableFog(BOOL val)
//
// Global enable/disable fog to allow fog to be turned of ingame
//
//***************************************************************************
void pie_EnableFog(BOOL val)
{
if (rendStates.fogCap == FOG_CAP_NO)
{
val = FALSE;
}
if (rendStates.fogEnabled != val)
{
rendStates.fogEnabled = val;
if (val == TRUE)
{
// pie_SetFogColour(0x0078684f);//(nicks colour + 404040)/2
pie_SetFogColour(0x00B08f5f);//nicks colour
}
else
{
pie_SetFogColour(0x00000000);//clear background to black
}
}
}
BOOL pie_GetFogEnabled(void)
{
return rendStates.fogEnabled;
}
//***************************************************************************
//
// pie_SetFogStatus(BOOL val)
@ -353,130 +63,10 @@ void pie_SetFogStatus(BOOL val)
}
}
BOOL pie_GetFogStatus(void)
{
return rendStates.fog;
}
/***************************************************************************/
void pie_SetFogColour(UDWORD colour)
{
UDWORD grey;
if (rendStates.fogCap == FOG_CAP_GREY)
{
grey = colour & 0xff;
colour >>= 8;
grey += (colour & 0xff);
colour >>= 8;
grey += (colour & 0xff);
grey /= 3;
grey &= 0xff;//check only
colour = grey + (grey<<8) + (grey<<16);
rendStates.fogColour = colour;
}
else if (rendStates.fogCap == FOG_CAP_NO)
{
rendStates.fogColour = 0;
}
else
{
rendStates.fogColour = colour;
}
}
UDWORD pie_GetFogColour(void)
{
return rendStates.fogColour;
}
void pie_SetTexturePage(SDWORD num)
WZ_DEPRECATED void pie_SetTexturePage(SDWORD num)
{
}
/***************************************************************************/
void pie_SetRendMode(REND_MODE rendMode)
{
if (rendMode != rendStates.rendMode)
{
rendStates.rendMode = rendMode;
switch (rendMode)
{
case REND_GOURAUD_TEX:
pie_SetColourCombine(COLOUR_TEX_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_DECAL);
break;
case REND_ALPHA_TEX:
pie_SetColourCombine(COLOUR_TEX_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_ADDITIVE_TEX:
pie_SetColourCombine(COLOUR_TEX_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ADDITIVE);
break;
case REND_TEXT:
pie_SetColourCombine(COLOUR_TEX_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_DECAL);
break;
case REND_ALPHA_TEXT:
pie_SetColourCombine(COLOUR_TEX_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_ALPHA_FLAT:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_ALPHA_ITERATED:
pie_SetColourCombine(COLOUR_FLAT_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ADDITIVE);
break;
case REND_FILTER_FLAT:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_FILTER);
break;
case REND_FILTER_ITERATED:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_FLAT:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_DECAL);
default:
break;
}
}
return;
}
/*
BOOL pie_GetTranslucent(void)
{
if (rendStates.transMode == TRANS_DECAL)
{
return FALSE;
}
return TRUE;
}
*/
/***************************************************************************/
void pie_SetColourKeyedBlack(BOOL keyingOn)
@ -491,33 +81,11 @@ void pie_SetColourKeyedBlack(BOOL keyingOn)
}
/***************************************************************************/
void pie_SetBilinear(BOOL bilinearOn)
{
#ifndef PIETOOL
if (bilinearOn != rendStates.bilinearOn)
{
rendStates.bilinearOn = bilinearOn;
pieStateCount++;
}
#endif
}
BOOL pie_GetBilinear(void)
{
#ifndef PIETOOL
return rendStates.bilinearOn;
#else
return FALSE;
#endif
}
/***************************************************************************/
static void pie_SetColourCombine(COLOUR_MODE colCombMode)
void pie_SetColourCombine(COLOUR_MODE colCombMode)
{
#ifndef PIETOOL //ffs
if (colCombMode != rendStates.colourCombine)
{
if (colCombMode != rendStates.colourCombine) {
rendStates.colourCombine = colCombMode;
pieStateCount++;
}
@ -525,40 +93,7 @@ static void pie_SetColourCombine(COLOUR_MODE colCombMode)
}
/***************************************************************************/
static void pie_SetTexCombine(TEX_MODE texCombMode)
{
#ifndef PIETOOL //ffs
if (texCombMode != rendStates.texCombine)
{
rendStates.texCombine = texCombMode;
pieStateCount++;
switch (texCombMode)
{
case TEX_LOCAL:
case TEX_NONE:
default:
break;
}
}
#endif
}
/***************************************************************************/
static void pie_SetAlphaCombine(ALPHA_MODE alphaCombMode)
{
#ifndef PIETOOL //ffs
if (alphaCombMode != rendStates.alphaCombine)
{
rendStates.alphaCombine = alphaCombMode;
pieStateCount++;
}
#endif
}
/***************************************************************************/
static void pie_SetTranslucencyMode(TRANSLUCENCY_MODE transMode)
void pie_SetTranslucencyMode(TRANSLUCENCY_MODE transMode)
{
#ifndef PIETOOL
if (transMode != rendStates.transMode)
@ -582,71 +117,8 @@ void pie_SetColour(UDWORD colour)
}
}
/***************************************************************************/
// get the constant colour used in text and flat render modes
/***************************************************************************/
UDWORD pie_GetColour(void)
{
return rendStates.colour;
}
/***************************************************************************/
void pie_SetGammaValue(float val)
{
pieStateCount++;
}
/***************************************************************************/
void pie_DrawMouse(SDWORD x,SDWORD y)
{
}
/***************************************************************************/
UWORD presentMouseID;
void pie_SetMouse(IMAGEFILE *psImageFile,UWORD ImageID)
{
presentMouseID = ImageID;
}
/***************************************************************************/
UDWORD pie_GetMouseID( void )
{
return(presentMouseID);
}
/***************************************************************************/
BOOL pie_SwirlyBoxes( void )
{
return(bSwirls);
}
void pie_SetSwirlyBoxes( BOOL val )
{
bSwirls = val;
}
BOOL pie_WaveBlit( void )
{
return(bWave);
}
void pie_SetWaveBlit( BOOL val )
{
bWave = val;
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/

View File

@ -19,11 +19,13 @@ libivis_common_a_SOURCES = \
ivispatch.h \
pieblitfunc.h \
pieclip.h \
pieclip.c \
piedef.h \
piefunc.h \
piemode.h \
piepalette.h \
piestate.h \
piestate.c \
pietypes.h \
rendfunc.h \
rendmode.h \

View File

@ -1,65 +1,26 @@
/***************************************************************************/
/*
* pieClip.c
*
* clipping routines for all render modes
*
*/
/***************************************************************************/
#include "frame.h"
#include "ivi.h"
#include "pieclip.h"
#include "piedef.h"
#include "piestate.h"
#include "rendmode.h"
/***************************************************************************/
/*
* Local Definitions
*/
/***************************************************************************/
/***************************************************************************/
/*
* Local Variables
*/
/***************************************************************************/
#include "ivi.h"
static BOOL bClipSpecular = TRUE;
static UDWORD videoBufferWidth = 640,videoBufferHeight = 480;
static UDWORD videoBufferWidth = 640, videoBufferHeight = 480;
extern iSurface *psRendSurface;
/***************************************************************************/
/*
* Local ProtoTypes
*/
/***************************************************************************/
static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip);
static int pie_ClipYT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip);
/***************************************************************************/
/*
* Source
*/
/***************************************************************************/
BOOL pie_SetVideoBuffer(UDWORD width, UDWORD height)
{
videoBufferWidth = width;
videoBufferHeight = height;
return(TRUE);
}
/***************************************************************************/
UDWORD pie_GetVideoBufferWidth(void)
{
return(videoBufferWidth);
}
/***************************************************************************/
UDWORD pie_GetVideoBufferHeight(void)
{
return(videoBufferHeight);
}
/***************************************************************************/
void pie_Set2DClip(int x0, int y0, int x1, int y1)
{
@ -69,47 +30,7 @@ void pie_Set2DClip(int x0, int y0, int x1, int y1)
psRendSurface->clip.bottom = y1;
}
//*************************************************************************
// New clipper that clips rgb lighting values
int pie_ClipTextured(int npoints, PIEVERTEX *points, PIEVERTEX *clip, BOOL bSpecular)
{
static PIEVERTEX xclip[iV_POLY_MAX_POINTS+4];
PIEVERTEX *p0, *p1;
int n1, n, i;
bClipSpecular = bSpecular;
p0 = &points[0];
p1 = &points[1];
for (i=0, n1=0; i<npoints; i++, p0++, p1++) {
if (i==(npoints-1))
p1 = &points[0];
if ((p0->sx == 1<<15) || (p0->sy == -1<<15))//check for invalid points jps19aug97
return 0;
n1 += pie_ClipXT(p0,p1,&xclip[n1]);
}
p0 = &xclip[0];
p1 = &xclip[1];
for (i=0, n=0; i<n1; p0++, p1++, i++) {
if (i==(n1-1))
p1 = &xclip[0];
n += pie_ClipYT(p0,p1,&clip[n]);
}
return n;
}
/***************************************************************************/
// New version that clips rgb lighting values
static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
{
int n, dx;
int32 t;
@ -118,8 +39,8 @@ static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
if (s2->sx >= s1->sx) {
if (s1->sx < psRendSurface->clip.left) {
if (s2->sx <= psRendSurface->clip.left) return 0;
if (s2->sx <= psRendSurface->clip.left)
return 0;
dx = s2->sx - s1->sx;
@ -152,11 +73,10 @@ static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
*clip = *s1;
if (s2->sx > psRendSurface->clip.right) {
if (s1->sx > psRendSurface->clip.right) return 0;
if (s1->sx > psRendSurface->clip.right)
return 0;
clip++;
dx = s2->sx - s1->sx;
if (dx != 0)
@ -175,8 +95,7 @@ static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
clip->light.byte.g = s1->light.byte.g + ((t * (s2->light.byte.g - s1->light.byte.g)) >> iV_DIVSHIFT);
clip->light.byte.b = s1->light.byte.b + ((t * (s2->light.byte.b - s1->light.byte.b)) >> iV_DIVSHIFT);
clip->light.byte.a = s1->light.byte.a + ((t * (s2->light.byte.a - s1->light.byte.a)) >> iV_DIVSHIFT);
if (bClipSpecular)
{
if (bClipSpecular) {
clip->specular.byte.r = s1->specular.byte.r + ((t * (s2->specular.byte.r - s1->specular.byte.r)) >> iV_DIVSHIFT);
clip->specular.byte.g = s1->specular.byte.g + ((t * (s2->specular.byte.g - s1->specular.byte.g)) >> iV_DIVSHIFT);
clip->specular.byte.b = s1->specular.byte.b + ((t * (s2->specular.byte.b - s1->specular.byte.b)) >> iV_DIVSHIFT);
@ -185,7 +104,6 @@ static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
n = 2;
}
return n;
} else {
@ -225,11 +143,10 @@ static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
if (s2->sx < psRendSurface->clip.left) {
if (s1->sx < psRendSurface->clip.left) return 0;
if (s1->sx < psRendSurface->clip.left)
return 0;
clip++;
dx = s1->sx - s2->sx;
if (dx != 0)
@ -256,21 +173,17 @@ static int pie_ClipXT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
clip->specular.byte.a = s1->specular.byte.a + ((t * (s1->specular.byte.a - s2->specular.byte.a)) >> iV_DIVSHIFT);
}
n = 2;
}
return n;
}
}
//*************************************************************************
// New version - clips rgb lighting values
static int pie_ClipYT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
{
int n, dy;
int32 t;
n = 1;
if (s2->sy >= s1->sy) {
@ -423,3 +336,83 @@ static int pie_ClipYT(PIEVERTEX *s1, PIEVERTEX *s2, PIEVERTEX *clip)
}
}
int pie_ClipTextured(int npoints, PIEVERTEX *points, PIEVERTEX *clip, BOOL bSpecular)
{
static PIEVERTEX xclip[iV_POLY_MAX_POINTS+4];
PIEVERTEX *p0, *p1;
int n1, n, i;
bClipSpecular = bSpecular;
p0 = &points[0];
p1 = &points[1];
for (i=0, n1=0; i<npoints; i++, p0++, p1++) {
if (i==(npoints-1))
p1 = &points[0];
if ((p0->sx == 1<<15) || (p0->sy == -1<<15))//check for invalid points jps19aug97
return 0;
n1 += pie_ClipXT(p0,p1,&xclip[n1]);
}
p0 = &xclip[0];
p1 = &xclip[1];
for (i=0, n=0; i<n1; p0++, p1++, i++) {
if (i==(n1-1))
p1 = &xclip[0];
n += pie_ClipYT(p0,p1,&clip[n]);
}
return n;
}
//*************************************************************************
/* Alex - much faster tri clipper - won't clip owt else tho' */
int pie_ClipTexturedTriangleFast(PIEVERTEX *v1, PIEVERTEX *v2, PIEVERTEX *v3, PIEVERTEX *clipped, BOOL bSpecular)
{
static PIEVERTEX xClip[iV_POLY_MAX_POINTS+4]; // plus 4 hopefully is limit?
static PIEVERTEX *p0,*p1;
UDWORD numPreY,numAll;
UDWORD i;
bClipSpecular = bSpecular;
numPreY = 0;
if( (v1->sx > LONG_TEST) OR (v1->sy > LONG_TEST) )
{
/* bomb out for out of range points */
return(0);
}
numPreY += pie_ClipXT(v1,v2,&xClip[numPreY]);
if( (v2->sx > LONG_TEST) OR (v2->sy > LONG_TEST) )
{
/* bomb out for out of range points */
return(0);
}
numPreY += pie_ClipXT(v2,v3,&xClip[numPreY]);
if( (v3->sx > LONG_TEST) OR (v3->sy > LONG_TEST) )
{
/* bomb out for out of range points */
return(0);
}
numPreY += pie_ClipXT(v3,v1,&xClip[numPreY]);
/* We've now clipped against x axis - now for Y */
p0 = &xClip[0];
p1 = &xClip[1];
for (i=0, numAll=0; i<numPreY; p0++, p1++, i++) {
if (i==(numPreY-1))
p1 = &xClip[0];
numAll += pie_ClipYT(p0,p1,&clipped[numAll]);
}
return numAll;
}

View File

@ -24,25 +24,16 @@
#define CLIP_BORDER 0
/***************************************************************************/
/*
* Global Variables
*/
/***************************************************************************/
/***************************************************************************/
/*
* Global ProtoTypes
*/
/***************************************************************************/
extern void pie_Set2DClip(int x0, int y0, int x1, int y1);
extern int pie_PolyClipTex2D(int npoints, iVertex *points, iVertex *clip);
extern int pie_PolyClip2D(int npoints, iVertex *points, iVertex *clip);
extern int pie_ClipTextured(int npoints, PIEVERTEX *points, PIEVERTEX *clip, BOOL bSpecular);
extern int pie_ClipTexturedTriangleFast(PIEVERTEX *v1, PIEVERTEX *v2, PIEVERTEX *v3, PIEVERTEX *clipped, BOOL bSpecular);
extern int pie_ClipFlat2dLine(SDWORD x0, SDWORD y0, SDWORD x1, SDWORD y1);
extern BOOL pie_SetVideoBuffer(UDWORD width, UDWORD height);
extern UDWORD pie_GetVideoBufferWidth( void );
extern UDWORD pie_GetVideoBufferHeight( void );
void pie_Set2DClip(int x0, int y0, int x1, int y1);
int pie_ClipTextured(int npoints, PIEVERTEX *points, PIEVERTEX *clip, BOOL bSpecular);
int pie_ClipTexturedTriangleFast(PIEVERTEX *v1, PIEVERTEX *v2, PIEVERTEX *v3, PIEVERTEX *clipped, BOOL bSpecular);
BOOL pie_SetVideoBuffer(UDWORD width, UDWORD height);
UDWORD pie_GetVideoBufferWidth( void );
UDWORD pie_GetVideoBufferHeight( void );
#endif // _pieclip_h

337
lib/ivis_common/piestate.c Normal file
View File

@ -0,0 +1,337 @@
#include "piestate.h"
SDWORD pieStateCount = 0; // FIXME Is this really used somewhere? Or is it just a dummy?
RENDER_STATE rendStates;
void pie_SetColourCombine(COLOUR_MODE colCombMode);
void pie_SetTranslucencyMode(TRANSLUCENCY_MODE transMode);
static void pie_SetTexCombine(TEX_MODE texCombMode);
static void pie_SetAlphaCombine(ALPHA_MODE alphaCombMode);
void pie_SetDefaultStates(void)//Sets all states
{
// pie_SetFogColour(0x00B08f5f);//nicks colour
//fog off
rendStates.fogEnabled = FALSE;// enable fog before renderer
rendStates.fog = FALSE;//to force reset to false
pie_SetFogStatus(FALSE);
pie_SetFogColour(0x00000000);//nicks colour
//depth Buffer on
rendStates.depthBuffer = FALSE;//to force reset to true
pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
//set render mode
pie_SetTranslucent(TRUE);
pie_SetAdditive(TRUE);
//basic gouraud textured rendering
rendStates.texCombine = TEX_NONE;//to force reset to GOURAUD_TEX
pie_SetTexCombine(TEX_LOCAL);
rendStates.colourCombine = COLOUR_FLAT_CONSTANT;//to force reset to GOURAUD_TEX
pie_SetColourCombine(COLOUR_TEX_ITERATED);
rendStates.alphaCombine = ALPHA_ITERATED;//to force reset to GOURAUD_TEX
pie_SetAlphaCombine(ALPHA_CONSTANT);
rendStates.transMode = TRANS_ALPHA;//to force reset to DECAL
pie_SetTranslucencyMode(TRANS_DECAL);
//chroma keying on black
rendStates.keyingOn = FALSE;//to force reset to true
pie_SetColourKeyedBlack(TRUE);
//bilinear filtering
rendStates.bilinearOn = FALSE;//to force reset to true
pie_SetBilinear(TRUE);
}
void pie_SetRenderEngine(REND_ENGINE rendEngine)
{
rendStates.rendEngine = rendEngine;
if( rendEngine == ENGINE_4101 )
rendStates.bHardware = FALSE;
else
rendStates.bHardware = TRUE;
}
REND_ENGINE pie_GetRenderEngine(void)
{
return rendStates.rendEngine;
}
BOOL pie_Hardware(void)
{
return rendStates.bHardware;
}
//***************************************************************************
//
// pie_SetTranslucent(BOOL val);
//
// Global enable/disable Translucent effects
//
//***************************************************************************
void pie_SetTranslucent(BOOL val)
{
rendStates.translucent = val;
}
BOOL pie_Translucent(void)
{
return rendStates.translucent;
}
//***************************************************************************
//
// pie_SetAdditive(BOOL val);
//
// Global enable/disable Additive effects
//
//***************************************************************************
void pie_SetAdditive(BOOL val)
{
rendStates.additive = val;
}
BOOL pie_Additive(void)
{
return rendStates.additive;
}
//***************************************************************************
//
// pie_SetCaps(BOOL val);
//
// HIGHEST LEVEL enable/disable modes
//
//***************************************************************************
void pie_SetFogCap(FOG_CAP val)
{
rendStates.fogCap = val;
}
FOG_CAP pie_GetFogCap(void)
{
return rendStates.fogCap;
}
void pie_SetTexCap(TEX_CAP val)
{
rendStates.texCap = val;
}
TEX_CAP pie_GetTexCap(void)
{
return rendStates.texCap;
}
//***************************************************************************
//
// pie_EnableFog(BOOL val)
//
// Global enable/disable fog to allow fog to be turned of ingame
//
//***************************************************************************
void pie_EnableFog(BOOL val)
{
if (rendStates.fogCap == FOG_CAP_NO)
{
val = FALSE;
}
if (rendStates.fogEnabled != val)
{
rendStates.fogEnabled = val;
if (val == TRUE)
{
// pie_SetFogColour(0x0078684f);//(nicks colour + 404040)/2
pie_SetFogColour(0x00B08f5f);//nicks colour
}
else
{
pie_SetFogColour(0x00000000);//clear background to black
}
}
}
BOOL pie_GetFogEnabled(void)
{
return rendStates.fogEnabled;
}
//***************************************************************************
//
// pie_SetFogStatus(BOOL val)
//
// Toggle fog on and off for rendering objects inside or outside the 3D world
//
//***************************************************************************
BOOL pie_GetFogStatus(void)
{
return rendStates.fog;
}
void pie_SetFogColour(UDWORD colour)
{
UDWORD grey;
if (rendStates.fogCap == FOG_CAP_GREY)
{
grey = colour & 0xff;
colour >>= 8;
grey += (colour & 0xff);
colour >>= 8;
grey += (colour & 0xff);
grey /= 3;
grey &= 0xff;//check only
colour = grey + (grey<<8) + (grey<<16);
rendStates.fogColour = colour;
}
else if (rendStates.fogCap == FOG_CAP_NO)
{
rendStates.fogColour = 0;
}
else
{
rendStates.fogColour = colour;
}
}
UDWORD pie_GetFogColour(void)
{
return rendStates.fogColour;
}
void pie_SetRendMode(REND_MODE rendMode)
{
if (rendMode != rendStates.rendMode)
{
rendStates.rendMode = rendMode;
switch (rendMode)
{
case REND_GOURAUD_TEX:
pie_SetColourCombine(COLOUR_TEX_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_DECAL);
break;
case REND_ALPHA_TEX:
pie_SetColourCombine(COLOUR_TEX_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_ADDITIVE_TEX:
pie_SetColourCombine(COLOUR_TEX_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ADDITIVE);
break;
case REND_TEXT:
pie_SetColourCombine(COLOUR_TEX_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_DECAL);
break;
case REND_ALPHA_TEXT:
pie_SetColourCombine(COLOUR_TEX_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_ALPHA_FLAT:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_ALPHA_ITERATED:
pie_SetColourCombine(COLOUR_FLAT_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ADDITIVE);
break;
case REND_FILTER_FLAT:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_FILTER);
break;
case REND_FILTER_ITERATED:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_FLAT:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_DECAL);
default:
break;
}
}
return;
}
void pie_SetBilinear(BOOL bilinearOn)
{
#ifndef PIETOOL
if (bilinearOn != rendStates.bilinearOn)
{
rendStates.bilinearOn = bilinearOn;
pieStateCount++;
}
#endif
}
BOOL pie_GetBilinear(void)
{
#ifndef PIETOOL
return rendStates.bilinearOn;
#else
return FALSE;
#endif
}
static void pie_SetTexCombine(TEX_MODE texCombMode)
{
#ifndef PIETOOL //ffs
if (texCombMode != rendStates.texCombine)
{
rendStates.texCombine = texCombMode;
pieStateCount++;
}
#endif
}
static void pie_SetAlphaCombine(ALPHA_MODE alphaCombMode)
{
#ifndef PIETOOL //ffs
if (alphaCombMode != rendStates.alphaCombine)
{
rendStates.alphaCombine = alphaCombMode;
pieStateCount++;
}
#endif
}
/***************************************************************************/
// get the constant colour used in text and flat render modes
/***************************************************************************/
UDWORD pie_GetColour(void)
{
return rendStates.colour;
}
WZ_DEPRECATED void pie_SetMouse(IMAGEFILE *psImageFile,UWORD ImageID)
{
}
WZ_DEPRECATED void pie_SetSwirlyBoxes( BOOL val )
{
}

View File

@ -82,6 +82,61 @@ typedef enum TEX_CAP
}
TEX_CAP;
typedef enum COLOUR_MODE
{
COLOUR_FLAT_CONSTANT,
COLOUR_FLAT_ITERATED,
COLOUR_TEX_ITERATED,
COLOUR_TEX_CONSTANT
}
COLOUR_MODE;
typedef enum TEX_MODE
{
TEX_LOCAL,
TEX_NONE
}
TEX_MODE;
typedef enum ALPHA_MODE
{
ALPHA_ITERATED,
ALPHA_CONSTANT
}
ALPHA_MODE;
typedef struct RENDER_STATE
{
REND_ENGINE rendEngine;
BOOL bHardware;
DEPTH_MODE depthBuffer;
BOOL translucent;
BOOL additive;
FOG_CAP fogCap;
BOOL fogEnabled;
BOOL fog;
UDWORD fogColour;
TEX_CAP texCap;
SDWORD texPage;
REND_MODE rendMode;
BOOL bilinearOn;
BOOL keyingOn;
COLOUR_MODE colourCombine;
TEX_MODE texCombine;
ALPHA_MODE alphaCombine;
TRANSLUCENCY_MODE transMode;
UDWORD colour;
#ifdef STATES
BOOL textured;
UBYTE lightLevel;
#endif
// FIXME Needed???
// UBYTE DDrawDriverName[256];
// UBYTE D3DDriverName[256];
}
RENDER_STATE;
#define NO_TEXPAGE -1
/***************************************************************************/
@ -130,13 +185,7 @@ extern void pie_SetRendMode(REND_MODE rendMode);
extern void pie_SetColour(UDWORD val);
extern UDWORD pie_GetColour(void);
//mouse states
extern void pie_DrawMouse(SDWORD x, SDWORD y);
extern void pie_SetMouse(IMAGEFILE *ImageFile,UWORD ImageID);
extern UDWORD pie_GetMouseID( void );
extern BOOL pie_SwirlyBoxes( void );
extern void pie_SetSwirlyBoxes( BOOL val );
extern BOOL pie_WaveBlit( void );
extern void pie_SetWaveBlit( BOOL val );
void pie_ResetStates(void);//Sets all states
#endif // _pieState_h

View File

@ -5,7 +5,6 @@ libivis_opengl_a_SOURCES = \
bspimd.c \
ivi.c \
pieblitfunc.c \
pieclip.c \
piedraw.c \
piefunc.c \
piematrix.c \

View File

@ -24,193 +24,13 @@
*/
/***************************************************************************/
SDWORD pieStateCount = 0;
BOOL bSwirls = FALSE;
BOOL bWave = FALSE;
/***************************************************************************/
/*
* Local Definitions
*/
/***************************************************************************/
typedef enum COLOUR_MODE
{
COLOUR_FLAT_CONSTANT,
COLOUR_FLAT_ITERATED,
COLOUR_TEX_ITERATED,
COLOUR_TEX_CONSTANT
}
COLOUR_MODE;
typedef enum TEX_MODE
{
TEX_LOCAL,
TEX_NONE
}
TEX_MODE;
typedef enum ALPHA_MODE
{
ALPHA_ITERATED,
ALPHA_CONSTANT
}
ALPHA_MODE;
typedef struct _renderState
{
REND_ENGINE rendEngine;
BOOL bHardware;
DEPTH_MODE depthBuffer;
BOOL translucent;
BOOL additive;
FOG_CAP fogCap;
BOOL fogEnabled;
BOOL fog;
UDWORD fogColour;
TEX_CAP texCap;
SDWORD texPage;
REND_MODE rendMode;
BOOL bilinearOn;
BOOL keyingOn;
COLOUR_MODE colourCombine;
TEX_MODE texCombine;
ALPHA_MODE alphaCombine;
TRANSLUCENCY_MODE transMode;
UDWORD colour;
#ifdef STATES
BOOL textured;
UBYTE lightLevel;
#endif
UBYTE DDrawDriverName[256];
UBYTE D3DDriverName[256];
} RENDER_STATE;
/***************************************************************************/
/*
* Local Variables
*/
/***************************************************************************/
RENDER_STATE rendStates;
/***************************************************************************/
/*
* Local ProtoTypes
*/
/***************************************************************************/
static void pie_SetColourCombine(COLOUR_MODE colCombMode);
static void pie_SetTexCombine(TEX_MODE texCombMode);
static void pie_SetAlphaCombine(ALPHA_MODE alphaCombMode);
static void pie_SetTranslucencyMode(TRANSLUCENCY_MODE transMode);
//static void pie_SetAlphaCombine(BOOL trans);
extern RENDER_STATE rendStates;
/***************************************************************************/
/*
* Source
*/
/***************************************************************************/
void pie_SetDefaultStates(void)//Sets all states
{
// pie_SetFogColour(0x00B08f5f);//nicks colour
//fog off
rendStates.fogEnabled = FALSE;// enable fog before renderer
rendStates.fog = FALSE;//to force reset to false
pie_SetFogStatus(FALSE);
pie_SetFogColour(0x00000000);//nicks colour
//depth Buffer on
rendStates.depthBuffer = FALSE;//to force reset to true
pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
//set render mode
pie_SetTranslucent(TRUE);
pie_SetAdditive(TRUE);
//basic gouraud textured rendering
rendStates.texCombine = TEX_NONE;//to force reset to GOURAUD_TEX
pie_SetTexCombine(TEX_LOCAL);
rendStates.colourCombine = COLOUR_FLAT_CONSTANT;//to force reset to GOURAUD_TEX
pie_SetColourCombine(COLOUR_TEX_ITERATED);
rendStates.alphaCombine = ALPHA_ITERATED;//to force reset to GOURAUD_TEX
pie_SetAlphaCombine(ALPHA_CONSTANT);
rendStates.transMode = TRANS_ALPHA;//to force reset to DECAL
pie_SetTranslucencyMode(TRANS_DECAL);
//chroma keying on black
rendStates.keyingOn = FALSE;//to force reset to true
pie_SetColourKeyedBlack(TRUE);
//bilinear filtering
rendStates.bilinearOn = FALSE;//to force reset to true
pie_SetBilinear(TRUE);
}
/***************************************************************************/
/***************************************************************************/
void pie_ResetStates(void)//Sets all states
{
SDWORD temp;
// pie_SetFogColour(0x00B08f5f);//nicks colour
rendStates.fog = !rendStates.fog;//to force reset
pie_SetFogStatus(!rendStates.fog);
//depth Buffer on
temp = rendStates.depthBuffer;
rendStates.depthBuffer = -1;//to force reset
pie_SetDepthBufferStatus(temp);
//set render mode
// pie_SetTranslucent(TRUE);
// pie_SetAdditive(TRUE);
//basic gouraud textured rendering
temp = rendStates.texCombine;
rendStates.texCombine = -1;//to force reset
pie_SetTexCombine(temp);
temp = rendStates.colourCombine;
rendStates.colourCombine = -1;//to force reset
pie_SetColourCombine(temp);
temp = rendStates.alphaCombine;
rendStates.alphaCombine = -1;//to force reset
pie_SetAlphaCombine(temp);
temp = rendStates.transMode;
rendStates.transMode = -1;//to force reset
pie_SetTranslucencyMode(temp);
//chroma keying on black
temp = rendStates.keyingOn;
rendStates.keyingOn = -1;//to force reset
pie_SetColourKeyedBlack(temp);
//bilinear filtering
temp = rendStates.bilinearOn;
rendStates.bilinearOn = -1;//to force reset
pie_SetBilinear(temp);
}
/***************************************************************************/
/***************************************************************************/
void pie_SetRenderEngine(REND_ENGINE rendEngine) {
// printf("renderstate is (old)%d (new)%d\n",rendStates.rendEngine,rendEngine); //Quick check to see what we using. -Q
rendStates.rendEngine = rendEngine;
}
REND_ENGINE pie_GetRenderEngine(void) {
// printf("renderstate is :%d\n",rendStates.rendEngine); //Quick check to see what we are using -Q
return rendStates.rendEngine;
}
BOOL pie_Hardware(void) {
return TRUE;
}
/***************************************************************************/
/***************************************************************************/
void pie_SetDepthBufferStatus(DEPTH_MODE depthMode) {
switch(depthMode) {
@ -235,106 +55,6 @@ void pie_SetDepthBufferStatus(DEPTH_MODE depthMode) {
}
}
//***************************************************************************
//
// pie_SetTranslucent(BOOL val);
//
// Global enable/disable Translucent effects
//
//***************************************************************************
void pie_SetTranslucent(BOOL val)
{
rendStates.translucent = val;
}
BOOL pie_Translucent(void)
{
return rendStates.translucent;
}
//***************************************************************************
//
// pie_SetAdditive(BOOL val);
//
// Global enable/disable Additive effects
//
//***************************************************************************
void pie_SetAdditive(BOOL val)
{
rendStates.additive = val;
}
BOOL pie_Additive(void)
{
return rendStates.additive;
}
//***************************************************************************
//
// pie_SetCaps(BOOL val);
//
// HIGHEST LEVEL enable/disable modes
//
//***************************************************************************
void pie_SetFogCap(FOG_CAP val)
{
rendStates.fogCap = val;
}
FOG_CAP pie_GetFogCap(void)
{
return rendStates.fogCap;
}
void pie_SetTexCap(TEX_CAP val)
{
rendStates.texCap = val;
}
TEX_CAP pie_GetTexCap(void)
{
return rendStates.texCap;
}
//***************************************************************************
//
// pie_EnableFog(BOOL val)
//
// Global enable/disable fog to allow fog to be turned of ingame
//
//***************************************************************************
void pie_EnableFog(BOOL val)
{
if (rendStates.fogCap == FOG_CAP_NO)
{
val = FALSE;
}
if (rendStates.fogEnabled != val)
{
rendStates.fogEnabled = val;
if (val == TRUE)
{
// pie_SetFogColour(0x0078684f);//(nicks colour + 404040)/2
pie_SetFogColour(0x00B08f5f);//nicks colour
}
else
{
pie_SetFogColour(0x00000000);//clear background to black
}
}
}
BOOL pie_GetFogEnabled(void)
{
return rendStates.fogEnabled;
}
//***************************************************************************
//
// pie_SetFogStatus(BOOL val)
@ -384,40 +104,6 @@ void pie_SetFogStatus(BOOL val)
}
}
BOOL pie_GetFogStatus(void)
{
return rendStates.fog;
}
/***************************************************************************/
void pie_SetFogColour(UDWORD colour)
{
UDWORD grey;
if (rendStates.fogCap == FOG_CAP_GREY)
{
grey = colour & 0xff;
colour >>= 8;
grey += (colour & 0xff);
colour >>= 8;
grey += (colour & 0xff);
grey /= 3;
grey &= 0xff;//check only
colour = grey + (grey<<8) + (grey<<16);
rendStates.fogColour = colour;
}
else if (rendStates.fogCap == FOG_CAP_NO)
{
rendStates.fogColour = 0;
}
else
{
rendStates.fogColour = colour;
}
}
UDWORD pie_GetFogColour(void)
{
return rendStates.fogColour;
}
/***************************************************************************/
void pie_SetTexturePage(SDWORD num)
{
@ -434,80 +120,6 @@ void pie_SetTexturePage(SDWORD num)
#endif
}
/***************************************************************************/
void pie_SetRendMode(REND_MODE rendMode)
{
if (rendMode != rendStates.rendMode)
{
rendStates.rendMode = rendMode;
switch (rendMode)
{
case REND_GOURAUD_TEX:
pie_SetColourCombine(COLOUR_TEX_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_DECAL);
break;
case REND_ALPHA_TEX:
pie_SetColourCombine(COLOUR_TEX_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_ADDITIVE_TEX:
pie_SetColourCombine(COLOUR_TEX_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ADDITIVE);
break;
case REND_TEXT:
pie_SetColourCombine(COLOUR_TEX_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_DECAL);
break;
case REND_ALPHA_TEXT:
pie_SetColourCombine(COLOUR_TEX_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_ALPHA_FLAT:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_ALPHA_ITERATED:
pie_SetColourCombine(COLOUR_FLAT_ITERATED);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ADDITIVE);
break;
case REND_FILTER_FLAT:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_FILTER);
break;
case REND_FILTER_ITERATED:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_ITERATED);
pie_SetTranslucencyMode(TRANS_ALPHA);
break;
case REND_FLAT:
pie_SetColourCombine(COLOUR_FLAT_CONSTANT);
pie_SetTexCombine(TEX_LOCAL);
pie_SetAlphaCombine(ALPHA_CONSTANT);
pie_SetTranslucencyMode(TRANS_DECAL);
default:
break;
}
}
return;
}
/***************************************************************************/
void pie_SetColourKeyedBlack(BOOL keyingOn)
@ -529,28 +141,7 @@ void pie_SetColourKeyedBlack(BOOL keyingOn)
}
/***************************************************************************/
void pie_SetBilinear(BOOL bilinearOn)
{
#ifndef PIETOOL
if (bilinearOn != rendStates.bilinearOn)
{
rendStates.bilinearOn = bilinearOn;
pieStateCount++;
}
#endif
}
BOOL pie_GetBilinear(void)
{
#ifndef PIETOOL
return rendStates.bilinearOn;
#else
return FALSE;
#endif
}
/***************************************************************************/
static void pie_SetColourCombine(COLOUR_MODE colCombMode)
void pie_SetColourCombine(COLOUR_MODE colCombMode)
{
#ifndef PIETOOL //ffs
@ -558,12 +149,11 @@ static void pie_SetColourCombine(COLOUR_MODE colCombMode)
rendStates.colourCombine = colCombMode;
pieStateCount++;
switch (colCombMode) {
case COLOUR_TEX_CONSTANT:
break;
case COLOUR_FLAT_CONSTANT:
case COLOUR_FLAT_ITERATED:
pie_SetTexturePage(-1);
break;
case COLOUR_TEX_CONSTANT:
case COLOUR_TEX_ITERATED:
default:
break;
@ -573,31 +163,7 @@ static void pie_SetColourCombine(COLOUR_MODE colCombMode)
}
/***************************************************************************/
static void pie_SetTexCombine(TEX_MODE texCombMode)
{
#ifndef PIETOOL //ffs
if (texCombMode != rendStates.texCombine)
{
rendStates.texCombine = texCombMode;
pieStateCount++;
}
#endif
}
/***************************************************************************/
static void pie_SetAlphaCombine(ALPHA_MODE alphaCombMode)
{
#ifndef PIETOOL //ffs
if (alphaCombMode != rendStates.alphaCombine)
{
rendStates.alphaCombine = alphaCombMode;
pieStateCount++;
}
#endif
}
/***************************************************************************/
static void pie_SetTranslucencyMode(TRANSLUCENCY_MODE transMode)
void pie_SetTranslucencyMode(TRANSLUCENCY_MODE transMode)
{
#ifndef PIETOOL
if (transMode != rendStates.transMode) {
@ -641,62 +207,6 @@ void pie_SetColour(UDWORD colour)
}
/***************************************************************************/
// get the constant colour used in text and flat render modes
/***************************************************************************/
UDWORD pie_GetColour(void)
{
return rendStates.colour;
}
/***************************************************************************/
void pie_SetGammaValue(float val)
WZ_DEPRECATED void pie_SetGammaValue(float val)
{
}
/***************************************************************************/
void pie_DrawMouse(SDWORD x,SDWORD y)
{
}
/***************************************************************************/
UWORD presentMouseID;
void pie_SetMouse(IMAGEFILE *psImageFile,UWORD ImageID)
{
presentMouseID = ImageID;
}
/***************************************************************************/
UDWORD pie_GetMouseID( void )
{
return(presentMouseID);
}
/***************************************************************************/
BOOL pie_SwirlyBoxes( void )
{
return(bSwirls);
}
void pie_SetSwirlyBoxes( BOOL val )
{
bSwirls = val;
}
BOOL pie_WaveBlit( void )
{
return(bWave);
}
void pie_SetWaveBlit( BOOL val )
{
bWave = val;
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/