mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-22 14:36:35 +00:00
Implement a rather hacky PickPixel implementation
This commit is contained in:
@@ -14,6 +14,16 @@ CustomPaintWidget::~CustomPaintWidget()
|
||||
|
||||
}
|
||||
|
||||
void CustomPaintWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
emit clicked(e);
|
||||
}
|
||||
|
||||
void CustomPaintWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
emit mouseMove(e);
|
||||
}
|
||||
|
||||
void CustomPaintWidget::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
if(m_Output)
|
||||
|
||||
@@ -14,7 +14,13 @@ class CustomPaintWidget : public QWidget
|
||||
|
||||
void SetOutput(IReplayOutput *out) { m_Output = out; }
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void clicked(QMouseEvent *e);
|
||||
void mouseMove(QMouseEvent *e);
|
||||
|
||||
private slots:
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ m_Core(core)
|
||||
|
||||
QWidget *renderContainer = ui->renderContainer;
|
||||
|
||||
QObject::connect(ui->render, &CustomPaintWidget::clicked, this, &TextureViewer::on_render_clicked);
|
||||
QObject::connect(ui->render, &CustomPaintWidget::mouseMove, this, &TextureViewer::on_render_clicked);
|
||||
|
||||
ui->dockarea->addToolWindow(ui->renderContainer, ToolWindowManager::EmptySpace);
|
||||
ui->dockarea->setToolWindowProperties(renderContainer, ToolWindowManager::DisallowUserDocking |
|
||||
ToolWindowManager::HideCloseButton |
|
||||
@@ -113,6 +116,39 @@ TextureViewer::~TextureViewer()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TextureViewer::on_render_clicked(QMouseEvent *e)
|
||||
{
|
||||
uint32_t x = (uint32_t)e->x();
|
||||
uint32_t y = (uint32_t)e->y();
|
||||
|
||||
if(e->buttons() & Qt::RightButton)
|
||||
{
|
||||
m_Core->Renderer()->AsyncInvoke([this,x,y](IReplayRenderer *) {
|
||||
|
||||
ResourceId id;
|
||||
if(m_Core->APIProps().pipelineType == ePipelineState_D3D11)
|
||||
id = m_Core->CurD3D11PipelineState.m_OM.RenderTargets[0].Resource;
|
||||
else
|
||||
id = m_Core->CurGLPipelineState.m_FB.m_DrawFBO.Color[0].Obj;
|
||||
|
||||
PixelValue val;
|
||||
ReplayOutput_PickPixel(m_Output, id, false, x, y, 0, 0, 0, &val);
|
||||
|
||||
QString str = QString("Pixel %1 %2 %3 %4").arg(val.value_f[0]).arg(val.value_f[1]).arg(val.value_f[2]).arg(val.value_f[3]);
|
||||
|
||||
GUIInvoke::call([this,str,val]() {
|
||||
ui->statusText->setText(str);
|
||||
QPalette Pal(palette());
|
||||
|
||||
// set black background
|
||||
Pal.setColor(QPalette::Background, QColor(int(val.value_f[0]*255), int(val.value_f[1]*255), int(val.value_f[2]*255)));
|
||||
ui->pickSwatch->setAutoFillBackground(true);
|
||||
ui->pickSwatch->setPalette(Pal);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void TextureViewer::OnLogfileLoaded()
|
||||
{
|
||||
#if defined(WIN32)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define TEXTUREVIEWER_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "Code/Core.h"
|
||||
|
||||
@@ -22,6 +23,9 @@ class TextureViewer : public QFrame, public ILogViewerForm
|
||||
void OnLogfileClosed();
|
||||
void OnEventSelected(uint32_t frameID, uint32_t eventID);
|
||||
|
||||
private slots:
|
||||
void on_render_clicked(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
Ui::TextureViewer *ui;
|
||||
Core *m_Core;
|
||||
|
||||
@@ -842,7 +842,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<widget class="QWidget" name="pickSwatch" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -864,7 +864,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="s">
|
||||
<widget class="QLabel" name="statusText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
|
||||
Reference in New Issue
Block a user