2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
|
|
|
Copyright (C) 2005-2007 Warzone Resurrection Project
|
|
|
|
|
|
|
|
Warzone 2100 is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Warzone 2100 is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2006-06-02 12:34:58 -07:00
|
|
|
#include "lib/ivis_common/rendmode.h"
|
|
|
|
#include "lib/ivis_common/pieclip.h"
|
|
|
|
#include "lib/ivis_common/textdraw.h"
|
|
|
|
#include "lib/ivis_common/piepalette.h"
|
|
|
|
#include "lib/ivis_common/piestate.h"
|
|
|
|
#include "lib/ivis_common/ivispatch.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
|
|
|
iSurface rendSurface;
|
|
|
|
iSurface *psRendSurface;
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
//***
|
|
|
|
//*
|
|
|
|
//*
|
|
|
|
//******
|
|
|
|
|
2007-03-16 09:20:16 -07:00
|
|
|
iSurface *iV_SurfaceCreate(Uint32 flags, int width, int height, int xp, int yp, UBYTE *buffer)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-31 06:04:21 -08:00
|
|
|
iSurface *s = malloc(sizeof(iSurface));
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
assert(buffer!=NULL); // on playstation this MUST be null
|
|
|
|
|
2007-12-31 06:04:21 -08:00
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
debug(LOG_ERROR, "iV_SurfaceCreate: out of memory");
|
2007-06-28 10:47:08 -07:00
|
|
|
return NULL;
|
2007-12-31 06:04:21 -08:00
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
s->flags = flags;
|
|
|
|
s->xcentre = width>>1;
|
|
|
|
s->ycentre = height>>1;
|
|
|
|
s->xpshift = xp;
|
|
|
|
s->ypshift = yp;
|
|
|
|
s->width = width;
|
|
|
|
s->height = height;
|
|
|
|
s->size = width * height;
|
|
|
|
s->buffer = buffer;
|
|
|
|
s->clip.left = 0;
|
|
|
|
s->clip.right = width-1;
|
|
|
|
s->clip.top = 0;
|
|
|
|
s->clip.bottom = height-1;
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// user must free s->buffer before calling
|
|
|
|
void iV_SurfaceDestroy(iSurface *s)
|
|
|
|
{
|
|
|
|
// if renderer assigned to surface
|
|
|
|
if (psRendSurface == s)
|
2007-12-31 06:04:21 -08:00
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
psRendSurface = NULL;
|
2007-12-31 06:04:21 -08:00
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if (s)
|
2007-12-31 06:04:21 -08:00
|
|
|
{
|
2007-04-15 03:43:05 -07:00
|
|
|
free(s);
|
2007-12-31 06:04:21 -08:00
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
|
|
|
// function pointers for render assign
|
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
|
2006-08-08 13:03:05 -07:00
|
|
|
void iV_RenderAssign(iSurface *s)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
/* Need to look into this - won't the unwanted called still set render surface? */
|
|
|
|
psRendSurface = s;
|
|
|
|
|
2007-10-27 06:58:01 -07:00
|
|
|
debug(LOG_3D, "iV_RenderAssign: flags %x; xcentre %d; ycentre %d; buffer %p",
|
2007-06-18 08:46:12 -07:00
|
|
|
s->flags, s->xcentre, s->ycentre, s->buffer);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|