mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-20 12:39:13 +12:00
Add Qt screen widget
This commit is contained in:
parent
f98662e1bd
commit
b8032c8286
4 changed files with 143 additions and 10 deletions
36
include/panda_qt/screen.hpp
Normal file
36
include/panda_qt/screen.hpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <memory>
|
||||
|
||||
#include "gl/context.h"
|
||||
#include "window_info.h"
|
||||
|
||||
// OpenGL widget for drawing the 3DS screen
|
||||
class ScreenWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ScreenWidget(QWidget* parent = nullptr) : QWidget(parent) {
|
||||
// Create a native window for use with our graphics API of choice
|
||||
setAutoFillBackground(false);
|
||||
setAttribute(Qt::WA_NativeWindow, true);
|
||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||
setAttribute(Qt::WA_PaintOnScreen, true);
|
||||
setAttribute(Qt::WA_KeyCompression, false);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setMouseTracking(true);
|
||||
|
||||
if (!createGLContext()) {
|
||||
Helpers::panic("Failed to create GL context for display");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<GL::Context> glContext = nullptr;
|
||||
bool createGLContext();
|
||||
|
||||
qreal devicePixelRatioFromScreen() const;
|
||||
int scaledWindowWidth() const;
|
||||
int scaledWindowHeight() const;
|
||||
std::optional<WindowInfo> getWindowInfo();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue