code format

This commit is contained in:
2022-12-14 14:14:33 +03:00
parent 09e5342956
commit cdb02fc9be
278 changed files with 15371 additions and 12176 deletions

View File

@@ -1,4 +1,5 @@
#include "openglwindow.h"
#include <QCoreApplication>
#include <QOpenGLContext>
#include <QOpenGLPaintDevice>
@@ -6,11 +7,7 @@
#include <qopenglext.h>
OpenGLWindow::OpenGLWindow(QWindow *parent)
: QWindow(parent)
, m_context(nullptr)
, m_device(nullptr)
{
OpenGLWindow::OpenGLWindow(QWindow * parent): QWindow(parent), m_context(nullptr), m_device(nullptr) {
setFlags(flags() | Qt::FramelessWindowHint);
setSurfaceType(QWindow::OpenGLSurface);
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
@@ -25,7 +22,7 @@ OpenGLWindow::OpenGLWindow(QWindow *parent)
#endif
format.setDepthBufferSize(24);
format.setSamples(8);
// format.setStencilBufferSize(8);
// format.setStencilBufferSize(8);
setFormat(format);
QSurfaceFormat::setDefaultFormat(format);
}
@@ -36,21 +33,19 @@ OpenGLWindow::~OpenGLWindow() {
}
void OpenGLWindow::render(QPainter *painter) {
}
void OpenGLWindow::render(QPainter * painter) {}
void OpenGLWindow::initialize() {
}
void OpenGLWindow::initialize() {}
void OpenGLWindow::render() {
// if (!m_device) m_device = new QOpenGLPaintDevice;
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// m_device->setSize(size() * devicePixelRatio());
// m_device->setDevicePixelRatio(devicePixelRatio());
// QPainter painter(m_device);
// render(&painter);
// if (!m_device) m_device = new QOpenGLPaintDevice;
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// m_device->setSize(size() * devicePixelRatio());
// m_device->setDevicePixelRatio(devicePixelRatio());
// QPainter painter(m_device);
// render(&painter);
}
@@ -59,25 +54,21 @@ void OpenGLWindow::renderLater() {
}
bool OpenGLWindow::event(QEvent *event) {
bool OpenGLWindow::event(QEvent * event) {
switch (event->type()) {
case QEvent::UpdateRequest:
renderNow();
return true;
default:
return QWindow::event(event);
case QEvent::UpdateRequest: renderNow(); return true;
default: return QWindow::event(event);
}
}
void OpenGLWindow::exposeEvent(QExposeEvent *event) {
void OpenGLWindow::exposeEvent(QExposeEvent * event) {
if (isExposed()) renderNow();
}
void OpenGLWindow::renderNow() {
if (!isExposed())
return;
if (!isExposed()) return;
bool needsInitialize = false;
if (!m_context) {
m_context = new QOpenGLContext(this);
@@ -93,4 +84,3 @@ void OpenGLWindow::renderNow() {
render();
m_context->swapBuffers(this);
}