Moving more things out of GL into VideoCommon...

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4187 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-09-03 20:37:35 +00:00
parent fd06a656f5
commit baede3a7f3
21 changed files with 144 additions and 250 deletions

View File

@ -1206,10 +1206,6 @@
RelativePath=".\Src\Render.cpp"
>
</File>
<File
RelativePath=".\Src\Render.h"
>
</File>
<File
RelativePath=".\Src\TextureCache.cpp"
>

View File

@ -37,35 +37,27 @@
#include "Utils.h"
#include "EmuWindow.h"
#include "AVIDump.h"
#include "OnScreenDisplay.h"
#include "debugger/debugger.h"
float Renderer::m_x;
float Renderer::m_y;
float Renderer::m_width;
float Renderer::m_height;
float Renderer::xScale;
float Renderer::yScale;
static float m_x;
static float m_y;
static float m_width;
static float m_height;
static float xScale;
static float yScale;
int Renderer::m_recordWidth;
int Renderer::m_recordHeight;
static int m_recordWidth;
static int m_recordHeight;
bool Renderer::m_LastFrameDumped;
bool Renderer::m_AVIDumping;
static bool m_LastFrameDumped;
static bool m_AVIDumping;
#define NUMWNDRES 6
extern int g_Res[NUMWNDRES][2];
struct Message
{
Message(const std::string &msg, u32 dw) : message(msg), dwTimeStamp(dw) { }
std::string message;
u32 dwTimeStamp;
};
static std::list<Message> s_listMsgs;
void Renderer::Init(SVideoInitialize &_VideoInitialize)
bool Renderer::Init()
{
EmuWindow::SetSize(g_Res[g_Config.iWindowedRes][0], g_Res[g_Config.iWindowedRes][1]);
@ -91,7 +83,13 @@ void Renderer::Init(SVideoInitialize &_VideoInitialize)
D3D::dev->SetTransform(D3DTS_VIEW, &mtx);
D3D::dev->SetTransform(D3DTS_WORLD, &mtx);
D3D::font.Init();
Initialize();
for (int i = 0; i < 8; i++)
D3D::dev->SetSamplerState(i, D3DSAMP_MAXANISOTROPY, 16);
D3D::BeginFrame(true, 0);
VertexManager::BeginFrame();
return true;
}
void Renderer::Shutdown()
@ -100,54 +98,20 @@ void Renderer::Shutdown()
D3D::EndFrame();
D3D::Close();
if(m_AVIDumping) {
if (m_AVIDumping)
{
AVIDump::Stop();
}
}
void Renderer::Initialize()
float Renderer::GetTargetScaleX()
{
for (int i = 0; i < 8; i++)
D3D::dev->SetSamplerState(i, D3DSAMP_MAXANISOTROPY, 16);
D3D::BeginFrame(true, 0);
VertexManager::BeginFrame();
return xScale;
}
void Renderer::AddMessage(const std::string &message, u32 ms)
float Renderer::GetTargetScaleY()
{
s_listMsgs.push_back(Message(message, timeGetTime()+ms));
}
void Renderer::ProcessMessages()
{
if (s_listMsgs.size() > 0)
{
int left = 25, top = 15;
std::list<Message>::iterator it = s_listMsgs.begin();
while (it != s_listMsgs.end())
{
int time_left = (int)(it->dwTimeStamp - timeGetTime());
int alpha = 255;
if (time_left<1024)
{
alpha=time_left>>2;
if (time_left<0) alpha=0;
}
alpha <<= 24;
RenderText(it->message.c_str(), left+1, top+1, 0x000000|alpha);
RenderText(it->message.c_str(), left, top, 0xffff30|alpha);
top += 15;
if (time_left <= 0)
it = s_listMsgs.erase(it);
else ++it;
}
}
return yScale;
}
void Renderer::RenderText(const char *text, int left, int top, u32 color)
@ -208,7 +172,7 @@ void Renderer::SwapBuffers()
} else {
char msg [255];
sprintf(msg, "Dumping Frames to \"%s/framedump0.avi\" (%dx%d RGB24)", FULL_FRAMES_DIR, m_recordWidth, m_recordHeight);
AddMessage(msg, 2000);
OSD::AddMessage(msg, 2000);
}
}
if (m_AVIDumping) {
@ -254,7 +218,7 @@ void Renderer::SwapBuffers()
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false);
}
ProcessMessages();
OSD::DrawMessages();
#if defined(DVPROFILE)
if (g_bWriteProfile) {

View File

@ -1,73 +0,0 @@
// Copyright (C) 2003 Dolphin Project.
// This program 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, version 2.0.
// This program 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef __H_RENDER__
#define __H_RENDER__
#include <vector>
#include <string>
#include "pluginspecs_video.h"
#include "D3DBase.h"
class Renderer
{
public:
static void Init(SVideoInitialize &_VideoInitialize);
static void Shutdown();
static void Initialize();
// must be called if the window size has changed
static void ReinitView();
static void SwapBuffers();
static void SetColorMask();
static void SetBlendMode(bool forceUpdate);
static bool SetScissorRect();
static float GetTargetScaleX() { return xScale; }
static float GetTargetScaleY() { return yScale; }
static float GetTargetWidth() { return m_width; }
static float GetTargetHeight() { return m_height; }
// static void SetProjection(float* _pProjection, int constantIndex = -1);
static u32 AccessEFB(EFBAccessType type, int x, int y);
// The little status display.
static void AddMessage(const std::string &message, unsigned int ms);
static void ProcessMessages();
static void RenderText(const char *pstr, int left, int top, unsigned int color);
private:
// screen offset
static float m_x;
static float m_y;
static float m_width;
static float m_height;
static float xScale;
static float yScale;
static bool m_LastFrameDumped;
static bool m_AVIDumping;
static int m_recordWidth;
static int m_recordHeight;
static std::vector<LPDIRECT3DBASETEXTURE9> m_Textures;
};
#endif // __H_RENDER__

View File

@ -43,6 +43,7 @@ GFXDebuggerDX9 *m_DebuggerFrame = NULL;
#include "PixelShaderManager.h"
#include "VertexShaderCache.h"
#include "PixelShaderCache.h"
#include "OnScreenDisplay.h"
#include "DlgSettings.h"
#include "D3DTexture.h"
#include "D3DUtil.h"
@ -271,8 +272,7 @@ void Initialize(void *init)
_pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay;
_pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle;
Renderer::AddMessage("Dolphin Direct3D9 Video Plugin.",5000);
OSD::AddMessage("Dolphin Direct3D9 Video Plugin.",5000);
}
void DoState(unsigned char **ptr, int mode) {
@ -300,7 +300,7 @@ void Video_SetRendering(bool bEnabled) {
void Video_Prepare(void)
{
Renderer::Init(g_VideoInitialize);
Renderer::Init();
TextureCache::Init();
@ -368,7 +368,7 @@ void Video_EndField()
void Video_AddMessage(const char* pstr, u32 milliseconds)
{
Renderer::AddMessage(pstr,milliseconds);
OSD::AddMessage(pstr,milliseconds);
}
HRESULT ScreenShot(const char *File)
@ -409,7 +409,7 @@ void Video_Screenshot(const char *_szFilename)
else {
std::string message = "Saved ";
message += _szFilename;
Renderer::AddMessage(message, 2000);
OSD::AddMessage(message.c_str(), 2000);
}
}