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

Fix compilation on Qt configured for OpenGL ES2 #2970

Merged
merged 1 commit into from
Jan 9, 2023
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
2 changes: 1 addition & 1 deletion plugins/Scenery3d/src/Frustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void Frustum::drawFrustum() const
{
// Minimum to avoid trouble when building on pure OpenGL ES systems
// Not sure about ANGLE!
#if !defined(QT_OPENGL_ES_2)
#if !QT_CONFIG(opengles2)

Vec3f ntl = drawCorners[NTL];
Vec3f ntr = drawCorners[NTR];
Expand Down
2 changes: 1 addition & 1 deletion plugins/Scenery3d/src/GLFuncs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <QOpenGLContext>
#include <QOpenGLFunctions_1_0>

#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
//! Defines some OpenGL functions not resolved through StelOpenGL (which only contains base OpenGL ES2 functions)
//! Using the QOpenGLFunctions_*_* directly would solve this better, but it conflicts with the
//! current StelOpenGL header dramatically.
Expand Down
2 changes: 1 addition & 1 deletion plugins/Scenery3d/src/Polyhedron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ const QVector<Vec3f> &Polyhedron::getVerts() const

void Polyhedron::render() const
{
#if !defined(QT_OPENGL_ES_2)
#if !QT_CONFIG(opengles2)

//render each polygon
glExtFuncs->glColor3f(0.4f,0.4f,0.4f);
Expand Down
20 changes: 10 additions & 10 deletions plugins/Scenery3d/src/S3DRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Q_LOGGING_CATEGORY(s3drenderer, "stel.plugin.scenery3d.renderer")
static const float LUNAR_BRIGHTNESS_FACTOR=0.2f;
static const float VENUS_BRIGHTNESS_FACTOR=0.005f;

#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
//this is the place where this is initialized
GLExtFuncs* glExtFuncs;
#endif
Expand Down Expand Up @@ -120,7 +120,7 @@ S3DRenderer::~S3DRenderer()
deleteShadowmapping();
deleteCubemapping();

#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
//delete extension functions
delete glExtFuncs;
#endif
Expand Down Expand Up @@ -1403,7 +1403,7 @@ void S3DRenderer::drawCoordinatesText()
void S3DRenderer::drawDebug()
{
//frustum/box debug rendering only on desktop GL
#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
if(!shaderParameters.openglES)
{
QOpenGLShaderProgram* debugShader = shaderManager.getDebugShader();
Expand Down Expand Up @@ -1654,7 +1654,7 @@ void S3DRenderer::init()
QOpenGLContext* ctx = QOpenGLContext::currentContext();
Q_ASSERT(ctx);

#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
//initialize additional functions needed and not provided through StelOpenGL
glExtFuncs = new GLExtFuncs();
glExtFuncs->init(ctx);
Expand Down Expand Up @@ -1787,7 +1787,7 @@ bool S3DRenderer::initCubemapping()
}


#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
//if we are on an ES context, it may not be possible to specify texture bitdepth
bool isEs = QOpenGLContext::currentContext()->isOpenGLES();
GLint colorFormat = isEs ? GL_RGBA : GL_RGBA8;
Expand Down Expand Up @@ -1916,7 +1916,7 @@ bool S3DRenderer::initCubemapping()

GET_GLERROR()

#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
//attach cube tex + cube depth
//note that this function will be a NULL pointer if GS is not supported, so it is important to check support before using
glExtFuncs->glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,cubeMapCubeTex,0);
Expand Down Expand Up @@ -2219,7 +2219,7 @@ bool S3DRenderer::initShadowmapping()
//Bind the depth map and setup parameters
glBindTexture(GL_TEXTURE_2D, shadowMapsArray.at(i));

#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
bool isEs = QOpenGLContext::currentContext()->isOpenGLES();
GLenum depthPcss = isEs ? GL_DEPTH_COMPONENT : GL_DEPTH_COMPONENT32F;
GLenum depthNormal = isEs ? GL_DEPTH_COMPONENT : GL_DEPTH_COMPONENT16;
Expand All @@ -2238,7 +2238,7 @@ bool S3DRenderer::initShadowmapping()
//NOTE: can't use depth compare mode on ES2
if(!pcssEnabled)
{
#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
if(!isEs)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
Expand All @@ -2254,7 +2254,7 @@ bool S3DRenderer::initShadowmapping()
|| shaderParameters.shadowFilterQuality == S3DEnum::SFQ_HIGH_HARDWARE) ? GL_LINEAR : GL_NEAREST;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
if(!isEs)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL,0);
Expand All @@ -2273,7 +2273,7 @@ bool S3DRenderer::initShadowmapping()
//but the respective functions are not available on GLES2?
//On ANGLE, it seems to work without this settings (framebuffer is complete, etc.)
//but I don't know if it will work on other ES platforms?
#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
if(!isEs)
{
glExtFuncs->glDrawBuffer(GL_NONE); // essential for depth-only FBOs!!!
Expand Down
2 changes: 1 addition & 1 deletion plugins/Scenery3d/src/SPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void SPolygon::addUniqueVert(const Vec3f &v)

void SPolygon::render()
{
#if !defined(QT_OPENGL_ES_2)
#if !QT_CONFIG(opengles2)
//render each polygon
glExtFuncs->glColor3f(0.4f,0.4f,0.4f);

Expand Down
2 changes: 1 addition & 1 deletion src/core/StelOpenGL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace StelOpenGL

// This is still needed for the ARM platform (armhf)

#if defined(QT_OPENGL_ES_2)
#if QT_CONFIG(opengles2)
#ifndef GL_DOUBLE
#define GL_DOUBLE GL_FLOAT
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/core/modules/Planet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3345,7 +3345,7 @@ bool Planet::initFBO()
GL(gl->glActiveTexture(GL_TEXTURE1));
GL(gl->glBindTexture(GL_TEXTURE_2D, shadowTex));

#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
if(!isGLESv2)
{
GL(gl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0));
Expand Down Expand Up @@ -3376,7 +3376,7 @@ bool Planet::initFBO()
//see GL_EXT_framebuffer_object and GL_ARB_framebuffer_object
//on ES 2, this seems to be allowed (there are no glDrawBuffers/glReadBuffer functions there), see GLES spec section 4.4.4
//probably same on ES 3: though it has glDrawBuffers/glReadBuffer but no mention of it in section 4.4.4 and no FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER is defined
#ifndef QT_OPENGL_ES_2
#if !QT_CONFIG(opengles2)
if(!ctx->isOpenGLES())
{
#if (QT_VERSION>=QT_VERSION_CHECK(6,0,0))
Expand Down