- Added message queue to DX9 plugin.

- Added plugin interface function Video_AddMessage to both plugins and to the plugin specs.
 - Added handling of the Video_AddMessage interface export from the core side.
 - Added a print on Core::Init for testing purposes (might not be the best place).

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@176 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
gigaherz
2008-08-10 21:34:22 +00:00
parent f5432b874a
commit 0332ec742e
8 changed files with 101 additions and 5 deletions

View File

@ -18,11 +18,23 @@
#include "Utils.h"
#include "EmuWindow.h"
#include <list>
using namespace std;
float Renderer::m_x,Renderer::m_y,Renderer::m_width, Renderer::m_height, Renderer::xScale,Renderer::yScale;
#define NUMWNDRES 6
extern int g_Res[NUMWNDRES][2];
struct MESSAGE
{
MESSAGE() {}
MESSAGE(const char* p, u32 dw) { strcpy(str, p); dwTimeStamp = dw; }
char str[255];
u32 dwTimeStamp;
};
static std::list<MESSAGE> s_listMsgs;
void Renderer::Init(SVideoInitialize &_VideoInitialize)
{
EmuWindow::SetSize(g_Res[g_Config.iWindowedRes][0], g_Res[g_Config.iWindowedRes][1]);
@ -69,6 +81,45 @@ void Renderer::Initialize(void)
CVertexHandler::BeginFrame();
}
void Renderer::AddMessage(const char* pstr, u32 ms)
{
s_listMsgs.push_back(MESSAGE(pstr, timeGetTime()+ms));
}
void Renderer::ProcessMessages()
{
if (s_listMsgs.size() > 0) {
int left = 25, top = 15;
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->str, left+1, top+1, 0x000000|alpha);
RenderText(it->str, left, top, 0xffff30|alpha);
top += 15;
if (time_left <= 0)
it = s_listMsgs.erase(it);
else ++it;
}
}
}
void Renderer::RenderText(const char* pstr, int left, int top, u32 color)
{
D3D::font.DrawTextScaled(left,top,20,20,0.0f,color,pstr,false);
}
void dumpMatrix(D3DXMATRIX &mtx)
{
@ -145,6 +196,8 @@ void Renderer::SwapBuffers(void)
//end frame
}
ProcessMessages();
#if defined(DVPROFILE)
if( g_bWriteProfile ) {
//g_bWriteProfile = 0;

View File

@ -27,4 +27,10 @@ public:
static void SetScissorBox(RECT &rc);
static void SetViewport(float* _Viewport);
static void SetProjection(float* _pProjection, int constantIndex = -1);
static void AddMessage(const char* pstr, unsigned int ms);
static void ProcessMessages();
static void RenderText(const char* pstr, int left, int top, unsigned int color);
};

View File

@ -158,6 +158,9 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize)
_pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages;
_pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay;
_pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle;
Renderer::AddMessage("Dolphin Direct3D9 Video Plugin.",5000);
}
void Video_Prepare(void)
@ -265,3 +268,8 @@ BOOL Video_Screenshot(TCHAR* _szFilename)
return FALSE;
}
void Video_AddMessage(const char* pstr, u32 milliseconds)
{
Renderer::AddMessage(pstr,milliseconds);
}