Revert "Replace deprecated QGLWidget with QOpenGLWidget"
This reverts commit 2f7adf19d0
.
pull/207/head
parent
c80ad6c12e
commit
03be74e3c7
|
@ -12,6 +12,7 @@ DEFINES += GIT_COMMIT=\\\"$$GIT_COMMIT\\\"
|
|||
QMAKE_CXXFLAGS += -std=c++11
|
||||
|
||||
QT += widgets
|
||||
QT += opengl
|
||||
|
||||
contains(DEFINES, TEST_MODEL) {
|
||||
QT += testlib
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include <QDesktopWidget>
|
||||
#include <QInputDialog>
|
||||
#include <QUrl>
|
||||
#include <QSurfaceFormat>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
@ -274,17 +273,24 @@ void CelestiaAppWindow::init(const QString& qConfigFileName,
|
|||
|
||||
// Enable antialiasing if requested in the config file.
|
||||
// TODO: Make this settable via the GUI
|
||||
QSurfaceFormat glformat = QSurfaceFormat::defaultFormat();
|
||||
QGLFormat glformat = QGLFormat::defaultFormat();
|
||||
if (m_appCore->getConfig()->aaSamples > 1)
|
||||
{
|
||||
glformat.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
glformat.setSampleBuffers(true);
|
||||
glformat.setSamples(m_appCore->getConfig()->aaSamples);
|
||||
QSurfaceFormat::setDefaultFormat(glformat);
|
||||
QGLFormat::setDefaultFormat(glformat);
|
||||
}
|
||||
|
||||
glWidget = new CelestiaGlWidget(nullptr, "Celestia", m_appCore);
|
||||
glWidget->makeCurrent();
|
||||
|
||||
GLenum glewErr = glewInit();
|
||||
if (glewErr != GLEW_OK)
|
||||
{
|
||||
QMessageBox::critical(0, "Celestia",
|
||||
QString(_("Celestia was unable to initialize OpenGL extensions (error %1). Graphics quality will be reduced.")).arg(glewErr));
|
||||
}
|
||||
|
||||
m_appCore->setCursorHandler(glWidget);
|
||||
m_appCore->setContextMenuCallback(ContextMenu);
|
||||
MainWindowInstance = this; // TODO: Fix context menu callback
|
||||
|
@ -635,7 +641,7 @@ void CelestiaAppWindow::saveBookmarks()
|
|||
void CelestiaAppWindow::celestia_tick()
|
||||
{
|
||||
m_appCore->tick();
|
||||
glWidget->update();
|
||||
glWidget->updateGL();
|
||||
}
|
||||
|
||||
|
||||
|
@ -673,7 +679,7 @@ void CelestiaAppWindow::slotGrabImage()
|
|||
QFileInfo saveAsFile(saveAsName);
|
||||
|
||||
//glWidget->repaint();
|
||||
QImage grabbedImage = glWidget->grabFramebuffer();
|
||||
QImage grabbedImage = glWidget->grabFrameBuffer();
|
||||
grabbedImage.save(saveAsName);
|
||||
|
||||
settings.setValue("GrabImageDir", saveAsFile.absolutePath());
|
||||
|
@ -784,7 +790,7 @@ void CelestiaAppWindow::slotCaptureVideo()
|
|||
void CelestiaAppWindow::slotCopyImage()
|
||||
{
|
||||
//glWidget->repaint();
|
||||
QImage grabbedImage = glWidget->grabFramebuffer();
|
||||
QImage grabbedImage = glWidget->grabFrameBuffer();
|
||||
QApplication::clipboard()->setImage(grabbedImage);
|
||||
m_appCore->flash(QString(_("Captured screen shot to clipboard")).toStdString());
|
||||
}
|
||||
|
@ -1009,7 +1015,7 @@ void CelestiaAppWindow::slotAddBookmark()
|
|||
appState.captureState(m_appCore);
|
||||
|
||||
// Capture the current frame buffer to use as a bookmark icon.
|
||||
QImage grabbedImage = glWidget->grabFramebuffer();
|
||||
QImage grabbedImage = glWidget->grabFrameBuffer();
|
||||
int width = grabbedImage.width();
|
||||
int height = grabbedImage.height();
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <QPaintDevice>
|
||||
#include <QMouseEvent>
|
||||
#include <QSettings>
|
||||
#include <QMessageBox>
|
||||
|
||||
#ifndef DEBUG
|
||||
# define G_DISABLE_ASSERT
|
||||
|
@ -62,7 +61,7 @@ const unsigned int DEFAULT_TEXTURE_RESOLUTION = medres;
|
|||
|
||||
|
||||
CelestiaGlWidget::CelestiaGlWidget(QWidget* parent, const char* /* name */, CelestiaCore* core) :
|
||||
QOpenGLWidget(parent)
|
||||
QGLWidget(parent)
|
||||
{
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
|
@ -113,16 +112,6 @@ static GLContext::GLRenderPath getBestAvailableRenderPath(const GLContext& /*glc
|
|||
|
||||
void CelestiaGlWidget::initializeGL()
|
||||
{
|
||||
GLenum glewErr = glewInit();
|
||||
|
||||
if (glewErr != GLEW_OK)
|
||||
{
|
||||
QString errMsg;
|
||||
errMsg = QString(_("GLEW Error: %1\n")).arg(reinterpret_cast<const char*>(glewGetErrorString(glewErr)));
|
||||
QMessageBox::critical(0, "Celestia", errMsg);
|
||||
exit(1); // We need OpenGL 2.1 at least
|
||||
}
|
||||
|
||||
if (!appCore->initRenderer())
|
||||
{
|
||||
// cerr << "Failed to initialize renderer.\n";
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
#include <QGLWidget>
|
||||
|
||||
#include "celestia/celestiacore.h"
|
||||
#include "celengine/simulation.h"
|
||||
|
@ -28,7 +28,7 @@
|
|||
*@author Christophe Teyssier
|
||||
*/
|
||||
|
||||
class CelestiaGlWidget : public QOpenGLWidget, public CelestiaCore::CursorHandler
|
||||
class CelestiaGlWidget : public QGLWidget, public CelestiaCore::CursorHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
Loading…
Reference in New Issue