Combine binaries, so we can choose the renderer. No actual selection
yet; change CreateDisplay if you want to do that for the next few hours.
This commit is contained in:
@@ -34,6 +34,8 @@ static int g_iFramesRenderedSinceLastCheck,
|
||||
g_iVertsRenderedSinceLastCheck,
|
||||
g_iNumChecksSinceLastReset;
|
||||
|
||||
RageDisplay* DISPLAY = NULL;
|
||||
|
||||
CString PixelFormatToString( PixelFormat pixfmt )
|
||||
{
|
||||
const CString s[NUM_PIX_FORMATS] = {
|
||||
|
||||
+46
-49
@@ -59,86 +59,86 @@ class RageDisplay
|
||||
friend class RageTexture;
|
||||
|
||||
public:
|
||||
const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const;
|
||||
RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile );
|
||||
~RageDisplay();
|
||||
void Update(float fDeltaTime);
|
||||
virtual const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const = 0;
|
||||
// RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile );
|
||||
virtual ~RageDisplay() { };
|
||||
virtual void Update(float fDeltaTime) { }
|
||||
|
||||
bool IsSoftwareRenderer();
|
||||
virtual bool IsSoftwareRenderer() = 0;
|
||||
|
||||
bool SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile );
|
||||
virtual bool SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile ) = 0;
|
||||
|
||||
/* Call this when the resolution has been changed externally: */
|
||||
void ResolutionChanged();
|
||||
virtual void ResolutionChanged() { }
|
||||
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
bool IsWindowed() const;
|
||||
int GetWidth() const;
|
||||
int GetHeight() const;
|
||||
int GetBPP() const;
|
||||
virtual void BeginFrame() = 0;
|
||||
virtual void EndFrame() = 0;
|
||||
virtual bool IsWindowed() const = 0;
|
||||
virtual int GetWidth() const = 0;
|
||||
virtual int GetHeight() const = 0;
|
||||
virtual int GetBPP() const = 0;
|
||||
|
||||
void SetBlendMode( BlendMode mode );
|
||||
virtual void SetBlendMode( BlendMode mode ) = 0;
|
||||
|
||||
bool SupportsTextureFormat( PixelFormat pixfmt );
|
||||
virtual bool SupportsTextureFormat( PixelFormat pixfmt ) = 0;
|
||||
/* return 0 if failed or internal texture resource handle
|
||||
* (unsigned in OpenGL, texture pointer in D3D) */
|
||||
unsigned CreateTexture(
|
||||
virtual unsigned CreateTexture(
|
||||
PixelFormat pixfmt, // format of img and of texture in video mem
|
||||
SDL_Surface*& img // must be in pixfmt
|
||||
);
|
||||
void UpdateTexture(
|
||||
) = 0;
|
||||
virtual void UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
PixelFormat pixfmt, // this must be the same as what was passed to CreateTexture
|
||||
SDL_Surface*& img,
|
||||
int xoffset, int yoffset, int width, int height
|
||||
);
|
||||
void DeleteTexture( unsigned uTexHandle );
|
||||
void SetTexture( RageTexture* pTexture );
|
||||
void SetTextureModeModulate();
|
||||
void SetTextureModeGlow( GlowMode m=GLOW_WHITEN );
|
||||
void SetTextureWrapping( bool b );
|
||||
int GetMaxTextureSize() const;
|
||||
void SetTextureFiltering( bool b);
|
||||
) = 0;
|
||||
virtual void DeleteTexture( unsigned uTexHandle ) = 0;
|
||||
virtual void SetTexture( RageTexture* pTexture ) = 0;
|
||||
virtual void SetTextureModeModulate() = 0;
|
||||
virtual void SetTextureModeGlow( GlowMode m=GLOW_WHITEN ) = 0;
|
||||
virtual void SetTextureWrapping( bool b ) = 0;
|
||||
virtual int GetMaxTextureSize() const = 0;
|
||||
virtual void SetTextureFiltering( bool b ) = 0;
|
||||
|
||||
bool IsZBufferEnabled() const;
|
||||
void SetZBuffer( bool b );
|
||||
void ClearZBuffer();
|
||||
virtual bool IsZBufferEnabled() const = 0;
|
||||
virtual void SetZBuffer( bool b ) = 0;
|
||||
virtual void ClearZBuffer() = 0;
|
||||
|
||||
void SetBackfaceCull( bool b );
|
||||
virtual void SetBackfaceCull( bool b ) = 0;
|
||||
|
||||
void SetAlphaTest( bool b );
|
||||
virtual void SetAlphaTest( bool b ) = 0;
|
||||
|
||||
void SetMaterial(
|
||||
virtual void SetMaterial(
|
||||
float emissive[4],
|
||||
float ambient[4],
|
||||
float diffuse[4],
|
||||
float specular[4],
|
||||
float shininess
|
||||
);
|
||||
) = 0;
|
||||
|
||||
void SetLighting( bool b );
|
||||
void SetLightOff( int index );
|
||||
void SetLightDirectional(
|
||||
virtual void SetLighting( bool b ) = 0;
|
||||
virtual void SetLightOff( int index ) = 0;
|
||||
virtual void SetLightDirectional(
|
||||
int index,
|
||||
RageColor ambient,
|
||||
RageColor diffuse,
|
||||
RageColor specular,
|
||||
RageVector3 dir );
|
||||
RageVector3 dir ) = 0;
|
||||
|
||||
|
||||
void DrawQuad( const RageVertex v[] ) { DrawQuads(v,4); } /* alias. upper-left, upper-right, lower-left, lower-right */
|
||||
void DrawQuads( const RageVertex v[], int iNumVerts );
|
||||
void DrawFan( const RageVertex v[], int iNumVerts );
|
||||
void DrawStrip( const RageVertex v[], int iNumVerts );
|
||||
void DrawTriangles( const RageVertex v[], int iNumVerts );
|
||||
void DrawIndexedTriangles( const RageVertex v[], const Uint16* pIndices, int iNumIndices );
|
||||
void DrawLineStrip( const RageVertex v[], int iNumVerts, float LineWidth );
|
||||
virtual void DrawQuads( const RageVertex v[], int iNumVerts ) = 0;
|
||||
virtual void DrawFan( const RageVertex v[], int iNumVerts ) = 0;
|
||||
virtual void DrawStrip( const RageVertex v[], int iNumVerts ) = 0;
|
||||
virtual void DrawTriangles( const RageVertex v[], int iNumVerts ) = 0;
|
||||
virtual void DrawIndexedTriangles( const RageVertex v[], const Uint16* pIndices, int iNumIndices ) = 0;
|
||||
virtual void DrawLineStrip( const RageVertex v[], int iNumVerts, float LineWidth ) = 0;
|
||||
|
||||
void SaveScreenshot( CString sPath );
|
||||
virtual void SaveScreenshot( CString sPath ) = 0;
|
||||
|
||||
protected:
|
||||
void SetViewport(int shift_left, int shift_down);
|
||||
virtual void SetViewport(int shift_left, int shift_down) = 0;
|
||||
|
||||
// Stuff in RageDisplay.cpp
|
||||
void SetDefaultRenderStates();
|
||||
@@ -152,9 +152,6 @@ public:
|
||||
void ProcessStatsOnFlip();
|
||||
void StatsAddVerts( int iNumVertsRendered );
|
||||
|
||||
/* Statistics */
|
||||
|
||||
/* Statistics */
|
||||
void PushMatrix();
|
||||
void PopMatrix();
|
||||
void Translate( float x, float y, float z );
|
||||
@@ -172,7 +169,7 @@ public:
|
||||
void ExitPerspective();
|
||||
void LookAt(const RageVector3 &Eye, const RageVector3 &At, const RageVector3 &Up);
|
||||
|
||||
RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf );
|
||||
virtual RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ) = 0;
|
||||
RageMatrix GetFrustrumMatrix(
|
||||
float left,
|
||||
float right,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include "RageDisplay.h"
|
||||
#include "RageDisplay_D3D.h"
|
||||
#include "D3D8.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
@@ -42,7 +43,6 @@
|
||||
#include <math.h>
|
||||
#include <list>
|
||||
|
||||
RageDisplay* DISPLAY = NULL;
|
||||
|
||||
//
|
||||
// Globals
|
||||
@@ -165,7 +165,7 @@ static const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
|
||||
}
|
||||
};
|
||||
|
||||
const PixelFormatDesc *RageDisplay::GetPixelFormatDesc(PixelFormat pf) const
|
||||
const PixelFormatDesc *RageDisplay_D3D::GetPixelFormatDesc(PixelFormat pf) const
|
||||
{
|
||||
ASSERT( pf < NUM_PIX_FORMATS );
|
||||
return &PIXEL_FORMAT_DESC[pf];
|
||||
@@ -173,9 +173,9 @@ const PixelFormatDesc *RageDisplay::GetPixelFormatDesc(PixelFormat pf) const
|
||||
|
||||
|
||||
|
||||
RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
|
||||
RageDisplay_D3D::RageDisplay_D3D( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
|
||||
{
|
||||
LOG->Trace( "RageDisplay::RageDisplay()" );
|
||||
LOG->Trace( "RageDisplay_D3D::RageDisplay()" );
|
||||
|
||||
if(!SDL_WasInit(SDL_INIT_VIDEO))
|
||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||
@@ -252,7 +252,7 @@ RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rat
|
||||
SetVideoMode( windowed, width, height, bpp, rate, vsync, sWindowTitle, sIconFile );
|
||||
}
|
||||
|
||||
void RageDisplay::Update(float fDeltaTime)
|
||||
void RageDisplay_D3D::Update(float fDeltaTime)
|
||||
{
|
||||
SDL_Event event;
|
||||
while(SDL_GetEvent(event, SDL_VIDEORESIZEMASK))
|
||||
@@ -270,14 +270,14 @@ void RageDisplay::Update(float fDeltaTime)
|
||||
}
|
||||
}
|
||||
|
||||
bool RageDisplay::IsSoftwareRenderer()
|
||||
bool RageDisplay_D3D::IsSoftwareRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
RageDisplay::~RageDisplay()
|
||||
RageDisplay_D3D::~RageDisplay_D3D()
|
||||
{
|
||||
LOG->Trace( "RageDisplay::~RageDisplay()" );
|
||||
LOG->Trace( "RageDisplay_D3D::~RageDisplay()" );
|
||||
|
||||
SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
@@ -359,7 +359,7 @@ HWND GetHwnd()
|
||||
|
||||
|
||||
/* Set the video mode. */
|
||||
bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
|
||||
bool RageDisplay_D3D::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
|
||||
{
|
||||
/* Set SDL window title and icon -before- creating the window */
|
||||
SDL_WM_SetCaption(sWindowTitle, "");
|
||||
@@ -462,7 +462,7 @@ bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, i
|
||||
return bCreateNewDevice;
|
||||
}
|
||||
|
||||
void RageDisplay::ResolutionChanged()
|
||||
void RageDisplay_D3D::ResolutionChanged()
|
||||
{
|
||||
// no need to clear because D3D uses an overlay
|
||||
// SetViewport(0,0);
|
||||
@@ -472,7 +472,7 @@ void RageDisplay::ResolutionChanged()
|
||||
// Flip();
|
||||
}
|
||||
|
||||
void RageDisplay::SetViewport(int shift_left, int shift_down)
|
||||
void RageDisplay_D3D::SetViewport(int shift_left, int shift_down)
|
||||
{
|
||||
/* left and down are on a 0..SCREEN_WIDTH, 0..SCREEN_HEIGHT scale.
|
||||
* Scale them to the actual viewport range. */
|
||||
@@ -483,12 +483,12 @@ void RageDisplay::SetViewport(int shift_left, int shift_down)
|
||||
g_pd3dDevice->SetViewport( &viewData );
|
||||
}
|
||||
|
||||
int RageDisplay::GetMaxTextureSize() const
|
||||
int RageDisplay_D3D::GetMaxTextureSize() const
|
||||
{
|
||||
return g_DeviceCaps.MaxTextureWidth;
|
||||
}
|
||||
|
||||
void RageDisplay::BeginFrame()
|
||||
void RageDisplay_D3D::BeginFrame()
|
||||
{
|
||||
if( g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET )
|
||||
SetVideoMode( g_Windowed, g_CurrentWidth, g_CurrentHeight, g_CurrentBPP, 0, 0, "", "" ); // FIXME: preserve prefs
|
||||
@@ -498,7 +498,7 @@ void RageDisplay::BeginFrame()
|
||||
g_pd3dDevice->BeginScene();
|
||||
}
|
||||
|
||||
void RageDisplay::EndFrame()
|
||||
void RageDisplay_D3D::EndFrame()
|
||||
{
|
||||
g_pd3dDevice->EndScene();
|
||||
g_pd3dDevice->Present( 0, 0, 0, 0 );
|
||||
@@ -519,7 +519,7 @@ D3DFORMAT D3DFORMATS[NUM_PIX_FORMATS] =
|
||||
D3DFMT_P8
|
||||
};
|
||||
|
||||
bool RageDisplay::SupportsTextureFormat( PixelFormat pixfmt )
|
||||
bool RageDisplay_D3D::SupportsTextureFormat( PixelFormat pixfmt )
|
||||
{
|
||||
D3DFORMAT d3dfmt = D3DFORMATS[pixfmt];
|
||||
HRESULT hr = g_pd3d->CheckDeviceFormat(
|
||||
@@ -532,7 +532,7 @@ bool RageDisplay::SupportsTextureFormat( PixelFormat pixfmt )
|
||||
return SUCCEEDED( hr );
|
||||
}
|
||||
|
||||
void RageDisplay::SaveScreenshot( CString sPath )
|
||||
void RageDisplay_D3D::SaveScreenshot( CString sPath )
|
||||
{
|
||||
#ifndef _XBOX
|
||||
IDirect3DSurface8* pSurface;
|
||||
@@ -543,10 +543,10 @@ void RageDisplay::SaveScreenshot( CString sPath )
|
||||
}
|
||||
|
||||
|
||||
bool RageDisplay::IsWindowed() const { return g_Windowed; }
|
||||
int RageDisplay::GetWidth() const { return g_CurrentWidth; }
|
||||
int RageDisplay::GetHeight() const { return g_CurrentHeight; }
|
||||
int RageDisplay::GetBPP() const { return g_CurrentBPP; }
|
||||
bool RageDisplay_D3D::IsWindowed() const { return g_Windowed; }
|
||||
int RageDisplay_D3D::GetWidth() const { return g_CurrentWidth; }
|
||||
int RageDisplay_D3D::GetHeight() const { return g_CurrentHeight; }
|
||||
int RageDisplay_D3D::GetBPP() const { return g_CurrentBPP; }
|
||||
|
||||
#define SEND_CURRENT_MATRICES \
|
||||
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)GetProjection() ); \
|
||||
@@ -557,7 +557,7 @@ int RageDisplay::GetBPP() const { return g_CurrentBPP; }
|
||||
g_pd3dDevice->SetTransform( D3DTS_WORLD, (D3DMATRIX*)&m );
|
||||
|
||||
|
||||
void RageDisplay::DrawQuads( const RageVertex v[], int iNumVerts )
|
||||
void RageDisplay_D3D::DrawQuads( const RageVertex v[], int iNumVerts )
|
||||
{
|
||||
ASSERT( (iNumVerts%4) == 0 );
|
||||
|
||||
@@ -599,7 +599,7 @@ void RageDisplay::DrawQuads( const RageVertex v[], int iNumVerts )
|
||||
|
||||
StatsAddVerts( iNumVerts );
|
||||
}
|
||||
void RageDisplay::DrawFan( const RageVertex v[], int iNumVerts )
|
||||
void RageDisplay_D3D::DrawFan( const RageVertex v[], int iNumVerts )
|
||||
{
|
||||
ASSERT( iNumVerts >= 3 );
|
||||
g_pd3dDevice->SetVertexShader( D3DFVF_RAGEVERTEX );
|
||||
@@ -613,7 +613,7 @@ void RageDisplay::DrawFan( const RageVertex v[], int iNumVerts )
|
||||
StatsAddVerts( iNumVerts );
|
||||
}
|
||||
|
||||
void RageDisplay::DrawStrip( const RageVertex v[], int iNumVerts )
|
||||
void RageDisplay_D3D::DrawStrip( const RageVertex v[], int iNumVerts )
|
||||
{
|
||||
ASSERT( iNumVerts >= 3 );
|
||||
g_pd3dDevice->SetVertexShader( D3DFVF_RAGEVERTEX );
|
||||
@@ -627,7 +627,7 @@ void RageDisplay::DrawStrip( const RageVertex v[], int iNumVerts )
|
||||
StatsAddVerts( iNumVerts );
|
||||
}
|
||||
|
||||
void RageDisplay::DrawTriangles( const RageVertex v[], int iNumVerts )
|
||||
void RageDisplay_D3D::DrawTriangles( const RageVertex v[], int iNumVerts )
|
||||
{
|
||||
if( iNumVerts == 0 )
|
||||
return;
|
||||
@@ -643,7 +643,7 @@ void RageDisplay::DrawTriangles( const RageVertex v[], int iNumVerts )
|
||||
StatsAddVerts( iNumVerts );
|
||||
}
|
||||
|
||||
void RageDisplay::DrawIndexedTriangles( const RageVertex v[], const Uint16 pIndices[], int iNumIndices )
|
||||
void RageDisplay_D3D::DrawIndexedTriangles( const RageVertex v[], const Uint16 pIndices[], int iNumIndices )
|
||||
{
|
||||
if( iNumIndices == 0 )
|
||||
return;
|
||||
@@ -662,7 +662,7 @@ void RageDisplay::DrawIndexedTriangles( const RageVertex v[], const Uint16 pIndi
|
||||
StatsAddVerts( iNumIndices );
|
||||
}
|
||||
|
||||
void RageDisplay::DrawLineStrip( const RageVertex v[], int iNumVerts, float LineWidth )
|
||||
void RageDisplay_D3D::DrawLineStrip( const RageVertex v[], int iNumVerts, float LineWidth )
|
||||
{
|
||||
ASSERT( iNumVerts >= 2 );
|
||||
g_pd3dDevice->SetRenderState( D3DRS_POINTSIZE, *((DWORD*)&LineWidth) ); // funky cast. See D3DRENDERSTATETYPE doc
|
||||
@@ -677,7 +677,7 @@ void RageDisplay::DrawLineStrip( const RageVertex v[], int iNumVerts, float Line
|
||||
StatsAddVerts( iNumVerts );
|
||||
}
|
||||
|
||||
void RageDisplay::SetTexture( RageTexture* pTexture )
|
||||
void RageDisplay_D3D::SetTexture( RageTexture* pTexture )
|
||||
{
|
||||
if( pTexture == NULL )
|
||||
{
|
||||
@@ -692,7 +692,7 @@ void RageDisplay::SetTexture( RageTexture* pTexture )
|
||||
// Set palette (if any)
|
||||
SetPalette(uTexHandle);
|
||||
}
|
||||
void RageDisplay::SetTextureModeModulate()
|
||||
void RageDisplay_D3D::SetTextureModeModulate()
|
||||
{
|
||||
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
@@ -702,7 +702,7 @@ void RageDisplay::SetTextureModeModulate()
|
||||
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
|
||||
}
|
||||
|
||||
void RageDisplay::SetTextureModeGlow(GlowMode m)
|
||||
void RageDisplay_D3D::SetTextureModeGlow(GlowMode m)
|
||||
{
|
||||
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
@@ -713,13 +713,13 @@ void RageDisplay::SetTextureModeGlow(GlowMode m)
|
||||
|
||||
}
|
||||
|
||||
void RageDisplay::SetTextureFiltering( bool b )
|
||||
void RageDisplay_D3D::SetTextureFiltering( bool b )
|
||||
{
|
||||
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, b ? D3DTEXF_LINEAR : D3DTEXF_POINT );
|
||||
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, b ? D3DTEXF_LINEAR : D3DTEXF_POINT );
|
||||
}
|
||||
|
||||
void RageDisplay::SetBlendMode( BlendMode mode )
|
||||
void RageDisplay_D3D::SetBlendMode( BlendMode mode )
|
||||
{
|
||||
g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
|
||||
switch( mode )
|
||||
@@ -741,32 +741,32 @@ void RageDisplay::SetBlendMode( BlendMode mode )
|
||||
}
|
||||
}
|
||||
|
||||
bool RageDisplay::IsZBufferEnabled() const
|
||||
bool RageDisplay_D3D::IsZBufferEnabled() const
|
||||
{
|
||||
DWORD b;
|
||||
g_pd3dDevice->GetRenderState( D3DRS_ZENABLE, &b );
|
||||
return b!=0;
|
||||
}
|
||||
|
||||
void RageDisplay::SetZBuffer( bool b )
|
||||
void RageDisplay_D3D::SetZBuffer( bool b )
|
||||
{
|
||||
g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, b ? D3DZB_TRUE : D3DZB_FALSE );
|
||||
g_pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
|
||||
g_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, b );
|
||||
}
|
||||
void RageDisplay::ClearZBuffer()
|
||||
void RageDisplay_D3D::ClearZBuffer()
|
||||
{
|
||||
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
|
||||
}
|
||||
|
||||
void RageDisplay::SetTextureWrapping( bool b )
|
||||
void RageDisplay_D3D::SetTextureWrapping( bool b )
|
||||
{
|
||||
int mode = b ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP;
|
||||
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, mode );
|
||||
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, mode );
|
||||
}
|
||||
|
||||
void RageDisplay::SetMaterial(
|
||||
void RageDisplay_D3D::SetMaterial(
|
||||
float emissive[4],
|
||||
float ambient[4],
|
||||
float diffuse[4],
|
||||
@@ -783,16 +783,16 @@ void RageDisplay::SetMaterial(
|
||||
g_pd3dDevice->SetMaterial( &mat );
|
||||
}
|
||||
|
||||
void RageDisplay::SetLighting( bool b )
|
||||
void RageDisplay_D3D::SetLighting( bool b )
|
||||
{
|
||||
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, b );
|
||||
}
|
||||
|
||||
void RageDisplay::SetLightOff( int index )
|
||||
void RageDisplay_D3D::SetLightOff( int index )
|
||||
{
|
||||
g_pd3dDevice->LightEnable( index, false );
|
||||
}
|
||||
void RageDisplay::SetLightDirectional(
|
||||
void RageDisplay_D3D::SetLightDirectional(
|
||||
int index,
|
||||
RageColor ambient,
|
||||
RageColor diffuse,
|
||||
@@ -812,12 +812,12 @@ void RageDisplay::SetLightDirectional(
|
||||
g_pd3dDevice->SetLight( index, &light );
|
||||
}
|
||||
|
||||
void RageDisplay::SetBackfaceCull( bool b )
|
||||
void RageDisplay_D3D::SetBackfaceCull( bool b )
|
||||
{
|
||||
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, b ? D3DCULL_CW : D3DCULL_NONE );
|
||||
}
|
||||
|
||||
void RageDisplay::DeleteTexture( unsigned uTexHandle )
|
||||
void RageDisplay_D3D::DeleteTexture( unsigned uTexHandle )
|
||||
{
|
||||
IDirect3DTexture8* pTex = (IDirect3DTexture8*) uTexHandle;
|
||||
pTex->Release();
|
||||
@@ -830,7 +830,7 @@ void RageDisplay::DeleteTexture( unsigned uTexHandle )
|
||||
}
|
||||
|
||||
|
||||
unsigned RageDisplay::CreateTexture(
|
||||
unsigned RageDisplay_D3D::CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface*& img )
|
||||
{
|
||||
@@ -869,7 +869,7 @@ unsigned RageDisplay::CreateTexture(
|
||||
return uTexHandle;
|
||||
}
|
||||
|
||||
void RageDisplay::UpdateTexture(
|
||||
void RageDisplay_D3D::UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface*& img,
|
||||
@@ -905,14 +905,14 @@ void RageDisplay::UpdateTexture(
|
||||
// NULL );
|
||||
}
|
||||
|
||||
void RageDisplay::SetAlphaTest( bool b )
|
||||
void RageDisplay_D3D::SetAlphaTest( bool b )
|
||||
{
|
||||
g_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, b );
|
||||
g_pd3dDevice->SetRenderState( D3DRS_ALPHAREF, 0 );
|
||||
g_pd3dDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATER );
|
||||
}
|
||||
|
||||
RageMatrix RageDisplay::GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf )
|
||||
RageMatrix RageDisplay_D3D::GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf )
|
||||
{
|
||||
// D3DXMatrixOrthoOffCenterRH
|
||||
RageMatrix m(
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace GLExt {
|
||||
};
|
||||
|
||||
#include "RageDisplay.h"
|
||||
#include "RageDisplay_OGL.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageTimer.h"
|
||||
@@ -62,8 +63,6 @@ namespace GLExt {
|
||||
|
||||
#include <math.h>
|
||||
|
||||
RageDisplay* DISPLAY = NULL;
|
||||
|
||||
|
||||
//
|
||||
// Globals
|
||||
@@ -106,9 +105,9 @@ void GetGLExtensions(set<string> &ext)
|
||||
ext.insert(lst[i]);
|
||||
}
|
||||
|
||||
RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
|
||||
RageDisplay_OGL::RageDisplay_OGL( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
|
||||
{
|
||||
LOG->Trace( "RageDisplay::RageDisplay()" );
|
||||
LOG->Trace( "RageDisplay_OGL::RageDisplay()" );
|
||||
|
||||
wind = MakeLowLevelWindow();
|
||||
|
||||
@@ -134,19 +133,19 @@ RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rat
|
||||
LOG->Info("Point size range: %.3f-%.3f +%.3f", g_point_range[0], g_point_range[1], g_point_granularity);
|
||||
}
|
||||
|
||||
void RageDisplay::Update(float fDeltaTime)
|
||||
void RageDisplay_OGL::Update(float fDeltaTime)
|
||||
{
|
||||
wind->Update(fDeltaTime);
|
||||
}
|
||||
|
||||
bool RageDisplay::IsSoftwareRenderer()
|
||||
bool RageDisplay_OGL::IsSoftwareRenderer()
|
||||
{
|
||||
return
|
||||
( strcmp((const char*)glGetString(GL_VENDOR),"Microsoft Corporation")==0 ) &&
|
||||
( strcmp((const char*)glGetString(GL_RENDERER),"GDI Generic")==0 );
|
||||
}
|
||||
|
||||
RageDisplay::~RageDisplay()
|
||||
RageDisplay_OGL::~RageDisplay_OGL()
|
||||
{
|
||||
delete wind;
|
||||
}
|
||||
@@ -247,7 +246,7 @@ void DumpOpenGLDebugInfo()
|
||||
#endif
|
||||
}
|
||||
|
||||
void RageDisplay::ResolutionChanged()
|
||||
void RageDisplay_OGL::ResolutionChanged()
|
||||
{
|
||||
SetViewport(0,0);
|
||||
|
||||
@@ -258,9 +257,9 @@ void RageDisplay::ResolutionChanged()
|
||||
|
||||
/* Set the video mode. In some cases, changing the video mode will reset
|
||||
* the rendering context; returns true if we need to reload textures. */
|
||||
bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
|
||||
bool RageDisplay_OGL::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
|
||||
{
|
||||
// LOG->Trace( "RageDisplay::SetVideoMode( %d, %d, %d, %d, %d, %d )", windowed, width, height, bpp, rate, vsync );
|
||||
// LOG->Trace( "RageDisplay_OGL::SetVideoMode( %d, %d, %d, %d, %d, %d )", windowed, width, height, bpp, rate, vsync );
|
||||
bool NewOpenGLContext = wind->SetVideoMode( windowed, width, height, bpp, rate, vsync, sWindowTitle, sIconFile );
|
||||
|
||||
if(NewOpenGLContext)
|
||||
@@ -288,7 +287,7 @@ bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, i
|
||||
return NewOpenGLContext;
|
||||
}
|
||||
|
||||
void RageDisplay::SetViewport(int shift_left, int shift_down)
|
||||
void RageDisplay_OGL::SetViewport(int shift_left, int shift_down)
|
||||
{
|
||||
/* left and down are on a 0..SCREEN_WIDTH, 0..SCREEN_HEIGHT scale.
|
||||
* Scale them to the actual viewport range. */
|
||||
@@ -298,26 +297,26 @@ void RageDisplay::SetViewport(int shift_left, int shift_down)
|
||||
glViewport(shift_left, -shift_down, wind->GetWidth(), wind->GetHeight());
|
||||
}
|
||||
|
||||
int RageDisplay::GetMaxTextureSize() const
|
||||
int RageDisplay_OGL::GetMaxTextureSize() const
|
||||
{
|
||||
GLint size;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
void RageDisplay::BeginFrame()
|
||||
void RageDisplay_OGL::BeginFrame()
|
||||
{
|
||||
glClearColor( 0,0,0,1 );
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
}
|
||||
|
||||
void RageDisplay::EndFrame()
|
||||
void RageDisplay_OGL::EndFrame()
|
||||
{
|
||||
wind->SwapBuffers();
|
||||
ProcessStatsOnFlip();
|
||||
}
|
||||
|
||||
bool RageDisplay::SupportsTextureFormat( PixelFormat pixfmt )
|
||||
bool RageDisplay_OGL::SupportsTextureFormat( PixelFormat pixfmt )
|
||||
{
|
||||
switch( pixfmt )
|
||||
{
|
||||
@@ -328,7 +327,7 @@ bool RageDisplay::SupportsTextureFormat( PixelFormat pixfmt )
|
||||
}
|
||||
}
|
||||
|
||||
void RageDisplay::SaveScreenshot( CString sPath )
|
||||
void RageDisplay_OGL::SaveScreenshot( CString sPath )
|
||||
{
|
||||
ASSERT( sPath.Right(3).CompareNoCase("bmp") == 0 ); // we can only save bitmaps
|
||||
|
||||
@@ -357,13 +356,58 @@ void RageDisplay::SaveScreenshot( CString sPath )
|
||||
}
|
||||
|
||||
|
||||
bool RageDisplay::IsWindowed() const { return wind->IsWindowed(); }
|
||||
int RageDisplay::GetWidth() const { return wind->GetWidth(); }
|
||||
int RageDisplay::GetHeight() const { return wind->GetHeight(); }
|
||||
int RageDisplay::GetBPP() const { return wind->GetBPP(); }
|
||||
bool RageDisplay_OGL::IsWindowed() const { return wind->IsWindowed(); }
|
||||
int RageDisplay_OGL::GetWidth() const { return wind->GetWidth(); }
|
||||
int RageDisplay_OGL::GetHeight() const { return wind->GetHeight(); }
|
||||
int RageDisplay_OGL::GetBPP() const { return wind->GetBPP(); }
|
||||
|
||||
static void SetupVertices( const RageVertex v[], int iNumVerts )
|
||||
{
|
||||
static float *Vertex, *Texture, *Normal;
|
||||
static GLubyte *Color;
|
||||
static int Size = 0;
|
||||
if(iNumVerts > Size)
|
||||
{
|
||||
Size = iNumVerts;
|
||||
delete [] Vertex;
|
||||
delete [] Color;
|
||||
delete [] Texture;
|
||||
delete [] Normal;
|
||||
Vertex = new float[Size*3];
|
||||
Color = new GLubyte[Size*4];
|
||||
Texture = new float[Size*2];
|
||||
Normal = new float[Size*3];
|
||||
}
|
||||
|
||||
void RageDisplay::DrawQuads( const RageVertex v[], int iNumVerts )
|
||||
for(unsigned i = 0; i < unsigned(iNumVerts); ++i)
|
||||
{
|
||||
Vertex[i*3+0] = v[i].p[0];
|
||||
Vertex[i*3+1] = v[i].p[1];
|
||||
Vertex[i*3+2] = v[i].p[2];
|
||||
Color[i*4+0] = v[i].c.r;
|
||||
Color[i*4+1] = v[i].c.g;
|
||||
Color[i*4+2] = v[i].c.b;
|
||||
Color[i*4+3] = v[i].c.a;
|
||||
Texture[i*2+0] = v[i].t[0];
|
||||
Texture[i*2+1] = v[i].t[1];
|
||||
Normal[i*2+0] = v[i].n[0];
|
||||
Normal[i*2+1] = v[i].n[1];
|
||||
Normal[i*2+2] = v[i].n[2];
|
||||
}
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, 0, Vertex);
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, Color);
|
||||
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, Texture);
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, 0, Texture);
|
||||
}
|
||||
|
||||
void RageDisplay_OGL::DrawQuads( const RageVertex v[], int iNumVerts )
|
||||
{
|
||||
ASSERT( (iNumVerts%4) == 0 );
|
||||
|
||||
@@ -375,75 +419,37 @@ void RageDisplay::DrawQuads( const RageVertex v[], int iNumVerts )
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadMatrixf( (const float*)GetModelViewTop() );
|
||||
|
||||
#if 1
|
||||
static float *Vertex, *Color, *Texture;
|
||||
static int Size = 0;
|
||||
if(iNumVerts > Size)
|
||||
{
|
||||
Size = iNumVerts;
|
||||
delete [] Vertex;
|
||||
delete [] Color;
|
||||
delete [] Texture;
|
||||
Vertex = new float[Size*3];
|
||||
Color = new float[Size*4];
|
||||
Texture = new float[Size*2];
|
||||
}
|
||||
|
||||
for(unsigned i = 0; i < unsigned(iNumVerts); ++i)
|
||||
{
|
||||
Vertex[i*3+0] = v[i].p[0];
|
||||
Vertex[i*3+1] = v[i].p[1];
|
||||
Vertex[i*3+2] = v[i].p[2];
|
||||
Color[i*4+0] = v[i].c[0];
|
||||
Color[i*4+1] = v[i].c[1];
|
||||
Color[i*4+2] = v[i].c[2];
|
||||
Color[i*4+3] = v[i].c[3];
|
||||
Texture[i*2+0] = v[i].t[0];
|
||||
Texture[i*2+1] = v[i].t[1];
|
||||
}
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, 0, Vertex);
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_FLOAT, 0, Color);
|
||||
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, Texture);
|
||||
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
#else
|
||||
glInterleavedArrays( RageVertexFormat, sizeof(RageVertex), v );
|
||||
#endif
|
||||
|
||||
SetupVertices( v, iNumVerts );
|
||||
glDrawArrays( GL_QUADS, 0, iNumVerts );
|
||||
|
||||
StatsAddVerts( iNumVerts );
|
||||
}
|
||||
void RageDisplay::DrawFan( const RageVertex v[], int iNumVerts )
|
||||
|
||||
void RageDisplay_OGL::DrawFan( const RageVertex v[], int iNumVerts )
|
||||
{
|
||||
ASSERT( iNumVerts >= 3 );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadMatrixf( (const float*)GetProjection() );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadMatrixf( (const float*)GetModelViewTop() );
|
||||
glInterleavedArrays( RageVertexFormat, sizeof(RageVertex), v );
|
||||
SetupVertices( v, iNumVerts );
|
||||
glDrawArrays( GL_TRIANGLE_FAN, 0, iNumVerts );
|
||||
StatsAddVerts( iNumVerts );
|
||||
}
|
||||
|
||||
void RageDisplay::DrawStrip( const RageVertex v[], int iNumVerts )
|
||||
void RageDisplay_OGL::DrawStrip( const RageVertex v[], int iNumVerts )
|
||||
{
|
||||
ASSERT( iNumVerts >= 3 );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadMatrixf( (const float*)GetProjection() );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadMatrixf( (const float*)GetModelViewTop() );
|
||||
glInterleavedArrays( RageVertexFormat, sizeof(RageVertex), v );
|
||||
SetupVertices( v, iNumVerts );
|
||||
glDrawArrays( GL_TRIANGLE_STRIP, 0, iNumVerts );
|
||||
StatsAddVerts( iNumVerts );
|
||||
}
|
||||
|
||||
void RageDisplay::DrawTriangles( const RageVertex v[], int iNumVerts )
|
||||
void RageDisplay_OGL::DrawTriangles( const RageVertex v[], int iNumVerts )
|
||||
{
|
||||
if( iNumVerts == 0 )
|
||||
return;
|
||||
@@ -453,12 +459,12 @@ void RageDisplay::DrawTriangles( const RageVertex v[], int iNumVerts )
|
||||
glLoadMatrixf( (const float*)GetProjection() );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadMatrixf( (const float*)GetModelViewTop() );
|
||||
glInterleavedArrays( RageVertexFormat, sizeof(RageVertex), v );
|
||||
SetupVertices( v, iNumVerts );
|
||||
glDrawArrays( GL_TRIANGLES, 0, iNumVerts );
|
||||
StatsAddVerts( iNumVerts );
|
||||
}
|
||||
|
||||
void RageDisplay::DrawIndexedTriangles( const RageVertex v[], const Uint16 pIndices[], int iNumIndices )
|
||||
void RageDisplay_OGL::DrawIndexedTriangles( const RageVertex v[], const Uint16 pIndices[], int iNumIndices )
|
||||
{
|
||||
if( iNumIndices == 0 )
|
||||
return;
|
||||
@@ -468,7 +474,13 @@ void RageDisplay::DrawIndexedTriangles( const RageVertex v[], const Uint16 pIndi
|
||||
glLoadMatrixf( (const float*)GetProjection() );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadMatrixf( (const float*)GetModelViewTop() );
|
||||
glInterleavedArrays( RageVertexFormat, sizeof(RageVertex), v );
|
||||
|
||||
/* XXX: This is ugly. */
|
||||
int iNumVerts = 0;
|
||||
for(int i = 0; i < iNumIndices; ++i)
|
||||
iNumVerts = max(iNumVerts, (int) pIndices[i]);
|
||||
SetupVertices( v, iNumVerts );
|
||||
// glInterleavedArrays( RageVertexFormat, sizeof(RageVertex), v );
|
||||
glDrawElements( GL_TRIANGLES, iNumIndices, GL_UNSIGNED_SHORT, pIndices );
|
||||
StatsAddVerts( iNumIndices );
|
||||
}
|
||||
@@ -506,7 +518,7 @@ void DrawPolyLine(const RageVertex &p1, const RageVertex &p2, float LineWidth )
|
||||
DISPLAY->DrawQuad(v);
|
||||
}
|
||||
|
||||
void RageDisplay::DrawLineStrip( const RageVertex v[], int iNumVerts, float LineWidth )
|
||||
void RageDisplay_OGL::DrawLineStrip( const RageVertex v[], int iNumVerts, float LineWidth )
|
||||
{
|
||||
ASSERT( iNumVerts >= 2 );
|
||||
|
||||
@@ -529,7 +541,7 @@ void RageDisplay::DrawLineStrip( const RageVertex v[], int iNumVerts, float Line
|
||||
for(i = 0; i < iNumVerts; ++i)
|
||||
{
|
||||
glPushMatrix();
|
||||
glColor4fv(v[i].c);
|
||||
glColor4ub(v[i].c.r, v[i].c.g, v[i].c.b, v[i].c.a);
|
||||
glTexCoord3fv(v[i].t);
|
||||
glTranslatef(v[i].p.x, v[i].p.y, v[i].p.z);
|
||||
|
||||
@@ -564,7 +576,7 @@ void RageDisplay::DrawLineStrip( const RageVertex v[], int iNumVerts, float Line
|
||||
glLineWidth(LineWidth);
|
||||
|
||||
/* Draw the line loop: */
|
||||
glInterleavedArrays( RageVertexFormat, sizeof(RageVertex), v );
|
||||
SetupVertices( v, iNumVerts );
|
||||
glDrawArrays( GL_LINE_STRIP, 0, iNumVerts );
|
||||
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
@@ -589,25 +601,25 @@ void RageDisplay::DrawLineStrip( const RageVertex v[], int iNumVerts, float Line
|
||||
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
|
||||
glInterleavedArrays( RageVertexFormat, sizeof(RageVertex), v );
|
||||
SetupVertices( v, iNumVerts );
|
||||
glDrawArrays( GL_POINTS, 0, iNumVerts );
|
||||
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
}
|
||||
}
|
||||
|
||||
void RageDisplay::SetTexture( RageTexture* pTexture )
|
||||
void RageDisplay_OGL::SetTexture( RageTexture* pTexture )
|
||||
{
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
unsigned id = pTexture ? pTexture->GetTexHandle() : 0;
|
||||
glBindTexture( GL_TEXTURE_2D, id );
|
||||
}
|
||||
void RageDisplay::SetTextureModeModulate()
|
||||
void RageDisplay_OGL::SetTextureModeModulate()
|
||||
{
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
|
||||
void RageDisplay::SetTextureModeGlow(GlowMode m)
|
||||
void RageDisplay_OGL::SetTextureModeGlow(GlowMode m)
|
||||
{
|
||||
if(m == GLOW_WHITEN && !g_bEXT_texture_env_combine)
|
||||
m = GLOW_BRIGHTEN; /* we can't do GLOW_WHITEN */
|
||||
@@ -633,12 +645,12 @@ void RageDisplay::SetTextureModeGlow(GlowMode m)
|
||||
return;
|
||||
}
|
||||
}
|
||||
void RageDisplay::SetTextureFiltering( bool b )
|
||||
void RageDisplay_OGL::SetTextureFiltering( bool b )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RageDisplay::SetBlendMode( BlendMode mode )
|
||||
void RageDisplay_OGL::SetBlendMode( BlendMode mode )
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
@@ -658,14 +670,14 @@ void RageDisplay::SetBlendMode( BlendMode mode )
|
||||
}
|
||||
}
|
||||
|
||||
bool RageDisplay::IsZBufferEnabled() const
|
||||
bool RageDisplay_OGL::IsZBufferEnabled() const
|
||||
{
|
||||
bool a;
|
||||
glGetBooleanv( GL_DEPTH_TEST, (unsigned char*)&a );
|
||||
return a;
|
||||
}
|
||||
|
||||
void RageDisplay::SetZBuffer( bool b )
|
||||
void RageDisplay_OGL::SetZBuffer( bool b )
|
||||
{
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
if( b )
|
||||
@@ -673,19 +685,19 @@ void RageDisplay::SetZBuffer( bool b )
|
||||
else
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
}
|
||||
void RageDisplay::ClearZBuffer()
|
||||
void RageDisplay_OGL::ClearZBuffer()
|
||||
{
|
||||
glClear( GL_DEPTH_BUFFER_BIT );
|
||||
}
|
||||
|
||||
void RageDisplay::SetTextureWrapping( bool b )
|
||||
void RageDisplay_OGL::SetTextureWrapping( bool b )
|
||||
{
|
||||
GLenum mode = b ? GL_REPEAT : GL_CLAMP;
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode );
|
||||
}
|
||||
|
||||
void RageDisplay::SetMaterial(
|
||||
void RageDisplay_OGL::SetMaterial(
|
||||
float emissive[4],
|
||||
float ambient[4],
|
||||
float diffuse[4],
|
||||
@@ -700,17 +712,17 @@ void RageDisplay::SetMaterial(
|
||||
glMaterialf( GL_FRONT, GL_SHININESS, shininess );
|
||||
}
|
||||
|
||||
void RageDisplay::SetLighting( bool b )
|
||||
void RageDisplay_OGL::SetLighting( bool b )
|
||||
{
|
||||
if( b ) glEnable( GL_LIGHTING );
|
||||
else glDisable( GL_LIGHTING );
|
||||
}
|
||||
|
||||
void RageDisplay::SetLightOff( int index )
|
||||
void RageDisplay_OGL::SetLightOff( int index )
|
||||
{
|
||||
glDisable( GL_LIGHT0+index );
|
||||
}
|
||||
void RageDisplay::SetLightDirectional(
|
||||
void RageDisplay_OGL::SetLightDirectional(
|
||||
int index,
|
||||
RageColor ambient,
|
||||
RageColor diffuse,
|
||||
@@ -732,7 +744,7 @@ void RageDisplay::SetLightDirectional(
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void RageDisplay::SetBackfaceCull( bool b )
|
||||
void RageDisplay_OGL::SetBackfaceCull( bool b )
|
||||
{
|
||||
if( b )
|
||||
glEnable( GL_CULL_FACE );
|
||||
@@ -783,7 +795,7 @@ static const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
|
||||
}
|
||||
};
|
||||
|
||||
const PixelFormatDesc *RageDisplay::GetPixelFormatDesc(PixelFormat pf) const
|
||||
const PixelFormatDesc *RageDisplay_OGL::GetPixelFormatDesc(PixelFormat pf) const
|
||||
{
|
||||
ASSERT( pf < NUM_PIX_FORMATS );
|
||||
return &PIXEL_FORMAT_DESC[pf];
|
||||
@@ -832,7 +844,7 @@ struct GLPixFmtInfo_t {
|
||||
};
|
||||
|
||||
|
||||
void RageDisplay::DeleteTexture( unsigned uTexHandle )
|
||||
void RageDisplay_OGL::DeleteTexture( unsigned uTexHandle )
|
||||
{
|
||||
unsigned int uTexID = uTexHandle;
|
||||
glDeleteTextures(1,reinterpret_cast<GLuint*>(&uTexID));
|
||||
@@ -842,7 +854,7 @@ void RageDisplay::DeleteTexture( unsigned uTexHandle )
|
||||
}
|
||||
|
||||
|
||||
unsigned RageDisplay::CreateTexture(
|
||||
unsigned RageDisplay_OGL::CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface*& img )
|
||||
{
|
||||
@@ -966,7 +978,7 @@ unsigned RageDisplay::CreateTexture(
|
||||
}
|
||||
|
||||
|
||||
void RageDisplay::UpdateTexture(
|
||||
void RageDisplay_OGL::UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface*& img,
|
||||
@@ -997,7 +1009,7 @@ void RageDisplay::UpdateTexture(
|
||||
glFlush();
|
||||
}
|
||||
|
||||
void RageDisplay::SetAlphaTest( bool b )
|
||||
void RageDisplay_OGL::SetAlphaTest( bool b )
|
||||
{
|
||||
glAlphaFunc( GL_GREATER, 0.01f );
|
||||
if( b )
|
||||
@@ -1006,7 +1018,7 @@ void RageDisplay::SetAlphaTest( bool b )
|
||||
glDisable( GL_ALPHA_TEST );
|
||||
}
|
||||
|
||||
RageMatrix RageDisplay::GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf )
|
||||
RageMatrix RageDisplay_OGL::GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf )
|
||||
{
|
||||
RageMatrix m(
|
||||
2/(r-l), 0, 0, 0,
|
||||
|
||||
@@ -188,18 +188,10 @@ typedef Rect<float> RectF;
|
||||
// A structure for our custom vertex type. Note that these data structes have the same layout that D3D expects.
|
||||
struct RageVertex
|
||||
{
|
||||
// Temporary hack. A better solution is coming. -Chris
|
||||
#ifdef D3D
|
||||
RageVector3 p; // position
|
||||
RageVector3 n; // normal
|
||||
RageVColor c; // diffuse color
|
||||
RageVector2 t; // texture coordinates
|
||||
#else
|
||||
RageVector2 t; // texture coordinates
|
||||
RageColor c; // diffuse color
|
||||
RageVector3 n; // normal
|
||||
RageVector3 p; // position
|
||||
#endif
|
||||
};
|
||||
|
||||
/* nonstandard extension used : nameless struct/union
|
||||
|
||||
+46
-10
@@ -16,7 +16,6 @@
|
||||
// Rage global classes
|
||||
//
|
||||
#include "RageLog.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include "RageSoundManager.h"
|
||||
#include "RageInput.h"
|
||||
@@ -24,6 +23,13 @@
|
||||
#include "RageException.h"
|
||||
#include "RageMath.h"
|
||||
#include "RageDisplay.h"
|
||||
#if defined(WIN32)
|
||||
#include "RageDisplay_D3D.h"
|
||||
#endif
|
||||
|
||||
#if !defined(_XBOX)
|
||||
#include "RageDisplay_OGL.h"
|
||||
#endif
|
||||
|
||||
#include "arch/arch.h"
|
||||
#include "arch/LoadingWindow/LoadingWindow.h"
|
||||
@@ -206,6 +212,44 @@ static void BoostAppPri()
|
||||
#endif
|
||||
}
|
||||
|
||||
RageDisplay *CreateDisplay()
|
||||
{
|
||||
/* XXX: Passing all of the SetVideoMode arguments to the ctor is cumbersome. */
|
||||
#if defined(_XBOX)
|
||||
RageDisplay *ret = new RageDisplay_D3D(
|
||||
PREFSMAN->m_bWindowed,
|
||||
PREFSMAN->m_iDisplayWidth,
|
||||
PREFSMAN->m_iDisplayHeight,
|
||||
PREFSMAN->m_iDisplayColorDepth,
|
||||
PREFSMAN->m_iRefreshRate,
|
||||
PREFSMAN->m_bVsync,
|
||||
THEME->GetMetric("Common","WindowTitle"),
|
||||
THEME->GetPathToG("Common window icon") );
|
||||
#elif !defined(WIN32)
|
||||
RageDisplay *ret = new RageDisplay_OGL(
|
||||
PREFSMAN->m_bWindowed,
|
||||
PREFSMAN->m_iDisplayWidth,
|
||||
PREFSMAN->m_iDisplayHeight,
|
||||
PREFSMAN->m_iDisplayColorDepth,
|
||||
PREFSMAN->m_iRefreshRate,
|
||||
PREFSMAN->m_bVsync,
|
||||
THEME->GetMetric("Common","WindowTitle"),
|
||||
THEME->GetPathToG("Common window icon") );
|
||||
#else
|
||||
/* Windows; we have both D3D and OGL available. XXX: do something smart. */
|
||||
RageDisplay *ret = new RageDisplay_OGL(
|
||||
PREFSMAN->m_bWindowed,
|
||||
PREFSMAN->m_iDisplayWidth,
|
||||
PREFSMAN->m_iDisplayHeight,
|
||||
PREFSMAN->m_iDisplayColorDepth,
|
||||
PREFSMAN->m_iRefreshRate,
|
||||
PREFSMAN->m_bVsync,
|
||||
THEME->GetMetric("Common","WindowTitle"),
|
||||
THEME->GetPathToG("Common window icon") );
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void RestoreAppPri()
|
||||
{
|
||||
if(!ChangeAppPri())
|
||||
@@ -279,15 +323,7 @@ int main(int argc, char* argv[])
|
||||
PREFSMAN->ReadGlobalPrefsFromDisk( true );
|
||||
PREFSMAN->ReadGamePrefsFromDisk();
|
||||
|
||||
DISPLAY = new RageDisplay(
|
||||
PREFSMAN->m_bWindowed,
|
||||
PREFSMAN->m_iDisplayWidth,
|
||||
PREFSMAN->m_iDisplayHeight,
|
||||
PREFSMAN->m_iDisplayColorDepth,
|
||||
PREFSMAN->m_iRefreshRate,
|
||||
PREFSMAN->m_bVsync,
|
||||
THEME->GetMetric("Common","WindowTitle"),
|
||||
THEME->GetPathToG("Common window icon") );
|
||||
DISPLAY = CreateDisplay();
|
||||
TEXTUREMAN = new RageTextureManager();
|
||||
TEXTUREMAN->SetPrefs(
|
||||
PREFSMAN->m_iTextureColorDepth,
|
||||
|
||||
Reference in New Issue
Block a user