mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Implement GraphicsDrawer::showMessage Use it to show OSD message about logging start and stop.
This commit is contained in:
parent
ee60040a78
commit
64c59fc20d
|
@ -9,6 +9,7 @@
|
|||
#include "Log.h"
|
||||
#include "wst.h"
|
||||
#include "DebugDump.h"
|
||||
#include "DisplayWindow.h"
|
||||
|
||||
#ifdef DEBUG_DUMP
|
||||
|
||||
|
@ -81,11 +82,13 @@ void DebugMsg(u32 _mode, const char * _format, ...)
|
|||
|
||||
void StartDump(u32 _mode)
|
||||
{
|
||||
dwnd().getDrawer().showMessage("Start commands logging\n", Milliseconds(750));
|
||||
g_log.reset(new BufferedLog(_mode));
|
||||
}
|
||||
|
||||
void EndDump()
|
||||
{
|
||||
dwnd().getDrawer().showMessage("Stop commands logging\n", Milliseconds(750));
|
||||
g_log.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <algorithm>
|
||||
#include <thread>
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
#include "Platform.h"
|
||||
|
@ -31,6 +32,12 @@ GraphicsDrawer::GraphicsDrawer()
|
|||
{
|
||||
}
|
||||
|
||||
GraphicsDrawer::~GraphicsDrawer()
|
||||
{
|
||||
while (!m_osdMessages.empty())
|
||||
std::this_thread::sleep_for(Milliseconds(1));
|
||||
}
|
||||
|
||||
void GraphicsDrawer::addTriangle(int _v0, int _v1, int _v2)
|
||||
{
|
||||
const u32 firstIndex = triangles.num;
|
||||
|
@ -1303,7 +1310,8 @@ void GraphicsDrawer::_drawOSD(const char *_pText, float _x, float & _y)
|
|||
|
||||
void GraphicsDrawer::drawOSD()
|
||||
{
|
||||
if ((config.onScreenDisplay.fps | config.onScreenDisplay.vis | config.onScreenDisplay.percent) == 0)
|
||||
if ((config.onScreenDisplay.fps | config.onScreenDisplay.vis | config.onScreenDisplay.percent) == 0 &&
|
||||
m_osdMessages.empty())
|
||||
return;
|
||||
|
||||
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER, ObjectHandle::null);
|
||||
|
@ -1350,9 +1358,26 @@ void GraphicsDrawer::drawOSD()
|
|||
_drawOSD(buf, x, y);
|
||||
}
|
||||
|
||||
for (const std::string & m : m_osdMessages) {
|
||||
_drawOSD(m.c_str(), x, y);
|
||||
}
|
||||
|
||||
frameBufferList().setCurrentDrawBuffer();
|
||||
}
|
||||
|
||||
void GraphicsDrawer::showMessage(std::string _message, Milliseconds _interval)
|
||||
{
|
||||
m_osdMessages.emplace_back(_message);
|
||||
std::thread t(&GraphicsDrawer::_removeOSDMessage, this, std::prev(m_osdMessages.end()), _interval);
|
||||
t.detach();
|
||||
}
|
||||
|
||||
void GraphicsDrawer::_removeOSDMessage(OSDMessages::iterator _iter, Milliseconds _interval)
|
||||
{
|
||||
std::this_thread::sleep_for(_interval);
|
||||
m_osdMessages.erase(_iter);
|
||||
}
|
||||
|
||||
void GraphicsDrawer::clearDepthBuffer(u32 _ulx, u32 _uly, u32 _lrx, u32 _lry)
|
||||
{
|
||||
if (!_canDraw())
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#include <memory>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include "gSP.h"
|
||||
#include "TexrectDrawer.h"
|
||||
#include "Graphics/ObjectHandle.h"
|
||||
|
@ -32,6 +35,8 @@ struct RectVertex
|
|||
float s0, t0, s1, t1;
|
||||
};
|
||||
|
||||
typedef std::chrono::milliseconds Milliseconds;
|
||||
|
||||
class GraphicsDrawer
|
||||
{
|
||||
public:
|
||||
|
@ -113,6 +118,8 @@ public:
|
|||
|
||||
void drawOSD();
|
||||
|
||||
void showMessage(std::string _message, Milliseconds _interval);
|
||||
|
||||
void clearDepthBuffer(u32 _ulx, u32 _uly, u32 _lrx, u32 _lry);
|
||||
|
||||
void clearColorBuffer(float * _pColor);
|
||||
|
@ -145,6 +152,7 @@ private:
|
|||
friend TexrectDrawer;
|
||||
|
||||
GraphicsDrawer();
|
||||
~GraphicsDrawer();
|
||||
|
||||
GraphicsDrawer(const GraphicsDrawer &) = delete;
|
||||
|
||||
|
@ -169,6 +177,9 @@ private:
|
|||
|
||||
void _drawOSD(const char *_pText, float _x, float & _y);
|
||||
|
||||
typedef std::list<std::string> OSDMessages;
|
||||
void _removeOSDMessage(OSDMessages::iterator _iter, Milliseconds _interval);
|
||||
|
||||
DrawingState m_drawingState;
|
||||
TexturedRectParams m_texrectParams;
|
||||
|
||||
|
@ -188,4 +199,5 @@ private:
|
|||
bool m_bImageTexture;
|
||||
bool m_bFlatColors;
|
||||
TexrectDrawer m_texrectDrawer;
|
||||
OSDMessages m_osdMessages;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user