Skip to content

Commit

Permalink
[GL] Fixed compile errors in GLES and WebGL profiles.
Browse files Browse the repository at this point in the history
- Fixed include path to GLProfile.h.
- Exclude Desktop GL exclusive sampler parameters from GLEmulatedSampler in GLES and WebGL profiles.
- Remove half-supported GL_EXT_separate_shader_objects extension; only GL_ARB_separate_shader_objects is supported.
- Also fix BuildAndroid.sh script when -d/--debug argument is not present.
  • Loading branch information
LukasBanana committed Sep 22, 2024
1 parent 39eef8b commit e4b86be
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 17 deletions.
10 changes: 3 additions & 7 deletions BuildAndroid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,13 @@ generate_app_project()

if [ $BUILD_APPS -ne 0 ]; then

PROJECT_DEBUG_BUILD=0

BIN_FILE_BASE="${OUTPUT_DIR}/${SUPPORTED_ANDROID_ABIS[0]}/build/libExample_"
BIN_FILE_BASE_LEN=${#BIN_FILE_BASE}

EXAMPLE_BIN_FILES_D=(${BIN_FILE_BASE}*D.so)
if [ -z "$EXAMPLE_BIN_FILES_D" ]; then
EXAMPLE_BIN_FILES=(${BIN_FILE_BASE}*.so)
if [ $BUILD_TYPE = "Debug" ]; then
EXAMPLE_BIN_FILES=(${BIN_FILE_BASE}*D.so)
else
EXAMPLE_BIN_FILES=(${EXAMPLE_BIN_FILES_D[@]})
PROJECT_DEBUG_BUILD=1
EXAMPLE_BIN_FILES=(${BIN_FILE_BASE}*.so)
fi

for BIN_FILE in ${EXAMPLE_BIN_FILES[@]}; do
Expand Down
7 changes: 1 addition & 6 deletions sources/Renderer/OpenGL/OpenGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,8 @@
# define LLGL_GLEXT_DRAW_INSTANCED 1
#endif

#if GL_ARB_separate_shader_objects || GL_ES_VERSION_3_1
#if GL_ARB_separate_shader_objects
# define LLGL_GLEXT_SEPARATE_SHADER_OBJECTS 1
#elif GL_EXT_separate_shader_objects
# define LLGL_GLEXT_SEPARATE_SHADER_OBJECTS 1
# ifndef GL_PROGRAM_PIPELINE_BINDING
# define GL_PROGRAM_PIPELINE_BINDING GL_PROGRAM_PIPELINE_BINDING_EXT
# endif
#endif

#if GL_ARB_uniform_buffer_object || GL_ES_VERSION_3_0
Expand Down
2 changes: 1 addition & 1 deletion sources/Renderer/OpenGL/Profile/GLES/GLESProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt).
*/

#include "../../GLProfile.h"
#include "../GLProfile.h"
#include "../../Ext/GLExtensions.h"
#include "../../../../Core/Assertion.h"
#include <LLGL/RenderSystemFlags.h>
Expand Down
1 change: 0 additions & 1 deletion sources/Renderer/OpenGL/Profile/GLES/GLESProfileCaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

#include "../../GLRenderingCaps.h"
#include "../../GLProfile.h"
#include "../../GLTypes.h"
#include "../../Ext/GLExtensions.h"
#include "../../Ext/GLExtensionRegistry.h"
Expand Down
2 changes: 1 addition & 1 deletion sources/Renderer/OpenGL/Profile/WebGL/WebGLProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt).
*/

#include "../../GLProfile.h"
#include "../GLProfile.h"
#include "../../GLTypes.h"
#include "../../Ext/GLExtensions.h"
#include "../../../../Core/Assertion.h"
Expand Down
1 change: 0 additions & 1 deletion sources/Renderer/OpenGL/Profile/WebGL/WebGLProfileCaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

#include "../../GLRenderingCaps.h"
#include "../../GLProfile.h"
#include "../../GLTypes.h"
#include "../../Ext/GLExtensions.h"
#include "../../Ext/GLExtensionRegistry.h"
Expand Down
32 changes: 32 additions & 0 deletions sources/Renderer/OpenGL/Texture/GLEmulatedSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ static GLenum GetGLSamplerMinFilter(const SamplerDescriptor& desc)
return GLTypes::Map(desc.minFilter);
}

#if LLGL_SAMPLER_BORDER_COLOR

static bool IsGLTextureWrapUsingBorder(GLenum mode)
{
/* Accroding to GL2.x spec: "Border texture elements are accessed only if wrapping is set to GL_CLAMP or GL_CLAMP_TO_BORDER" */
return (mode == GL_CLAMP || mode == GL_CLAMP_TO_BORDER);
}

#endif // /LLGL_SAMPLER_BORDER_COLOR

void GLEmulatedSampler::SamplerParameters(const SamplerDescriptor& desc)
{
/* Store texture coordinate wrap modes */
Expand All @@ -40,28 +44,38 @@ void GLEmulatedSampler::SamplerParameters(const SamplerDescriptor& desc)
/* Store filter states */
minFilter_ = GetGLSamplerMinFilter(desc);
magFilter_ = GLTypes::Map(desc.magFilter);
#if LLGL_OPENGL
maxAnisotropy_ = static_cast<float>(desc.maxAnisotropy);
#endif

/* Store MIP-map level selection */
minLod_ = desc.minLOD;
maxLod_ = desc.maxLOD;
#if LLGL_OPENGL
lodBias_ = desc.mipMapLODBias;
#endif

/* Store compare operation */
if (desc.compareEnabled)
{
#if LLGL_GL_ENABLE_OPENGL2X
compareMode_ = GL_COMPARE_R_TO_TEXTURE;
#else
compareMode_ = GL_COMPARE_REF_TO_TEXTURE;
#endif
compareFunc_ = GLTypes::Map(desc.compareOp);
}
else
compareMode_ = GL_NONE;

#if LLGL_SAMPLER_BORDER_COLOR
/* Set border color */
borderColor_[0] = (std::max)(0.0f, (std::min)(desc.borderColor[0], 1.0f));
borderColor_[1] = (std::max)(0.0f, (std::min)(desc.borderColor[1], 1.0f));
borderColor_[2] = (std::max)(0.0f, (std::min)(desc.borderColor[2], 1.0f));
borderColor_[3] = (std::max)(0.0f, (std::min)(desc.borderColor[3], 1.0f));
borderColorUsed_ = (IsGLTextureWrapUsingBorder(wrapS_) || IsGLTextureWrapUsingBorder(wrapT_) || IsGLTextureWrapUsingBorder(wrapR_));
#endif // /LLGL_SAMPLER_BORDER_COLOR
}

static void GLSetTexParameteri(GLenum target, GLenum param, GLint value)
Expand Down Expand Up @@ -112,15 +126,21 @@ void GLEmulatedSampler::BindTexParameters(GLenum target, const GLEmulatedSampler
GLChangeTexParameteri(target, GL_TEXTURE_WRAP_R, wrapR_, prevSampler->wrapR_);
GLChangeTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter_, prevSampler->minFilter_);
GLChangeTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter_, prevSampler->magFilter_);
#if LLGL_OPENGL
GLChangeTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY, maxAnisotropy_, prevSampler->maxAnisotropy_);
#endif
GLChangeTexParameterf(target, GL_TEXTURE_MIN_LOD, minLod_, prevSampler->minLod_);
GLChangeTexParameterf(target, GL_TEXTURE_MAX_LOD, maxLod_, prevSampler->maxLod_);
#if LLGL_OPENGL
GLChangeTexParameterf(target, GL_TEXTURE_LOD_BIAS, lodBias_, prevSampler->lodBias_);
#endif
GLChangeTexParameteri(target, GL_TEXTURE_COMPARE_MODE, compareMode_, prevSampler->compareMode_);
if (compareMode_ != GL_NONE)
GLChangeTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, compareFunc_, prevSampler->compareFunc_);
#if LLGL_SAMPLER_BORDER_COLOR
if (borderColorUsed_)
GLChangeTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, borderColor_, prevSampler->borderColor_);
#endif
}
else
{
Expand All @@ -130,13 +150,19 @@ void GLEmulatedSampler::BindTexParameters(GLenum target, const GLEmulatedSampler
GLSetTexParameteri(target, GL_TEXTURE_WRAP_R, wrapR_);
GLSetTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter_);
GLSetTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter_);
#if LLGL_OPENGL
GLSetTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY, maxAnisotropy_);
#endif
GLSetTexParameterf(target, GL_TEXTURE_MIN_LOD, minLod_);
GLSetTexParameterf(target, GL_TEXTURE_MAX_LOD, maxLod_);
#if LLGL_OPENGL
GLSetTexParameterf(target, GL_TEXTURE_LOD_BIAS, lodBias_);
#endif
GLSetTexParameteri(target, GL_TEXTURE_COMPARE_MODE, compareMode_);
GLSetTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, compareFunc_);
#if LLGL_SAMPLER_BORDER_COLOR
GLSetTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, borderColor_);
#endif
}
}

Expand All @@ -147,23 +173,29 @@ int GLEmulatedSampler::CompareSWO(const GLEmulatedSampler& lhs, const GLEmulated
LLGL_COMPARE_MEMBER_SWO( wrapR_ );
LLGL_COMPARE_MEMBER_SWO( minFilter_ );
LLGL_COMPARE_MEMBER_SWO( magFilter_ );
#if LLGL_OPENGL
LLGL_COMPARE_MEMBER_SWO( maxAnisotropy_ );
#endif
LLGL_COMPARE_MEMBER_SWO( minLod_ );
LLGL_COMPARE_MEMBER_SWO( maxLod_ );
#if LLGL_OPENGL
LLGL_COMPARE_MEMBER_SWO( lodBias_ );
#endif
LLGL_COMPARE_MEMBER_SWO( compareMode_ );
if (lhs.compareMode_ != GL_NONE)
{
/* Only compare comparison-function if compare-mode is enabled */
LLGL_COMPARE_MEMBER_SWO( compareFunc_ );
}
#if LLGL_SAMPLER_BORDER_COLOR
if (lhs.borderColorUsed_)
{
LLGL_COMPARE_MEMBER_SWO( borderColor_[0] );
LLGL_COMPARE_MEMBER_SWO( borderColor_[1] );
LLGL_COMPARE_MEMBER_SWO( borderColor_[2] );
LLGL_COMPARE_MEMBER_SWO( borderColor_[3] );
}
#endif // /LLGL_SAMPLER_BORDER_COLOR
return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions sources/Renderer/OpenGL/Texture/GLEmulatedSampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@ class GLEmulatedSampler final : public Sampler
GLint wrapR_ = GL_REPEAT;
GLint minFilter_ = GL_NEAREST_MIPMAP_LINEAR;
GLint magFilter_ = GL_LINEAR;
#if LLGL_OPENGL
GLfloat maxAnisotropy_ = 0.0f;
#endif
GLfloat minLod_ = -1000.0f;
GLfloat maxLod_ = +1000.0f;
#if LLGL_OPENGL
GLfloat lodBias_ = 0.0f;
#endif
GLint compareMode_ = GL_NONE;
GLint compareFunc_ = GL_LESS;
#if LLGL_SAMPLER_BORDER_COLOR
GLfloat borderColor_[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
bool borderColorUsed_ = false;
#endif

};

Expand Down

0 comments on commit e4b86be

Please sign in to comment.