Merge pull request #1736 from degasus/osd

OSD
This commit is contained in:
Ryan Houdek
2014-12-20 23:21:24 -06:00
7 changed files with 136 additions and 192 deletions

View File

@ -118,11 +118,12 @@ static const u8 rasters[CHAR_COUNT][CHAR_HEIGHT] = {
static const char *s_vertexShaderSrc =
"uniform vec2 charSize;\n"
"uniform vec2 offset;"
"in vec2 rawpos;\n"
"in vec2 tex0;\n"
"out vec2 uv0;\n"
"void main(void) {\n"
" gl_Position = vec4(rawpos,0,1);\n"
" gl_Position = vec4(rawpos + offset,0,1);\n"
" uv0 = tex0 * charSize;\n"
"}\n";
@ -166,7 +167,8 @@ RasterFont::RasterFont()
glUniform2f(glGetUniformLocation(s_shader.glprogid,"charSize"), 1.0f / GLfloat(CHAR_COUNT), 1.0f);
uniform_color_id = glGetUniformLocation(s_shader.glprogid,"color");
glUniform4f(uniform_color_id, 1.0f, 1.0f, 1.0f, 1.0f);
cached_color = -1;
uniform_offset_id = glGetUniformLocation(s_shader.glprogid, "offset");
glUniform2f(uniform_offset_id, 0.0f, 0.0f);
// generate VBO & VAO
glGenBuffers(1, &VBO);
@ -263,13 +265,13 @@ void RasterFont::printMultilineText(const std::string& text, double start_x, dou
s_shader.Bind();
if (color != cached_color)
{
glUniform4f(uniform_color_id, GLfloat((color>>16)&0xff)/255.f,GLfloat((color>>8)&0xff)/255.f,GLfloat((color>>0)&0xff)/255.f,GLfloat((color>>24)&0xff)/255.f);
cached_color = color;
}
// shadows
glUniform2f(uniform_offset_id, 2.0f / GLfloat(bbWidth), -2.0f / GLfloat(bbHeight));
glUniform4f(uniform_color_id, 0.0f, 0.0f, 0.0f, GLfloat((color>>24)&0xff)/255.f);
glDrawArrays(GL_TRIANGLES, 0, usage/4);
glActiveTexture(GL_TEXTURE0+8);
glUniform2f(uniform_offset_id, 0.0f, 0.0f);
glUniform4f(uniform_color_id, GLfloat((color>>16)&0xff)/255.f,GLfloat((color>>8)&0xff)/255.f,GLfloat((color>>0)&0xff)/255.f,GLfloat((color>>24)&0xff)/255.f);
glDrawArrays(GL_TRIANGLES, 0, usage/4);
}

View File

@ -25,7 +25,7 @@ private:
u32 VAO;
u32 texture;
u32 uniform_color_id;
u32 cached_color;
u32 uniform_offset_id;
};
}

View File

@ -12,14 +12,12 @@
#include "Common/Atomic.h"
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/Profiler.h"
#include "Common/StringUtil.h"
#include "Common/Thread.h"
#include "Common/Timer.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/Movie.h"
#include "VideoBackends/OGL/BoundingBox.h"
#include "VideoBackends/OGL/FramebufferManager.h"
@ -721,40 +719,8 @@ void Renderer::Init()
}
// Create On-Screen-Messages
void Renderer::DrawDebugInfo()
void Renderer::ShowEfbCopyRegions()
{
// Reset viewport for drawing text
glViewport(0, 0, GLInterface->GetBackBufferWidth(), GLInterface->GetBackBufferHeight());
// Draw various messages on the screen, like FPS, statistics, etc.
std::string debug_info;
if (g_ActiveConfig.bShowFPS || SConfig::GetInstance().m_ShowFrameCount)
{
std::string fps = "";
if (g_ActiveConfig.bShowFPS)
debug_info += StringFromFormat("FPS: %d", m_fps_counter.m_fps);
if (g_ActiveConfig.bShowFPS && SConfig::GetInstance().m_ShowFrameCount)
debug_info += " - ";
if (SConfig::GetInstance().m_ShowFrameCount)
{
debug_info += StringFromFormat("Frame: %llu", (unsigned long long) Movie::g_currentFrame);
if (Movie::IsPlayingInput())
debug_info += StringFromFormat(" / %llu", (unsigned long long) Movie::g_totalFrames);
}
debug_info += "\n";
}
if (SConfig::GetInstance().m_ShowLag)
debug_info += StringFromFormat("Lag: %" PRIu64 "\n", Movie::g_currentLagCount);
if (SConfig::GetInstance().m_ShowInputDisplay)
debug_info += Movie::GetInputDisplay();
debug_info += Profiler::ToString();
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL && g_ActiveConfig.bShowEFBCopyRegions)
{
// Set Line Size
@ -872,19 +838,6 @@ void Renderer::DrawDebugInfo()
// Clear stored regions
stats.efb_regions.clear();
}
if (g_ActiveConfig.bOverlayStats)
debug_info += Statistics::ToString();
if (g_ActiveConfig.bOverlayProjStats)
debug_info += Statistics::ToStringProj();
if (!debug_info.empty())
{
// Render a shadow, and then the text.
Renderer::RenderText(debug_info, 21, 21, 0xDD000000);
Renderer::RenderText(debug_info, 20, 20, 0xFF00FFFF);
}
}
void Renderer::RenderText(const std::string& text, int left, int top, u32 color)
@ -1715,7 +1668,10 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
DrawDebugInfo();
// Reset viewport for drawing text
glViewport(0, 0, GLInterface->GetBackBufferWidth(), GLInterface->GetBackBufferHeight());
ShowEfbCopyRegions();
DrawDebugText();
// Do our OSD callbacks

View File

@ -66,7 +66,7 @@ public:
void RestoreState() override {}
void RenderText(const std::string& text, int left, int top, u32 color) override;
void DrawDebugInfo();
void ShowEfbCopyRegions();
void FlipImageData(u8 *data, int w, int h, int pixel_width = 3);
u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) override;