From f5432b874ac7e69b2e8572f71fcc7732eb130311 Mon Sep 17 00:00:00 2001 From: gigaherz Date: Sun, 10 Aug 2008 21:06:03 +0000 Subject: [PATCH] - 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 --- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 44 +++++++++++++++---- Source/Plugins/Plugin_VideoOGL/Src/Render.h | 2 +- Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 7 ++- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index d32ea1be5d..7c08dfab7e 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -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::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 diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.h b/Source/Plugins/Plugin_VideoOGL/Src/Render.h index b5733de08e..ffb651ac1a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.h @@ -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); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 9afa73aff4..a1c2aae131 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -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)) {