- Made the message queue actually be processed.

- Made the message prints support alpha transparency.
 - Made the messages fade out when time <=1024.
 - Added a init message as a test for the queue.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@175 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
gigaherz 2008-08-10 21:06:03 +00:00
parent efd15dc2c3
commit f5432b874a
3 changed files with 42 additions and 11 deletions

View File

@ -339,6 +339,7 @@ bool Renderer::Initialize()
GLenum err = GL_NO_ERROR;
GL_REPORT_ERROR();
return err == GL_NO_ERROR;
}
@ -349,26 +350,48 @@ void Renderer::AddMessage(const char* pstr, u32 ms)
void Renderer::ProcessMessages()
{
if (s_listMsgs.size() > 0) {
GLboolean wasEnabled = glIsEnabled(GL_BLEND);
if(!wasEnabled) glEnable(GL_BLEND);
if (s_listMsgs.size() > 0) {
int left = 25, top = 15;
list<MESSAGE>::iterator it = s_listMsgs.begin();
while( it != s_listMsgs.end() )
{
DrawText(it->str, left+1, top+1, 0xff000000);
DrawText(it->str, left, top, 0xffffff30);
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 ((int)(it->dwTimeStamp - timeGetTime()) < 0)
if (time_left <= 0)
it = s_listMsgs.erase(it);
else ++it;
}
}
if(!wasEnabled) glDisable(GL_BLEND);
}
void Renderer::DrawText(const char* pstr, int left, int top, u32 color)
void Renderer::RenderText(const char* pstr, int left, int top, u32 color)
{
glColor3f(((color>>16) & 0xff)/255.0f, ((color>>8) & 0xff)/255.0f, (color & 0xff)/255.0f);
glColor4f(
((color>>16) & 0xff)/255.0f,
((color>> 8) & 0xff)/255.0f,
((color>> 0) & 0xff)/255.0f,
((color>>24) & 0xFF)/255.0f
);
s_pfont->printMultilineText(pstr, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight,0,nBackbufferWidth,nBackbufferHeight);
}
@ -660,7 +683,7 @@ void Renderer::Swap(const TRectangle& rc)
//
// char strfps[25];
// sprintf(strfps, "fps: %2.1f\n", s_fps);
// Renderer::DrawText(strfps, 20, 20, 0xFF00FFFF);
// Renderer::RenderText(strfps, 20, 20, 0xFF00FFFF);
if (g_Config.bOverlayStats) {
char st[2048];
@ -687,9 +710,11 @@ void Renderer::Swap(const TRectangle& rc)
p+=sprintf(p,"Num BP loads: %i\n",stats.thisFrame.numBPLoads);
p+=sprintf(p,"Num BP loads (DL): %i\n",stats.thisFrame.numBPLoadsInDL);
Renderer::DrawText(st, 20, 20, 0xFF00FFFF);
Renderer::RenderText(st, 20, 20, 0xFF00FFFF);
}
Renderer::ProcessMessages();
#if defined(DVPROFILE)
if (g_bWriteProfile) {
//g_bWriteProfile = 0;
@ -706,6 +731,9 @@ void Renderer::Swap(const TRectangle& rc)
// copy the rendered from to the real window
OpenGL_SwapBuffers();
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
GL_REPORT_ERRORD();
//clean out old stuff from caches

View File

@ -45,7 +45,7 @@ public:
static void AddMessage(const char* str, u32 ms);
static void ProcessMessages(); // draw the current messages on the screen
static void DrawText(const char* pstr, int left, int top, u32 color);
static void RenderText(const char* pstr, int left, int top, u32 color);
static void SetAA(int aa); // sets the anti-aliasing level
static void ReinitView(int nNewWidth, int nNewHeight);

View File

@ -151,6 +151,9 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize)
_pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages;
_pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay;
_pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle;
Renderer::AddMessage("Dolphin OpenGL Video Plugin v" VERSION_STRING ,5000);
}
@ -210,8 +213,8 @@ bool ScreenShot(TCHAR *File)
sprintf(str, "Dolphin OGL " VERSION_STRING);
Renderer::ResetGLState();
Renderer::DrawText(str, left+1, top+1, 0xff000000);
Renderer::DrawText(str, left, top, 0xffc0ffff);
Renderer::RenderText(str, left+1, top+1, 0xff000000);
Renderer::RenderText(str, left, top, 0xffc0ffff);
Renderer::RestoreGLState();
if (Renderer::SaveRenderTarget(File, 0)) {