Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL & Linux CI fixes #88

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ jobs:
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libkf5syntaxhighlighting-dev ninja-build qtbase5-dev
sudo apt-get install -y \
libjpeg-turbo8-dev \
libkf5syntaxhighlighting-dev \
libpng-dev \
ninja-build \
qtbase5-dev

- name: Checkout string_theory
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ find_package(string_theory 2.0 REQUIRED)
if(NOT DEFINED QT_VERSION_MAJOR)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
endif()
find_package(Qt${QT_VERSION_MAJOR} 5.10 REQUIRED COMPONENTS Core Widgets)
find_package(Qt${QT_VERSION_MAJOR} 5.10 REQUIRED COMPONENTS Core Widgets OpenGL)
if(Qt5_FOUND AND NOT TARGET Qt::Core)
# The version-generic targets were only added in Qt 5.15
foreach(_qt_lib Core Widgets)
foreach(_qt_lib Core Widgets OpenGL)
add_library(Qt::${_qt_lib} INTERFACE IMPORTED)
set_target_properties(Qt::${_qt_lib} PROPERTIES
INTERFACE_LINK_LIBRARIES "Qt5::${_qt_lib}")
Expand Down
5 changes: 1 addition & 4 deletions src/PrpShop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,13 @@ include_directories("${PROJECT_SOURCE_DIR}/src/PrpShop")
# QtOpenGL dependencies (maybe the Qt OpenGL cmake stuff is broken, but I had
# to copy this here from Qt4ConfigDependentSettings.cmake)
find_package(OpenGL)
set(QT_QTOPENGL_LIB_DEPENDENCIES ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY})

add_executable(PrpShop WIN32 MACOSX_BUNDLE
${PrpShop_Sources} ${PrpShop_Headers} ${PrpShop_QRC})
target_link_libraries(PrpShop PSCommon Qt::Core Qt::Widgets)
target_link_libraries(PrpShop PSCommon HSPlasma OpenGL::GL Qt::Core Qt::Widgets Qt::OpenGL)
if(QT_VERSION_MAJOR VERSION_GREATER_EQUAL 6)
target_link_libraries(PrpShop Qt::OpenGLWidgets)
endif()
target_link_libraries(PrpShop HSPlasma)
target_link_libraries(PrpShop ${QT_QTOPENGL_LIB_DEPENDENCIES})

if(APPLE)
set(MACOSX_BUNDLE true)
Expand Down
17 changes: 13 additions & 4 deletions src/PrpShop/PRP/Render/QPlasmaRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

#include "QPlasmaRender.h"

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#include <Debug/plDebug.h>
#include <PRP/Surface/plLayer.h>
#include <PRP/Surface/plCubicEnvironmap.h>
Expand Down Expand Up @@ -116,6 +113,8 @@ QActionGroup* QPlasmaRender::createViewActions()

void QPlasmaRender::initializeGL()
{
initializeOpenGLFunctions();

glShadeModel(GL_SMOOTH);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
Expand All @@ -139,7 +138,17 @@ void QPlasmaRender::resizeGL(int width, int height)
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (float)width/(float)height, 0.001f, 20000.0f);

// Below is essentially the implementation of
// gluPerspective(45.0f, (float)width/(float)height, 0.001f, 20000.0f);

GLdouble xmin, xmax, ymin, ymax;
ymax = 0.001f; // * tan(45.f degrees) which == 1
ymin = -ymax;
xmin = ymin * ((float)width/(float)height);
xmax = ymax * ((float)width/(float)height);

glFrustum(xmin, xmax, ymin, ymax, 0.001f, 20000.0f);
}

void QPlasmaRender::paintGL()
Expand Down
2 changes: 1 addition & 1 deletion src/PrpShop/PRP/Render/QPlasmaRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "QTrackball.h"

class QPlasmaRender : public QOpenGLWidget
class QPlasmaRender : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT

Expand Down
Loading