2002-05-20 08:59:37 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: RageDisplay
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "RageDisplay.h"
|
|
|
|
|
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "RageLog.h"
|
2002-07-27 19:29:51 +00:00
|
|
|
#include "RageTimer.h"
|
|
|
|
|
#include "RageException.h"
|
2002-08-13 23:26:46 +00:00
|
|
|
#include "RageTexture.h"
|
2002-10-28 05:30:45 +00:00
|
|
|
#include "RageMath.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "SDL.h"
|
|
|
|
|
#include "SDL_opengl.h"
|
|
|
|
|
#include "RageTypes.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
2002-06-14 22:25:22 +00:00
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
RageDisplay* DISPLAY = NULL;
|
|
|
|
|
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
////////////
|
|
|
|
|
// Globals
|
|
|
|
|
////////////
|
|
|
|
|
const int MAX_NUM_VERTICIES = 1000;
|
|
|
|
|
SDL_Surface *g_screen = NULL; // this class is a singleton, so there can be only one
|
|
|
|
|
vector<RageMatrix> g_matModelStack; // model matrix stack
|
|
|
|
|
RageMatrix g_matView; // view matrix
|
|
|
|
|
RageMatrix& GetTopModelMatrix() { return g_matModelStack.back(); }
|
|
|
|
|
int g_flags = 0; /* SDL video flags */
|
|
|
|
|
GLenum g_vertMode = GL_TRIANGLES;
|
|
|
|
|
RageVertex g_vertQueue[MAX_NUM_VERTICIES];
|
2002-11-11 09:56:07 +00:00
|
|
|
RageTimer g_LastCheckTimer;
|
2002-11-11 04:53:31 +00:00
|
|
|
int g_iNumVerts;
|
|
|
|
|
float g_fLastCheckTime;
|
2002-11-11 20:43:30 +00:00
|
|
|
int g_iFPS, g_iVPF, g_iDPF;
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-11-11 20:43:30 +00:00
|
|
|
int RageDisplay::GetFPS() const { return g_iFPS; }
|
|
|
|
|
int RageDisplay::GetVPF() const { return g_iVPF; }
|
|
|
|
|
int RageDisplay::GetDPF() const { return g_iDPF; }
|
|
|
|
|
|
|
|
|
|
static int g_iFramesRenderedSinceLastCheck,
|
|
|
|
|
g_iVertsRenderedSinceLastCheck,
|
|
|
|
|
g_iDrawsSinceLastCheck;
|
2002-08-29 21:48:57 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, RefreshRateMode rate, bool vsync )
|
2002-08-22 08:49:41 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
// LOG->Trace( "RageDisplay::RageDisplay()" );
|
2002-08-22 08:49:41 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
|
|
|
|
|
|
|
|
SetVideoMode( windowed, width, height, bpp, rate, vsync );
|
2002-08-22 08:49:41 +00:00
|
|
|
}
|
|
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
RageDisplay::~RageDisplay()
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
2002-08-29 22:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// Name: SwitchDisplayMode()
|
|
|
|
|
// Desc:
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, RefreshRateMode rate, bool vsync )
|
2002-08-29 22:30:06 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
// LOG->Trace( "RageDisplay::SetVideoMode( %d, %d, %d, %d, %d, %d )", windowed, width, height, bpp, rate, vsync );
|
2002-08-29 22:30:06 +00:00
|
|
|
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
// if( windowed )
|
|
|
|
|
// flags |= SDL_FULLSCREEN;
|
|
|
|
|
g_flags |= SDL_DOUBLEBUF;
|
|
|
|
|
g_flags |= SDL_RESIZABLE;
|
|
|
|
|
g_flags |= SDL_OPENGL;
|
2002-08-29 22:30:06 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
SDL_ShowCursor( ~g_flags & SDL_FULLSCREEN );
|
2002-08-29 22:30:06 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
switch( bpp )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
case 15:
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
|
|
|
|
break;
|
|
|
|
|
case 24:
|
|
|
|
|
case 32:
|
|
|
|
|
default:
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, bpp);
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, TRUE);
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
g_screen = SDL_SetVideoMode(width, height, bpp, g_flags);
|
|
|
|
|
if(!g_screen)
|
|
|
|
|
throw RageException("Failed to open screen!");
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
/*
|
|
|
|
|
* Set up OpenGL for 2D rendering.
|
|
|
|
|
*/
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glViewport(0, 0, g_screen->w, g_screen->h);
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
/*
|
|
|
|
|
* Set state variables
|
|
|
|
|
*/
|
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
// glBegin( GL_TRIANGLES );
|
|
|
|
|
// glColor4f( 1,1,1,1 );
|
|
|
|
|
// glVertex3f( 0, 0, 0 );
|
|
|
|
|
// glVertex3f( 320, 0, 0 );
|
|
|
|
|
// glVertex3f( 320, 240, 0 );
|
|
|
|
|
// glEnd();
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
// SDL_GL_SwapBuffers();
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
int RageDisplay::GetMaxTextureSize() const
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
GLint size;
|
|
|
|
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size);
|
|
|
|
|
return size;
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::Clear()
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
glClearColor( 0,0,0,1 );
|
|
|
|
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::Flip()
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
FlushQueue();
|
|
|
|
|
SDL_GL_SwapBuffers();
|
2002-11-11 09:56:07 +00:00
|
|
|
g_iFramesRenderedSinceLastCheck++;
|
|
|
|
|
|
|
|
|
|
if( g_LastCheckTimer.PeekDeltaTime() >= 1.0f ) // update stats every 1 sec.
|
|
|
|
|
{
|
|
|
|
|
g_LastCheckTimer.GetDeltaTime();
|
|
|
|
|
g_iFPS = g_iFramesRenderedSinceLastCheck;
|
|
|
|
|
g_iFramesRenderedSinceLastCheck = 0;
|
2002-11-11 20:43:30 +00:00
|
|
|
g_iVPF = g_iVertsRenderedSinceLastCheck / g_iFPS;
|
2002-11-11 09:56:07 +00:00
|
|
|
g_iVertsRenderedSinceLastCheck = 0;
|
|
|
|
|
g_iDPF = g_iDrawsSinceLastCheck / g_iFPS;
|
|
|
|
|
g_iDrawsSinceLastCheck = 0;
|
2002-11-11 20:43:30 +00:00
|
|
|
//LOG->Trace( "FPS: %d, VPF: %d, DPF: %d", m_iFPS, m_iVPF, m_iDPF );
|
2002-11-11 09:56:07 +00:00
|
|
|
}
|
|
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::GetHzAtResolution(int width, int height, int bpp, CArray<int,int> &add) const
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
|
|
|
|
|
2002-08-29 20:59:47 +00:00
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
bool RageDisplay::IsWindowed() const
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
return true; // FIXME
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::DrawQuad( const RageVertex v[4] ) // upper-left, upper-right, lower-left, lower-right
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
DrawQuads( v, 4 );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::DrawQuads( const RageVertex v[], int iNumVerts )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
if( g_vertMode != GL_QUADS )
|
|
|
|
|
FlushQueue();
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
ASSERT( (iNumVerts%4) == 0 );
|
|
|
|
|
g_vertMode = GL_QUADS;
|
|
|
|
|
AddVerts( v, iNumVerts );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::DrawFan( const RageVertex v[], int iNumVerts )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
if( g_vertMode != GL_TRIANGLE_FAN )
|
|
|
|
|
FlushQueue();
|
|
|
|
|
|
|
|
|
|
ASSERT( iNumVerts >= 3 );
|
|
|
|
|
g_vertMode = GL_TRIANGLE_FAN;
|
|
|
|
|
AddVerts( v, iNumVerts );
|
|
|
|
|
FlushQueue();
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::DrawStrip( const RageVertex v[], int iNumVerts )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
if( g_vertMode != GL_TRIANGLE_STRIP )
|
2002-08-13 23:26:46 +00:00
|
|
|
FlushQueue();
|
2002-08-18 17:48:50 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
ASSERT( iNumVerts >= 3 );
|
|
|
|
|
g_vertMode = GL_TRIANGLE_STRIP;
|
|
|
|
|
AddVerts( v, iNumVerts );
|
|
|
|
|
FlushQueue();
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::AddVerts( const RageVertex v[], int iNumVerts )
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
for( int i=0; i<iNumVerts; i++ )
|
|
|
|
|
{
|
2002-11-11 09:56:07 +00:00
|
|
|
// Don't overflow the queue
|
|
|
|
|
if( g_iNumVerts+1 > MAX_NUM_VERTICIES )
|
|
|
|
|
FlushQueue();
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
// transform the verticies as we copy
|
|
|
|
|
RageVec3TransformCoord( &g_vertQueue[g_iNumVerts].p, &v[i].p, &GetTopModelMatrix() );
|
|
|
|
|
g_vertQueue[g_iNumVerts].c = v[i].c;
|
|
|
|
|
g_vertQueue[g_iNumVerts].t = v[i].t;
|
|
|
|
|
g_iNumVerts++;
|
|
|
|
|
}
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RageDisplay::FlushQueue()
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
if( g_iNumVerts == 0 )
|
2002-08-13 23:26:46 +00:00
|
|
|
return;
|
2002-08-19 20:02:30 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glInterleavedArrays( GL_T2F_C4UB_V3F, sizeof(RageVertex), g_vertQueue );
|
|
|
|
|
glDrawArrays( g_vertMode, 0, g_iNumVerts );
|
2002-08-19 20:02:30 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
g_iVertsRenderedSinceLastCheck += g_iNumVerts;
|
|
|
|
|
g_iNumVerts = 0;
|
2002-08-18 17:48:50 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
g_iDrawsSinceLastCheck++;
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
void RageDisplay::SetViewTransform( const RageMatrix* pMatrix )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
|
|
|
|
FlushQueue();
|
2002-11-11 04:53:31 +00:00
|
|
|
// OpenGL doesn't have a separate view matrix. We need to save it and muliply in later
|
|
|
|
|
g_matView = *pMatrix;
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
2002-10-28 05:30:45 +00:00
|
|
|
void RageDisplay::SetProjectionTransform( const RageMatrix* pMatrix )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
|
|
|
|
FlushQueue();
|
2002-11-11 04:53:31 +00:00
|
|
|
glMatrixMode( GL_MODELVIEW );
|
|
|
|
|
glLoadMatrixf( (float*)pMatrix );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
2002-10-28 05:30:45 +00:00
|
|
|
void RageDisplay::GetViewTransform( RageMatrix* pMatrixOut )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
*pMatrixOut = g_matView;
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
2002-10-28 05:30:45 +00:00
|
|
|
void RageDisplay::GetProjectionTransform( RageMatrix* pMatrixOut )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
glGetFloatv( GL_PROJECTION_MATRIX, (float*)pMatrixOut );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RageDisplay::ResetMatrixStack()
|
|
|
|
|
{
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrix ident;
|
|
|
|
|
RageMatrixIdentity( &ident );
|
2002-11-11 04:53:31 +00:00
|
|
|
g_matModelStack.clear();
|
|
|
|
|
g_matModelStack.push_back(ident);
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RageDisplay::PushMatrix()
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
g_matModelStack.push_back( GetTopModelMatrix() );
|
|
|
|
|
ASSERT(g_matModelStack.size()<20); // check for infinite loop
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RageDisplay::PopMatrix()
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
g_matModelStack.erase( g_matModelStack.end()-1, g_matModelStack.end() );
|
|
|
|
|
ASSERT(g_matModelStack.size()>=1); // popped a matrix we didn't push
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
2002-08-29 21:30:16 +00:00
|
|
|
void RageDisplay::Translate( float x, float y, float z )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrix matTemp;
|
|
|
|
|
RageMatrixTranslation( &matTemp, x, y, z );
|
2002-11-11 04:53:31 +00:00
|
|
|
RageMatrix& matTop = GetTopModelMatrix();
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrixMultiply( &matTop, &matTemp, &matTop );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
2002-08-29 21:30:16 +00:00
|
|
|
void RageDisplay::TranslateLocal( float x, float y, float z )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrix matTemp;
|
|
|
|
|
RageMatrixTranslation( &matTemp, x, y, z );
|
2002-11-11 04:53:31 +00:00
|
|
|
RageMatrix& matTop = GetTopModelMatrix();
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrixMultiply( &matTop, &matTop, &matTemp );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
2002-08-29 21:30:16 +00:00
|
|
|
void RageDisplay::Scale( float x, float y, float z )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrix matTemp;
|
|
|
|
|
RageMatrixScaling( &matTemp, x, y, z );
|
2002-11-11 04:53:31 +00:00
|
|
|
RageMatrix& matTop = GetTopModelMatrix();
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrixMultiply( &matTop, &matTemp, &matTop );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
2002-08-29 21:30:16 +00:00
|
|
|
void RageDisplay::RotateX( float r )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrix matTemp;
|
|
|
|
|
RageMatrixRotationX( &matTemp, r );
|
2002-11-11 04:53:31 +00:00
|
|
|
RageMatrix& matTop = GetTopModelMatrix();
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrixMultiply( &matTop, &matTemp, &matTop );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
2002-08-29 21:30:16 +00:00
|
|
|
void RageDisplay::RotateY( float r )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrix matTemp;
|
|
|
|
|
RageMatrixRotationY( &matTemp, r );
|
2002-11-11 04:53:31 +00:00
|
|
|
RageMatrix& matTop = GetTopModelMatrix();
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrixMultiply( &matTop, &matTemp, &matTop );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
2002-08-29 21:30:16 +00:00
|
|
|
void RageDisplay::RotateZ( float r )
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrix matTemp;
|
|
|
|
|
RageMatrixRotationZ( &matTemp, r );
|
2002-11-11 04:53:31 +00:00
|
|
|
RageMatrix& matTop = GetTopModelMatrix();
|
2002-10-28 05:30:45 +00:00
|
|
|
RageMatrixMultiply( &matTop, &matTemp, &matTop );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
void RageDisplay::SetTexture( RageTexture* pTexture )
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
static int iLastTexID = 0;
|
|
|
|
|
int iNewTexID = pTexture ? pTexture->GetGLTextureID() : 0;
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
if( iLastTexID != iNewTexID )
|
2002-08-18 16:19:26 +00:00
|
|
|
FlushQueue();
|
2002-11-11 09:56:07 +00:00
|
|
|
iLastTexID = iNewTexID;
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glBindTexture( GL_TEXTURE_2D, iNewTexID );
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::SetTextureModeModulate()
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
int a;
|
|
|
|
|
glGetTexEnviv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &a );
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-11-11 09:56:07 +00:00
|
|
|
if( a != GL_MODULATE )
|
2002-08-18 16:19:26 +00:00
|
|
|
FlushQueue();
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
void RageDisplay::SetTextureModeGlow()
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
int a, b;
|
|
|
|
|
glGetIntegerv( GL_BLEND_SRC, &a );
|
|
|
|
|
glGetIntegerv( GL_BLEND_DST, &b );
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
if( a!=GL_SRC_ALPHA || b!=GL_ONE )
|
2002-08-18 16:19:26 +00:00
|
|
|
FlushQueue();
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE );
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
void RageDisplay::SetBlendModeNormal()
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
int a, b;
|
|
|
|
|
glGetIntegerv( GL_BLEND_SRC, &a );
|
|
|
|
|
glGetIntegerv( GL_BLEND_DST, &b );
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
if( a!=GL_SRC_ALPHA || b!=GL_ONE_MINUS_SRC_ALPHA )
|
2002-08-18 16:19:26 +00:00
|
|
|
FlushQueue();
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
void RageDisplay::SetBlendModeAdd()
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
int a, b;
|
|
|
|
|
glGetIntegerv( GL_BLEND_SRC, &a );
|
|
|
|
|
glGetIntegerv( GL_BLEND_DST, &b );
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
if( a!=GL_ONE || b!=GL_ONE )
|
2002-08-18 16:19:26 +00:00
|
|
|
FlushQueue();
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glBlendFunc( GL_ONE, GL_ONE );
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
void RageDisplay::EnableZBuffer()
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
bool a;
|
|
|
|
|
glGetBooleanv( GL_DEPTH_TEST, (unsigned char*)&a );
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
if( !a )
|
2002-08-18 16:19:26 +00:00
|
|
|
FlushQueue();
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glEnable( GL_DEPTH_TEST );
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
void RageDisplay::DisableZBuffer()
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
bool a;
|
|
|
|
|
glGetBooleanv( GL_DEPTH_TEST, (unsigned char*)&a );
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
if( a )
|
2002-08-18 16:19:26 +00:00
|
|
|
FlushQueue();
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glDisable( GL_DEPTH_TEST );
|
2002-10-18 19:01:32 +00:00
|
|
|
}
|
|
|
|
|
void RageDisplay::EnableTextureWrapping()
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
int a, b;
|
|
|
|
|
glGetTexParameteriv( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &a );
|
|
|
|
|
glGetTexParameteriv( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &b );
|
2002-10-18 19:01:32 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
if( a!=GL_REPEAT || b!=GL_REPEAT )
|
2002-10-18 19:01:32 +00:00
|
|
|
FlushQueue();
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
|
|
|
|
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
2002-10-18 19:01:32 +00:00
|
|
|
}
|
|
|
|
|
void RageDisplay::DisableTextureWrapping()
|
|
|
|
|
{
|
2002-11-11 04:53:31 +00:00
|
|
|
int a, b;
|
|
|
|
|
glGetTexParameteriv( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &a );
|
|
|
|
|
glGetTexParameteriv( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, &b );
|
2002-10-18 19:01:32 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
if( a!=GL_CLAMP || b!=GL_CLAMP )
|
2002-10-18 19:01:32 +00:00
|
|
|
FlushQueue();
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
|
|
|
|
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
|
2002-10-18 19:01:32 +00:00
|
|
|
}
|