modify render
This commit is contained in:
parent
c3bb7a8054
commit
32ed1bf037
@ -9,7 +9,7 @@ SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets LinguistTools REQUIRED)
|
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets LinguistTools REQUIRED)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools OpenGL REQUIRED)
|
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Gui Widgets LinguistTools OpenGL REQUIRED)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets LinguistTools DataVisualization Charts Network REQUIRED)
|
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets LinguistTools DataVisualization Charts Network REQUIRED)
|
||||||
|
|
||||||
message("qt VERSION " ${QT_VERSION_MAJOR})
|
message("qt VERSION " ${QT_VERSION_MAJOR})
|
||||||
@ -146,6 +146,7 @@ target_link_libraries(
|
|||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
Qt${QT_VERSION_MAJOR}::Core
|
Qt${QT_VERSION_MAJOR}::Core
|
||||||
|
Qt${QT_VERSION_MAJOR}::Gui
|
||||||
Qt${QT_VERSION_MAJOR}::Widgets
|
Qt${QT_VERSION_MAJOR}::Widgets
|
||||||
Qt${QT_VERSION_MAJOR}::Charts
|
Qt${QT_VERSION_MAJOR}::Charts
|
||||||
Qt${QT_VERSION_MAJOR}::DataVisualization
|
Qt${QT_VERSION_MAJOR}::DataVisualization
|
||||||
|
@ -6,10 +6,16 @@
|
|||||||
#include "common/CrashHandler.h"
|
#include "common/CrashHandler.h"
|
||||||
|
|
||||||
#include "ui/MainFrame.h"
|
#include "ui/MainFrame.h"
|
||||||
|
#include "viewer/OSGEnv.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
SpdLogger logger("logs/log.txt", 5);
|
SpdLogger logger("logs/log.txt", 5);
|
||||||
|
|
||||||
|
if (!OSGEnv::init()) {
|
||||||
|
LOG_ERROR("OSGEnv::init() failed!");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
Application::setAttribute(Qt::AA_EnableHighDpiScaling);
|
Application::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
||||||
Application app(argc, argv);
|
Application app(argc, argv);
|
||||||
@ -24,6 +30,7 @@ int main(int argc, char* argv[]) {
|
|||||||
mainWindow.showMaximized();
|
mainWindow.showMaximized();
|
||||||
|
|
||||||
ret = app.exec();
|
ret = app.exec();
|
||||||
|
OSGEnv::destroy();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -479,153 +479,153 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="70"/>
|
<location filename="../ui/MainWindow.cpp" line="71"/>
|
||||||
<source>model elements</source>
|
<source>model elements</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="76"/>
|
<location filename="../ui/MainWindow.cpp" line="77"/>
|
||||||
<source>attribte</source>
|
<source>attribte</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="113"/>
|
<location filename="../ui/MainWindow.cpp" line="115"/>
|
||||||
<source>Wave Curve</source>
|
<source>Wave Curve</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="121"/>
|
<location filename="../ui/MainWindow.cpp" line="123"/>
|
||||||
<source>Speed Curve</source>
|
<source>Speed Curve</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="130"/>
|
<location filename="../ui/MainWindow.cpp" line="132"/>
|
||||||
<source>3D Curve</source>
|
<source>3D Curve</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="142"/>
|
<location filename="../ui/MainWindow.cpp" line="144"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="167"/>
|
<location filename="../ui/MainWindow.cpp" line="169"/>
|
||||||
<source>Target number</source>
|
<source>Target number</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="142"/>
|
<location filename="../ui/MainWindow.cpp" line="144"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="167"/>
|
<location filename="../ui/MainWindow.cpp" line="169"/>
|
||||||
<source>Signal-to-noise ratio</source>
|
<source>Signal-to-noise ratio</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="143"/>
|
<location filename="../ui/MainWindow.cpp" line="145"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="168"/>
|
<location filename="../ui/MainWindow.cpp" line="170"/>
|
||||||
<source>Azimuth line of sight</source>
|
<source>Azimuth line of sight</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="143"/>
|
<location filename="../ui/MainWindow.cpp" line="145"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="168"/>
|
<location filename="../ui/MainWindow.cpp" line="170"/>
|
||||||
<source>Pitch gaze angle</source>
|
<source>Pitch gaze angle</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="144"/>
|
<location filename="../ui/MainWindow.cpp" line="146"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="169"/>
|
<location filename="../ui/MainWindow.cpp" line="171"/>
|
||||||
<source>azimuth</source>
|
<source>azimuth</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="144"/>
|
<location filename="../ui/MainWindow.cpp" line="146"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="169"/>
|
<location filename="../ui/MainWindow.cpp" line="171"/>
|
||||||
<source>Pitch angle</source>
|
<source>Pitch angle</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="145"/>
|
<location filename="../ui/MainWindow.cpp" line="147"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="170"/>
|
<location filename="../ui/MainWindow.cpp" line="172"/>
|
||||||
<source>attribute</source>
|
<source>attribute</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="145"/>
|
<location filename="../ui/MainWindow.cpp" line="147"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="170"/>
|
<location filename="../ui/MainWindow.cpp" line="172"/>
|
||||||
<source>Doppler</source>
|
<source>Doppler</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="146"/>
|
<location filename="../ui/MainWindow.cpp" line="148"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="171"/>
|
<location filename="../ui/MainWindow.cpp" line="173"/>
|
||||||
<source>course</source>
|
<source>course</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="146"/>
|
<location filename="../ui/MainWindow.cpp" line="148"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="171"/>
|
<location filename="../ui/MainWindow.cpp" line="173"/>
|
||||||
<source>Speed</source>
|
<source>Speed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="147"/>
|
<location filename="../ui/MainWindow.cpp" line="149"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="172"/>
|
<location filename="../ui/MainWindow.cpp" line="174"/>
|
||||||
<source>longitude</source>
|
<source>longitude</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="147"/>
|
<location filename="../ui/MainWindow.cpp" line="149"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="172"/>
|
<location filename="../ui/MainWindow.cpp" line="174"/>
|
||||||
<source>latitude</source>
|
<source>latitude</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="148"/>
|
<location filename="../ui/MainWindow.cpp" line="150"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="173"/>
|
<location filename="../ui/MainWindow.cpp" line="175"/>
|
||||||
<source>distance</source>
|
<source>distance</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="148"/>
|
<location filename="../ui/MainWindow.cpp" line="150"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="173"/>
|
<location filename="../ui/MainWindow.cpp" line="175"/>
|
||||||
<source>velocity</source>
|
<source>velocity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="149"/>
|
<location filename="../ui/MainWindow.cpp" line="151"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="174"/>
|
<location filename="../ui/MainWindow.cpp" line="176"/>
|
||||||
<source>Radial dimensions</source>
|
<source>Radial dimensions</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="149"/>
|
<location filename="../ui/MainWindow.cpp" line="151"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="174"/>
|
<location filename="../ui/MainWindow.cpp" line="176"/>
|
||||||
<source>Target RCS</source>
|
<source>Target RCS</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="155"/>
|
<location filename="../ui/MainWindow.cpp" line="157"/>
|
||||||
<source>Report Table</source>
|
<source>Report Table</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="180"/>
|
<location filename="../ui/MainWindow.cpp" line="182"/>
|
||||||
<source>Report</source>
|
<source>Report</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="189"/>
|
<location filename="../ui/MainWindow.cpp" line="191"/>
|
||||||
<source>Signal Indicator Lamp</source>
|
<source>Signal Indicator Lamp</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="196"/>
|
<location filename="../ui/MainWindow.cpp" line="198"/>
|
||||||
<source>ParamSetting</source>
|
<source>ParamSetting</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="201"/>
|
<location filename="../ui/MainWindow.cpp" line="203"/>
|
||||||
<source>Matlab File</source>
|
<source>Matlab File</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="206"/>
|
<location filename="../ui/MainWindow.cpp" line="208"/>
|
||||||
<source>name: 5year 0412</source>
|
<source>name: 5year 0412</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
|
|
||||||
#include "viewer/ViewWidget.h"
|
#include "viewer/ViewWidget.h"
|
||||||
|
#include "viewer/OsgOpenGLWindow.h"
|
||||||
#include "viewer/OsgViewer.h"
|
#include "viewer/OsgViewer.h"
|
||||||
|
|
||||||
#include "chartPlot/FitCurveDialog.h"
|
#include "chartPlot/FitCurveDialog.h"
|
||||||
@ -82,8 +83,9 @@ void MainWindow::InitUI() {
|
|||||||
connect(modelBrowser_, &ModelBrowser::WorkSpaceChange, propertyBrowser_, &PropertyBrowser::OnWorkSpaceChange);
|
connect(modelBrowser_, &ModelBrowser::WorkSpaceChange, propertyBrowser_, &PropertyBrowser::OnWorkSpaceChange);
|
||||||
connect(modelBrowser_, &ModelBrowser::EntityChange, propertyBrowser_, &PropertyBrowser::OnEntityChange);
|
connect(modelBrowser_, &ModelBrowser::EntityChange, propertyBrowser_, &PropertyBrowser::OnEntityChange);
|
||||||
|
|
||||||
qtOsgViewWidget_ = new ViewWidget;
|
//qtOsgViewWidget_ = new ViewWidget;
|
||||||
qtOsgViewWidget_->Initialize();
|
qtOsgViewWidget_ = new OsgOpenGLWindow;
|
||||||
|
//qtOsgViewWidget_->Initialize();
|
||||||
m_mapDockWidget.insert("PropertyBrowser", attribte);
|
m_mapDockWidget.insert("PropertyBrowser", attribte);
|
||||||
|
|
||||||
QString wavePath ="", speedPath = "", rdPath = "", matlabParam="";
|
QString wavePath ="", speedPath = "", rdPath = "", matlabParam="";
|
||||||
@ -209,7 +211,7 @@ void MainWindow::InitUI() {
|
|||||||
InitDockLayout();
|
InitDockLayout();
|
||||||
|
|
||||||
//ui->viewWidget->layout()->addWidget(qtOsgViewWidget_);
|
//ui->viewWidget->layout()->addWidget(qtOsgViewWidget_);
|
||||||
qtOsgViewWidget_->LoadDefaultScene();
|
//qtOsgViewWidget_->LoadDefaultScene();
|
||||||
//OsgViewer::Get().Initialize();
|
//OsgViewer::Get().Initialize();
|
||||||
//OsgViewer::Get().OnFrame();
|
//OsgViewer::Get().OnFrame();
|
||||||
|
|
||||||
@ -235,7 +237,8 @@ void MainWindow::InitDockLayout() {
|
|||||||
|
|
||||||
tabWidget_->insertTab(i, mainWindow_, strTabName);
|
tabWidget_->insertTab(i, mainWindow_, strTabName);
|
||||||
if (listDocArea[0].toList().size() > 0) {
|
if (listDocArea[0].toList().size() > 0) {
|
||||||
mainWindow_->setCentralWidget(qtOsgViewWidget_);
|
//mainWindow_->setCentralWidget(qtOsgViewWidget_);
|
||||||
|
mainWindow_->setCentralWidget(qtOsgViewWidget_->AsWidget());
|
||||||
//OsgViewer::Get().Initialize();
|
//OsgViewer::Get().Initialize();
|
||||||
//OsgViewer::Get().OnFrame();
|
//OsgViewer::Get().OnFrame();
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,9 +21,9 @@ public:
|
|||||||
class ModelBrowser* GetModelBrowser() const {
|
class ModelBrowser* GetModelBrowser() const {
|
||||||
return modelBrowser_;
|
return modelBrowser_;
|
||||||
}
|
}
|
||||||
class ViewWidget* GetViewWidget() const {
|
/*class ViewWidget* GetViewWidget() const {
|
||||||
return qtOsgViewWidget_;
|
return qtOsgViewWidget_;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
class FitCurveDialog* GetFitCurveDlg() const {
|
class FitCurveDialog* GetFitCurveDlg() const {
|
||||||
return fitCurveDlg_;
|
return fitCurveDlg_;
|
||||||
@ -55,7 +55,8 @@ private:
|
|||||||
class ModelBrowser* modelBrowser_{ nullptr };
|
class ModelBrowser* modelBrowser_{ nullptr };
|
||||||
class PropertyBrowser* propertyBrowser_{ nullptr };
|
class PropertyBrowser* propertyBrowser_{ nullptr };
|
||||||
class QWebEngineView* webEngineView_{ nullptr };
|
class QWebEngineView* webEngineView_{ nullptr };
|
||||||
class ViewWidget* qtOsgViewWidget_{ nullptr };
|
//class ViewWidget* qtOsgViewWidget_{ nullptr };
|
||||||
|
class OsgOpenGLWindow* qtOsgViewWidget_{ nullptr };
|
||||||
|
|
||||||
class FitCurveDialog* fitCurveDlg_{ nullptr };
|
class FitCurveDialog* fitCurveDlg_{ nullptr };
|
||||||
class FitCurveDialog* fitYLgCurveDlg_{ nullptr };
|
class FitCurveDialog* fitYLgCurveDlg_{ nullptr };
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <QOpenGLFrameBufferObjectFormat>
|
#include <QOpenGLFrameBufferObjectFormat>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
|
#include <QThread>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
@ -107,28 +108,13 @@ namespace {
|
|||||||
|
|
||||||
|
|
||||||
GraphicsWindowEx::GraphicsWindowEx(int x, int y, int width, int height)
|
GraphicsWindowEx::GraphicsWindowEx(int x, int y, int width, int height)
|
||||||
: osgViewer::GraphicsWindowEmbedded(x, y, width, height)
|
: osgViewer::GraphicsWindowEmbedded(x, y, width == 0 ? 1 : width, height == 0 ? 1 : height) {
|
||||||
, offScreenSurface_(new QOffscreenSurface)
|
|
||||||
, offScreenContext_(new QOpenGLContext)
|
|
||||||
{
|
|
||||||
LOG_INFO("actor, self={}", spdlog::fmt_lib::ptr(this));
|
LOG_INFO("actor, self={}", spdlog::fmt_lib::ptr(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsWindowEx::~GraphicsWindowEx() {
|
GraphicsWindowEx::~GraphicsWindowEx() {
|
||||||
LOG_INFO("dctor isSharedContextSet_:{}, self={}", isSharedContextSet_, spdlog::fmt_lib::ptr(this));
|
LOG_INFO("dctor isSharedContextSet_:{}, self={}", isSharedContextSet_, spdlog::fmt_lib::ptr(this));
|
||||||
if (!isSharedContextSet_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFrameBufferInitialized_) {
|
|
||||||
offScreenContext_->makeCurrent(offScreenSurface_.get());
|
|
||||||
renderFramebuffer_.reset();
|
|
||||||
sharedFrameBuffer_.reset();
|
|
||||||
offScreenContext_->doneCurrent();
|
|
||||||
}
|
|
||||||
|
|
||||||
offScreenContext_.reset();
|
|
||||||
offScreenSurface_.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsWindowEx::realizeImplementation() {
|
bool GraphicsWindowEx::realizeImplementation() {
|
||||||
@ -152,17 +138,39 @@ bool GraphicsWindowEx::realizeImplementation() {
|
|||||||
|
|
||||||
bool GraphicsWindowEx::makeCurrentImplementation() {
|
bool GraphicsWindowEx::makeCurrentImplementation() {
|
||||||
LOG_INFO("makeCurrentImplementation, isRealized_:{}, self={}", isRealized_, spdlog::fmt_lib::ptr(this));
|
LOG_INFO("makeCurrentImplementation, isRealized_:{}, self={}", isRealized_, spdlog::fmt_lib::ptr(this));
|
||||||
dyt_check(nullptr != offScreenContext_);
|
|
||||||
offScreenContext_->makeCurrent(offScreenSurface_.get());
|
InitOffScreenContext();
|
||||||
|
if (nullptr != offScreenContext_) {
|
||||||
|
offScreenContext_->makeCurrent(offScreenSurface_.get());
|
||||||
|
}
|
||||||
|
|
||||||
InitFrameBuffer();
|
InitFrameBuffer();
|
||||||
|
|
||||||
setDefaultFboId(renderFramebuffer_->handle());
|
setDefaultFboId(renderFramebuffer_->handle());
|
||||||
renderFramebuffer_->bind();
|
renderFramebuffer_->bind();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsWindowEx::closeImplementation() {
|
||||||
|
if (!isSharedContextSet_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isFrameBufferInitialized_) {
|
||||||
|
offScreenContext_->makeCurrent(offScreenSurface_.get());
|
||||||
|
renderFramebuffer_.reset();
|
||||||
|
sharedFrameBuffer_.reset();
|
||||||
|
offScreenContext_->doneCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
|
offScreenContext_.reset();
|
||||||
|
offScreenSurface_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
bool GraphicsWindowEx::releaseContextImplementation() {
|
bool GraphicsWindowEx::releaseContextImplementation() {
|
||||||
LOG_INFO("releaseContextImplementation, self={}", spdlog::fmt_lib::ptr(this));
|
LOG_INFO("releaseContextImplementation, self={}", spdlog::fmt_lib::ptr(this));
|
||||||
|
QOpenGLFramebufferObject::bindDefault();
|
||||||
offScreenContext_->doneCurrent();
|
offScreenContext_->doneCurrent();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -178,25 +186,20 @@ void GraphicsWindowEx::swapBuffersImplementation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsWindowEx::SetSharedContext(QOpenGLContext* sharedContext) {
|
bool GraphicsWindowEx::SetSharedContext(QOpenGLContext* sharedContext) {
|
||||||
LOG_INFO("Set shared context, {}", isSharedContextSet_);
|
sharedContext_ = sharedContext;
|
||||||
if (isSharedContextSet_) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
offScreenContext_->setFormat(sharedContext->format());
|
|
||||||
offScreenContext_->setShareContext(sharedContext);
|
|
||||||
|
|
||||||
isSharedContextSet_ = offScreenContext_->create();
|
|
||||||
if (!isSharedContextSet_) {
|
|
||||||
LOG_ERROR("Failed to create offscreen context");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
offScreenSurface_->setFormat(offScreenContext_->format());
|
|
||||||
offScreenSurface_->create();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsWindowEx::ReizeWindow(int width, int height) {
|
||||||
|
if (width == _traits->width && height == _traits->height) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getEventQueue()->windowResize(0, 0, width, height);
|
||||||
|
resized(0, 0, width, height);
|
||||||
|
isFrameBufferInitialized_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
void GraphicsWindowEx::keyPressEvent(QKeyEvent* event) {
|
void GraphicsWindowEx::keyPressEvent(QKeyEvent* event) {
|
||||||
setKeyboardModifiers(getEventQueue(), event);
|
setKeyboardModifiers(getEventQueue(), event);
|
||||||
int value = s_QtKeyboardMap.remapKey(event);
|
int value = s_QtKeyboardMap.remapKey(event);
|
||||||
@ -321,6 +324,36 @@ void GraphicsWindowEx::wheelEvent(QWheelEvent* event) {
|
|||||||
osgGA::GUIEventAdapter::SCROLL_RIGHT));
|
osgGA::GUIEventAdapter::SCROLL_RIGHT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsWindowEx::InitOffScreenContext() {
|
||||||
|
if (isSharedContextSet_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!offScreenSurface_) {
|
||||||
|
offScreenSurface_.reset(new QOffscreenSurface);
|
||||||
|
}
|
||||||
|
if (!offScreenContext_) {
|
||||||
|
offScreenContext_.reset(new QOpenGLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO("Set shared context");
|
||||||
|
|
||||||
|
dyt_check(nullptr != sharedContext_);
|
||||||
|
|
||||||
|
offScreenContext_->setFormat(sharedContext_->format());
|
||||||
|
offScreenContext_->setShareContext(sharedContext_);
|
||||||
|
|
||||||
|
isSharedContextSet_ = offScreenContext_->create();
|
||||||
|
if (!isSharedContextSet_) {
|
||||||
|
LOG_ERROR("Failed to create offscreen context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
offScreenSurface_->setFormat(offScreenContext_->format());
|
||||||
|
offScreenSurface_->create();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void GraphicsWindowEx::InitFrameBuffer() {
|
void GraphicsWindowEx::InitFrameBuffer() {
|
||||||
if (isFrameBufferInitialized_) {
|
if (isFrameBufferInitialized_) {
|
||||||
return;
|
return;
|
||||||
@ -335,4 +368,3 @@ void GraphicsWindowEx::InitFrameBuffer() {
|
|||||||
|
|
||||||
isFrameBufferInitialized_ = true;
|
isFrameBufferInitialized_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef GRAPHICSWINDOWEX_H
|
#ifndef GRAPHICSWINDOWEX_H
|
||||||
#define GRAPHICSWINDOWEX_H
|
#define GRAPHICSWINDOWEX_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include <osgViewer/GraphicsWindow>
|
#include <osgViewer/GraphicsWindow>
|
||||||
|
|
||||||
#include <QOffscreenSurface>
|
#include <QOffscreenSurface>
|
||||||
@ -38,7 +39,7 @@ public:
|
|||||||
}
|
}
|
||||||
bool realizeImplementation() override;
|
bool realizeImplementation() override;
|
||||||
bool makeCurrentImplementation() override;
|
bool makeCurrentImplementation() override;
|
||||||
void closeImplementation() override {}
|
void closeImplementation() override;
|
||||||
bool releaseContextImplementation() override;
|
bool releaseContextImplementation() override;
|
||||||
void swapBuffersImplementation() override;
|
void swapBuffersImplementation() override;
|
||||||
|
|
||||||
@ -46,10 +47,13 @@ public:
|
|||||||
void UpdateWindowScale(float scale) {
|
void UpdateWindowScale(float scale) {
|
||||||
windowScale_ = scale;
|
windowScale_ = scale;
|
||||||
}
|
}
|
||||||
unsigned int GetFrameBufferId() const {
|
unsigned int GetFrameBufferId() {
|
||||||
|
isRenderDonwn_ = true;
|
||||||
return frameBufferId_;
|
return frameBufferId_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReizeWindow(int width, int height);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void keyPressEvent(class QKeyEvent* event);
|
void keyPressEvent(class QKeyEvent* event);
|
||||||
void keyReleaseEvent(class QKeyEvent* event);
|
void keyReleaseEvent(class QKeyEvent* event);
|
||||||
@ -60,6 +64,7 @@ public:
|
|||||||
void wheelEvent(class QWheelEvent* event);
|
void wheelEvent(class QWheelEvent* event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void InitOffScreenContext();
|
||||||
void InitFrameBuffer();
|
void InitFrameBuffer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -68,6 +73,8 @@ private:
|
|||||||
std::unique_ptr<QOpenGLFramebufferObject> renderFramebuffer_{ nullptr };
|
std::unique_ptr<QOpenGLFramebufferObject> renderFramebuffer_{ nullptr };
|
||||||
std::unique_ptr<QOpenGLFramebufferObject> sharedFrameBuffer_{ nullptr };
|
std::unique_ptr<QOpenGLFramebufferObject> sharedFrameBuffer_{ nullptr };
|
||||||
|
|
||||||
|
QOpenGLContext* sharedContext_{ nullptr };
|
||||||
|
|
||||||
bool isSharedContextSet_{ false };
|
bool isSharedContextSet_{ false };
|
||||||
bool isRealized_{ false };
|
bool isRealized_{ false };
|
||||||
bool isFrameBufferInitialized_{ false };
|
bool isFrameBufferInitialized_{ false };
|
||||||
|
56
src/viewer/OSGEnv.cpp
Normal file
56
src/viewer/OSGEnv.cpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#include "viewer/OSGEnv.h"
|
||||||
|
|
||||||
|
#include <QSurfaceFormat>
|
||||||
|
|
||||||
|
#include <osgDB/Registry>
|
||||||
|
#include <osgEarth/Capabilities>
|
||||||
|
#include <osgEarth/Registry>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool s_gBChecked = false;
|
||||||
|
|
||||||
|
bool OSGEnv::init() {
|
||||||
|
osgEarth::initialize();
|
||||||
|
const osgEarth::Capabilities& csCapabilities = osgEarth::Registry::instance()->getCapabilities();
|
||||||
|
s_gBChecked = csCapabilities.supportsGLSL();
|
||||||
|
if (!s_gBChecked) {
|
||||||
|
return(s_gBChecked);
|
||||||
|
}
|
||||||
|
|
||||||
|
int nMax, nMin;
|
||||||
|
sscanf(csCapabilities.getVersion().data(), "%d.%d", &nMax, &nMin);
|
||||||
|
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
|
||||||
|
osg::GraphicsContext::Traits traits(osg::DisplaySettings::instance().get());
|
||||||
|
|
||||||
|
int nHttpThreads = osg::DisplaySettings::instance()->getNumOfDatabaseThreadsHint();
|
||||||
|
nHttpThreads = nHttpThreads < 1 ? 1 : nHttpThreads;
|
||||||
|
osg::DisplaySettings::instance()->setNumOfHttpDatabaseThreadsHint(nHttpThreads);
|
||||||
|
format.setAlphaBufferSize(traits.alpha);
|
||||||
|
format.setRedBufferSize(traits.red);
|
||||||
|
format.setGreenBufferSize(traits.green);
|
||||||
|
format.setBlueBufferSize(traits.blue);
|
||||||
|
format.setDepthBufferSize(traits.depth);
|
||||||
|
format.setStencilBufferSize(traits.stencil);
|
||||||
|
format.setSamples(traits.samples);
|
||||||
|
format.setVersion(nMax, nMin);
|
||||||
|
|
||||||
|
/// ÅжÏÊÇ·ñÖ§³ÖºËÐÄģʽ
|
||||||
|
if (csCapabilities.isCoreProfile()) {
|
||||||
|
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||||
|
} else {
|
||||||
|
format.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
format.setSwapInterval(traits.vsync ? 1 : 0);
|
||||||
|
format.setStereo(traits.quadBufferStereo ? 1 : 0);
|
||||||
|
|
||||||
|
QSurfaceFormat::setDefaultFormat(format);
|
||||||
|
osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper("osg::Image");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OSGEnv::destroy() {
|
||||||
|
|
||||||
|
}
|
7
src/viewer/OSGEnv.h
Normal file
7
src/viewer/OSGEnv.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class OSGEnv {
|
||||||
|
public:
|
||||||
|
static bool init();
|
||||||
|
static void destroy();
|
||||||
|
};
|
@ -59,23 +59,20 @@ void OSGRenderer::Init(osg::GraphicsContext* gc) {
|
|||||||
|
|
||||||
getCamera()->setGraphicsContext(gc);
|
getCamera()->setGraphicsContext(gc);
|
||||||
getCamera()->setViewport(new osg::Viewport(0, 0, gc->getTraits()->width, gc->getTraits()->height));
|
getCamera()->setViewport(new osg::Viewport(0, 0, gc->getTraits()->width, gc->getTraits()->height));
|
||||||
|
getCamera()->setDrawBuffer(GL_BACK);
|
||||||
|
getCamera()->setReadBuffer(GL_BACK);
|
||||||
|
getCamera()->setProjectionMatrixAsPerspective(45, 1.0, 0.01, 100.);
|
||||||
isInited_ = true;
|
isInited_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSGRenderer::Resize(osg::GraphicsContext* gc, int width, int height) {
|
void OSGRenderer::Resize(GraphicsWindowEx* gc, int width, int height) {
|
||||||
LOG_INFO("OSGRenderer::Resize {}, gc:{}", isInited_, spdlog::fmt_lib::ptr(gc));
|
LOG_INFO("OSGRenderer::Resize {}, gc:{}", isInited_, spdlog::fmt_lib::ptr(gc));
|
||||||
if (!gc) {
|
dyt_check(nullptr != gc);
|
||||||
|
if (!isInited_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInited_) {
|
gc->ReizeWindow(width, height);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
osgViewer::GraphicsWindow* window = dynamic_cast<osgViewer::GraphicsWindow*>(gc);
|
|
||||||
dyt_check(nullptr != window);
|
|
||||||
window->getEventQueue()->windowResize(0, 0, width, height);
|
|
||||||
window->resized(0, 0, width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSGRenderer::Render() {
|
void OSGRenderer::Render() {
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include <osgViewer/Viewer>
|
#include <osgViewer/Viewer>
|
||||||
|
|
||||||
|
#include "GraphicsWindowEx.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
enum RenderEvent {
|
enum RenderEvent {
|
||||||
INIT = QEvent::Type(QEvent::User + 1),
|
INIT = QEvent::Type(QEvent::User + 1),
|
||||||
@ -39,13 +41,13 @@ namespace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct GraphicsWindowResizeEvent : public QEvent {
|
struct GraphicsWindowResizeEvent : public QEvent {
|
||||||
GraphicsWindowResizeEvent(osg::GraphicsContext* gc, int width, int height)
|
GraphicsWindowResizeEvent(GraphicsWindowEx* gc, int width, int height)
|
||||||
: QEvent(QEvent::Type(RESIZE))
|
: QEvent(QEvent::Type(RESIZE))
|
||||||
, gc_(gc)
|
, gc_(gc)
|
||||||
, width_(width)
|
, width_(width)
|
||||||
, height_(height) {}
|
, height_(height) {}
|
||||||
|
|
||||||
osg::observer_ptr<osg::GraphicsContext> gc_;
|
osg::observer_ptr<GraphicsWindowEx> gc_;
|
||||||
int width_;
|
int width_;
|
||||||
int height_;
|
int height_;
|
||||||
};
|
};
|
||||||
@ -67,7 +69,7 @@ Q_SIGNALS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void Init(osg::GraphicsContext* gc);
|
void Init(osg::GraphicsContext* gc);
|
||||||
void Resize(osg::GraphicsContext* gc, int width, int height);
|
void Resize(GraphicsWindowEx* gc, int width, int height);
|
||||||
void Render();
|
void Render();
|
||||||
void Destoy();
|
void Destoy();
|
||||||
|
|
||||||
|
@ -47,38 +47,33 @@ static const char* fragmentShaderSource =
|
|||||||
|
|
||||||
|
|
||||||
OsgOpenGLWindow::OsgOpenGLWindow(QWidget* parent)
|
OsgOpenGLWindow::OsgOpenGLWindow(QWidget* parent)
|
||||||
: QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, nullptr)
|
: QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, nullptr) {
|
||||||
{
|
|
||||||
widget_ = QWidget::createWindowContainer(this);
|
widget_ = QWidget::createWindowContainer(this);
|
||||||
|
gw_ = new GraphicsWindowEx(0, 0, width(), height());
|
||||||
renderer_ = new OSGRenderer(this);
|
renderer_ = new OSGRenderer(this);
|
||||||
connect(renderer_, &OSGRenderer::RenderFlush, this, &OsgOpenGLWindow::OnRenderFlush);
|
connect(renderer_, &OSGRenderer::RenderFlush, this, &OsgOpenGLWindow::OnRenderFlush, Qt::QueuedConnection);
|
||||||
|
connect(&timer_, &QTimer::timeout, this, &OsgOpenGLWindow::OnRender);
|
||||||
}
|
}
|
||||||
|
|
||||||
OsgOpenGLWindow::~OsgOpenGLWindow()
|
OsgOpenGLWindow::~OsgOpenGLWindow() {}
|
||||||
{
|
|
||||||
|
osgViewer::Viewer* OsgOpenGLWindow::getOsgViewer() {
|
||||||
|
return renderer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
osgViewer::Viewer* OsgOpenGLWindow::getOsgViewer()
|
void OsgOpenGLWindow::initializeGL() {
|
||||||
{
|
|
||||||
return m_renderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenThreads::ReadWriteMutex* OsgOpenGLWindow::mutex()
|
|
||||||
{
|
|
||||||
return &_osgMutex;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void OsgOpenGLWindow::initializeGL()
|
|
||||||
{
|
|
||||||
//// Initializes OpenGL function resolution for the current context.
|
//// Initializes OpenGL function resolution for the current context.
|
||||||
//initializeOpenGLFunctions();
|
//initializeOpenGLFunctions();
|
||||||
//createRenderer();
|
//createRenderer();
|
||||||
//emit initialized();
|
//emit initialized();
|
||||||
context()->doneCurrent();
|
QOpenGLContext* ctx = context();
|
||||||
|
dyt_check(nullptr != ctx);
|
||||||
|
ctx->doneCurrent();
|
||||||
gw_->SetSharedContext(context());
|
gw_->SetSharedContext(context());
|
||||||
QApplication::postEvent(renderer_, new RenderBindGraphicsContextEvent(gw_));
|
QApplication::postEvent(renderer_, new RenderBindGraphicsContextEvent(gw_));
|
||||||
|
|
||||||
|
setDefaultDisplaySettings();
|
||||||
|
|
||||||
double pixelRatio = screen()->devicePixelRatio();
|
double pixelRatio = screen()->devicePixelRatio();
|
||||||
gw_->UpdateWindowScale(pixelRatio);
|
gw_->UpdateWindowScale(pixelRatio);
|
||||||
QApplication::postEvent(renderer_, new GraphicsWindowResizeEvent(gw_, width() * pixelRatio, height() * pixelRatio));
|
QApplication::postEvent(renderer_, new GraphicsWindowResizeEvent(gw_, width() * pixelRatio, height() * pixelRatio));
|
||||||
@ -90,28 +85,28 @@ void OsgOpenGLWindow::initializeGL()
|
|||||||
shaderProgram_ = new QOpenGLShaderProgram(this);
|
shaderProgram_ = new QOpenGLShaderProgram(this);
|
||||||
vao_ = new QOpenGLVertexArrayObject(this);
|
vao_ = new QOpenGLVertexArrayObject(this);
|
||||||
if (!vao_->create()) {
|
if (!vao_->create()) {
|
||||||
LOG_ERROR( "Failed to create VAO");
|
LOG_ERROR("Failed to create VAO");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shaderProgram_->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource)) {
|
if (!shaderProgram_->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource)) {
|
||||||
LOG_ERROR( "Failed to add vertex shader");
|
LOG_ERROR("Failed to add vertex shader");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!shaderProgram_->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource)) {
|
if (!shaderProgram_->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource)) {
|
||||||
LOG_ERROR( "Failed to add fragment shader");
|
LOG_ERROR("Failed to add fragment shader");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shaderProgram_->link()) {
|
if (!shaderProgram_->link()) {
|
||||||
LOG_ERROR( "Failed to link shader program, {}", shaderProgram_->log().toLocal8Bit().constData());
|
LOG_ERROR("Failed to link shader program, {}", shaderProgram_->log().toLocal8Bit().constData());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timer_.start(1000 / 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgOpenGLWindow::resizeGL(int w, int h)
|
void OsgOpenGLWindow::resizeGL(int w, int h) {
|
||||||
{
|
|
||||||
Q_ASSERT(m_renderer);
|
|
||||||
double pixelRatio = screen()->devicePixelRatio();
|
double pixelRatio = screen()->devicePixelRatio();
|
||||||
gw_->UpdateWindowScale(pixelRatio);
|
gw_->UpdateWindowScale(pixelRatio);
|
||||||
QApplication::postEvent(renderer_, new GraphicsWindowResizeEvent(gw_, w * pixelRatio, h * pixelRatio));
|
QApplication::postEvent(renderer_, new GraphicsWindowResizeEvent(gw_, w * pixelRatio, h * pixelRatio));
|
||||||
@ -137,73 +132,59 @@ void OsgOpenGLWindow::paintUnderGL() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgOpenGLWindow::keyPressEvent(QKeyEvent* event)
|
void OsgOpenGLWindow::keyPressEvent(QKeyEvent* event) {
|
||||||
{
|
|
||||||
Q_ASSERT(gw_);
|
Q_ASSERT(gw_);
|
||||||
// forward event to renderer
|
// forward event to renderer
|
||||||
gw_->keyPressEvent(event);
|
gw_->keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgOpenGLWindow::keyReleaseEvent(QKeyEvent* event)
|
void OsgOpenGLWindow::keyReleaseEvent(QKeyEvent* event) {
|
||||||
{
|
|
||||||
Q_ASSERT(gw_);
|
Q_ASSERT(gw_);
|
||||||
// forward event to renderer
|
// forward event to renderer
|
||||||
gw_->keyReleaseEvent(event);
|
gw_->keyReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgOpenGLWindow::mousePressEvent(QMouseEvent* event)
|
void OsgOpenGLWindow::mousePressEvent(QMouseEvent* event) {
|
||||||
{
|
|
||||||
Q_ASSERT(gw_);
|
Q_ASSERT(gw_);
|
||||||
// forward event to renderer
|
// forward event to renderer
|
||||||
gw_->mousePressEvent(event);
|
gw_->mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgOpenGLWindow::mouseReleaseEvent(QMouseEvent* event)
|
void OsgOpenGLWindow::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
{
|
|
||||||
Q_ASSERT(gw_);
|
Q_ASSERT(gw_);
|
||||||
// forward event to renderer
|
// forward event to renderer
|
||||||
gw_->mouseReleaseEvent(event);
|
gw_->mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgOpenGLWindow::mouseDoubleClickEvent(QMouseEvent* event)
|
void OsgOpenGLWindow::mouseDoubleClickEvent(QMouseEvent* event) {
|
||||||
{
|
|
||||||
Q_ASSERT(gw_);
|
Q_ASSERT(gw_);
|
||||||
// forward event to renderer
|
// forward event to renderer
|
||||||
gw_->mouseDoubleClickEvent(event);
|
gw_->mouseDoubleClickEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgOpenGLWindow::mouseMoveEvent(QMouseEvent* event)
|
void OsgOpenGLWindow::mouseMoveEvent(QMouseEvent* event) {
|
||||||
{
|
|
||||||
Q_ASSERT(gw_);
|
Q_ASSERT(gw_);
|
||||||
// forward event to renderer
|
// forward event to renderer
|
||||||
gw_->mouseMoveEvent(event);
|
gw_->mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgOpenGLWindow::wheelEvent(QWheelEvent* event)
|
void OsgOpenGLWindow::wheelEvent(QWheelEvent* event) {
|
||||||
{
|
|
||||||
Q_ASSERT(gw_);
|
Q_ASSERT(gw_);
|
||||||
// forward event to renderer
|
// forward event to renderer
|
||||||
gw_->wheelEvent(event);
|
gw_->wheelEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgOpenGLWindow::setDefaultDisplaySettings()
|
void OsgOpenGLWindow::setDefaultDisplaySettings() {
|
||||||
{
|
|
||||||
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
|
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
|
||||||
ds->setNvOptimusEnablement(1);
|
ds->setNvOptimusEnablement(1);
|
||||||
ds->setStereo(false);
|
ds->setStereo(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgOpenGLWindow::createRenderer()
|
|
||||||
{
|
|
||||||
// call this before creating a View...
|
|
||||||
setDefaultDisplaySettings();
|
|
||||||
|
|
||||||
/*m_renderer = new OSGRenderer(this);
|
|
||||||
double pixelRatio = screen()->devicePixelRatio();
|
|
||||||
m_renderer->setupOSG(width(), height(), pixelRatio);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void OsgOpenGLWindow::OnRenderFlush() {
|
void OsgOpenGLWindow::OnRenderFlush() {
|
||||||
shaderTextureId_ = gw_->GetFrameBufferId();
|
shaderTextureId_ = gw_->GetFrameBufferId();
|
||||||
updateTexture_ = true;
|
updateTexture_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OsgOpenGLWindow::OnRender() {
|
||||||
|
requestUpdate();
|
||||||
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <QOpenGLWindow>
|
#include <QOpenGLWindow>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
#include <QReadWriteLock>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
|
|
||||||
@ -32,15 +32,6 @@ namespace osgViewer
|
|||||||
class OsgOpenGLWindow : public QOpenGLWindow {
|
class OsgOpenGLWindow : public QOpenGLWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
protected:
|
|
||||||
OSGRenderer* m_renderer {nullptr};
|
|
||||||
bool _osgWantsToRenderFrame{true};
|
|
||||||
OpenThreads::ReadWriteMutex _osgMutex;
|
|
||||||
bool _isFirstFrame {true};
|
|
||||||
friend class OSGRenderer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OsgOpenGLWindow(QWidget* parent = nullptr);
|
OsgOpenGLWindow(QWidget* parent = nullptr);
|
||||||
~OsgOpenGLWindow() override;
|
~OsgOpenGLWindow() override;
|
||||||
@ -48,8 +39,6 @@ public:
|
|||||||
/** Get osgViewer View */
|
/** Get osgViewer View */
|
||||||
virtual osgViewer::Viewer* getOsgViewer();
|
virtual osgViewer::Viewer* getOsgViewer();
|
||||||
|
|
||||||
//! get mutex
|
|
||||||
virtual OpenThreads::ReadWriteMutex* mutex();
|
|
||||||
|
|
||||||
QWidget* AsWidget()
|
QWidget* AsWidget()
|
||||||
{
|
{
|
||||||
@ -65,8 +54,7 @@ protected:
|
|||||||
void resizeGL(int w, int h) override;
|
void resizeGL(int w, int h) override;
|
||||||
void paintUnderGL() override;
|
void paintUnderGL() override;
|
||||||
|
|
||||||
//! called before creating renderer
|
void setDefaultDisplaySettings();
|
||||||
virtual void setDefaultDisplaySettings();
|
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent* event) override;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
void keyReleaseEvent(QKeyEvent* event) override;
|
void keyReleaseEvent(QKeyEvent* event) override;
|
||||||
@ -76,10 +64,9 @@ protected:
|
|||||||
void mouseMoveEvent(QMouseEvent* event) override;
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
void wheelEvent(QWheelEvent* event) override;
|
void wheelEvent(QWheelEvent* event) override;
|
||||||
|
|
||||||
void createRenderer();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnRenderFlush();
|
void OnRenderFlush();
|
||||||
|
void OnRender();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget* widget_{ nullptr };
|
QWidget* widget_{ nullptr };
|
||||||
@ -89,6 +76,7 @@ private:
|
|||||||
class QOpenGLVertexArrayObject* vao_{ nullptr };
|
class QOpenGLVertexArrayObject* vao_{ nullptr };
|
||||||
uint32_t shaderTextureId_{ 0 };
|
uint32_t shaderTextureId_{ 0 };
|
||||||
bool updateTexture_{ false };
|
bool updateTexture_{ false };
|
||||||
|
QTimer timer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OSGQOPENGLWINDOW_H
|
#endif // OSGQOPENGLWINDOW_H
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "scene/OEScene.h"
|
#include "scene/OEScene.h"
|
||||||
#include "viewer/OsgViewWidget.h"
|
|
||||||
#include "viewer/GraphicsWindowEx.h"
|
#include "viewer/GraphicsWindowEx.h"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user