2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
2010-07-26 16:36:29 -07:00
|
|
|
Copyright (C) 2005-2010 Warzone 2100 Project
|
2007-01-15 12:09:25 -08:00
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2007-06-28 10:47:08 -07:00
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* pieMode.h
|
|
|
|
*
|
|
|
|
* renderer control for pumpkin library functions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2010-02-26 13:50:37 -08:00
|
|
|
#include <GLee.h>
|
2007-04-11 07:21:45 -07:00
|
|
|
#include "lib/framework/frame.h"
|
|
|
|
|
2007-11-24 03:49:51 -08:00
|
|
|
#include <SDL.h>
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2010-12-31 13:37:14 -08:00
|
|
|
#include "lib/ivis_opengl/piedef.h"
|
|
|
|
#include "lib/ivis_opengl/piestate.h"
|
|
|
|
#include "lib/ivis_opengl/piemode.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "piematrix.h"
|
2010-12-31 13:37:14 -08:00
|
|
|
#include "lib/ivis_opengl/ivi.h"
|
|
|
|
#include "lib/ivis_opengl/piefunc.h"
|
|
|
|
#include "lib/ivis_opengl/tex.h"
|
|
|
|
#include "lib/ivis_opengl/pieclip.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "screen.h"
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* Source
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2010-10-13 11:25:57 -07:00
|
|
|
iSurface rendSurface;
|
|
|
|
|
2006-08-08 13:03:05 -07:00
|
|
|
BOOL pie_Initialise(void)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
pie_TexInit();
|
|
|
|
|
2007-03-28 08:08:57 -07:00
|
|
|
/* Find texture compression extension */
|
2008-04-20 05:52:19 -07:00
|
|
|
if (GLEE_ARB_texture_compression)
|
2007-03-28 08:08:57 -07:00
|
|
|
{
|
|
|
|
debug(LOG_TEXTURE, "Texture compression: Yes");
|
|
|
|
wz_texture_compression = GL_COMPRESSED_RGBA_ARB;
|
2008-04-20 05:52:19 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-28 08:08:57 -07:00
|
|
|
debug(LOG_TEXTURE, "Texture compression: No");
|
|
|
|
wz_texture_compression = GL_RGBA;
|
|
|
|
}
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
pie_MatInit();
|
|
|
|
_TEX_INDEX = 0;
|
|
|
|
|
2006-02-18 10:54:37 -08:00
|
|
|
rendSurface.width = pie_GetVideoBufferWidth();
|
|
|
|
rendSurface.height = pie_GetVideoBufferHeight();
|
|
|
|
rendSurface.xcentre = pie_GetVideoBufferWidth()/2;
|
|
|
|
rendSurface.ycentre = pie_GetVideoBufferHeight()/2;
|
|
|
|
rendSurface.clip.left = 0;
|
|
|
|
rendSurface.clip.top = 0;
|
|
|
|
rendSurface.clip.right = pie_GetVideoBufferWidth();
|
|
|
|
rendSurface.clip.bottom = pie_GetVideoBufferHeight();
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
pie_SetDefaultStates();
|
2010-10-13 13:09:31 -07:00
|
|
|
debug(LOG_3D, "xcentre %d; ycentre %d", rendSurface.xcentre, rendSurface.ycentre);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2008-03-24 09:51:17 -07:00
|
|
|
return true;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-13 13:09:31 -07:00
|
|
|
void pie_ShutDown(void)
|
|
|
|
{
|
2006-02-18 10:54:37 -08:00
|
|
|
pie_CleanUp();
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-03-12 12:29:24 -07:00
|
|
|
void pie_ScreenFlip(int clearMode)
|
|
|
|
{
|
2007-03-30 10:38:35 -07:00
|
|
|
GLbitfield clearFlags = 0;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
screenDoDumpToDiskIfRequired();
|
|
|
|
SDL_GL_SwapBuffers();
|
2008-03-12 12:29:24 -07:00
|
|
|
if (!(clearMode & CLEAR_OFF_AND_NO_BUFFER_DOWNLOAD))
|
2007-03-30 10:38:35 -07:00
|
|
|
{
|
2008-03-12 12:29:24 -07:00
|
|
|
glDepthMask(GL_TRUE);
|
|
|
|
clearFlags = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
|
|
|
|
if (clearMode & CLEAR_SHADOW)
|
|
|
|
{
|
|
|
|
clearFlags |= GL_STENCIL_BUFFER_BIT;
|
|
|
|
}
|
2007-03-30 10:38:35 -07:00
|
|
|
}
|
2008-03-12 12:29:24 -07:00
|
|
|
if (clearFlags)
|
2007-03-30 10:38:35 -07:00
|
|
|
{
|
|
|
|
glClear(clearFlags);
|
|
|
|
}
|
2008-03-12 12:29:24 -07:00
|
|
|
if (screen_GetBackDrop())
|
|
|
|
{
|
2010-05-31 09:24:33 -07:00
|
|
|
screen_Upload(NULL, screen_getMapPreview());
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
2007-11-19 12:09:01 -08:00
|
|
|
UDWORD pie_GetResScalingFactor(void)
|
|
|
|
{
|
2005-11-29 08:20:35 -08:00
|
|
|
if (pie_GetVideoBufferWidth() * 4 > pie_GetVideoBufferHeight() * 5) {
|
|
|
|
return pie_GetVideoBufferHeight()*5/4/6;
|
|
|
|
} else {
|
|
|
|
return pie_GetVideoBufferWidth()/6;
|
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|