Skip to content

Commit 08f1a7f

Browse files
committedMay 5, 2021
Use Irrlicht functions to query npot texture support
1 parent de85bc9 commit 08f1a7f

File tree

4 files changed

+10
-48
lines changed

4 files changed

+10
-48
lines changed
 

Diff for: ‎src/CMakeLists.txt

+5-9
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ endif()
102102
option(ENABLE_GLES "Use OpenGL ES instead of OpenGL" FALSE)
103103
mark_as_advanced(ENABLE_GLES)
104104
if(BUILD_CLIENT)
105-
if(ENABLE_GLES)
106-
find_package(OpenGLES2 REQUIRED)
107-
else()
108-
# transitive dependency from Irrlicht (see longer explanation below)
109-
if(NOT WIN32)
105+
# transitive dependency from Irrlicht (see longer explanation below)
106+
if(NOT WIN32)
107+
if(ENABLE_GLES)
108+
find_package(OpenGLES2 REQUIRED)
109+
else()
110110
set(OPENGL_GL_PREFERENCE "LEGACY" CACHE STRING
111111
"See CMake Policy CMP0072 for reference. GLVND is broken on some nvidia setups")
112112
set(OpenGL_GL_PREFERENCE ${OPENGL_GL_PREFERENCE})
@@ -523,10 +523,6 @@ include_directories(
523523
${PROJECT_SOURCE_DIR}/script
524524
)
525525

526-
if(ENABLE_GLES)
527-
include_directories(${OPENGLES2_INCLUDE_DIR} ${EGL_INCLUDE_DIR})
528-
endif()
529-
530526
if(USE_GETTEXT)
531527
include_directories(${GETTEXT_INCLUDE_DIR})
532528
endif()

Diff for: ‎src/client/guiscalingfilter.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2323
#include "util/numeric.h"
2424
#include <cstdio>
2525
#include "client/renderingengine.h"
26-
#include "client/tile.h" // hasNPotSupport()
2726

2827
/* Maintain a static cache to store the images that correspond to textures
2928
* in a format that's manipulable by code. Some platforms exhibit issues
@@ -117,7 +116,7 @@ video::ITexture *guiScalingResizeCached(video::IVideoDriver *driver,
117116
#if ENABLE_GLES
118117
// Some platforms are picky about textures being powers of 2, so expand
119118
// the image dimensions to the next power of 2, if necessary.
120-
if (!hasNPotSupport()) {
119+
if (!driver->queryFeature(video::EVDF_TEXTURE_NPOT)) {
121120
video::IImage *po2img = driver->createImage(src->getColorFormat(),
122121
core::dimension2d<u32>(npot2((u32)destrect.getWidth()),
123122
npot2((u32)destrect.getHeight())));

Diff for: ‎src/client/tile.cpp

+3-35
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3434
#include "guiscalingfilter.h"
3535
#include "renderingengine.h"
3636

37-
38-
#if ENABLE_GLES
39-
#ifdef _IRR_COMPILE_WITH_OGLES1_
40-
#include <GLES/gl.h>
41-
#else
42-
#include <GLES2/gl2.h>
43-
#endif
44-
#endif
45-
4637
/*
4738
A cache from texture name to texture path
4839
*/
@@ -1013,42 +1004,19 @@ video::IImage* TextureSource::generateImage(const std::string &name)
10131004

10141005
#if ENABLE_GLES
10151006

1016-
1017-
static inline u16 get_GL_major_version()
1018-
{
1019-
const GLubyte *gl_version = glGetString(GL_VERSION);
1020-
return (u16) (gl_version[0] - '0');
1021-
}
1022-
1023-
/**
1024-
* Check if hardware requires npot2 aligned textures
1025-
* @return true if alignment NOT(!) requires, false otherwise
1026-
*/
1027-
1028-
bool hasNPotSupport()
1029-
{
1030-
// Only GLES2 is trusted to correctly report npot support
1031-
// Note: we cache the boolean result, the GL context will never change.
1032-
static const bool supported = get_GL_major_version() > 1 &&
1033-
glGetString(GL_EXTENSIONS) &&
1034-
strstr((char *)glGetString(GL_EXTENSIONS), "GL_OES_texture_npot");
1035-
return supported;
1036-
}
1037-
10381007
/**
10391008
* Check and align image to npot2 if required by hardware
10401009
* @param image image to check for npot2 alignment
10411010
* @param driver driver to use for image operations
10421011
* @return image or copy of image aligned to npot2
10431012
*/
1044-
1045-
video::IImage * Align2Npot2(video::IImage * image,
1046-
video::IVideoDriver* driver)
1013+
video::IImage *Align2Npot2(video::IImage *image,
1014+
video::IVideoDriver *driver)
10471015
{
10481016
if (image == NULL)
10491017
return image;
10501018

1051-
if (hasNPotSupport())
1019+
if (driver->queryFeature(video::EVDF_TEXTURE_NPOT))
10521020
return image;
10531021

10541022
core::dimension2d<u32> dim = image->getDimension();

Diff for: ‎src/client/tile.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ class IWritableTextureSource : public ITextureSource
134134
IWritableTextureSource *createTextureSource();
135135

136136
#if ENABLE_GLES
137-
bool hasNPotSupport();
138-
video::IImage * Align2Npot2(video::IImage * image, irr::video::IVideoDriver* driver);
137+
video::IImage *Align2Npot2(video::IImage *image, video::IVideoDriver *driver);
139138
#endif
140139

141140
enum MaterialType{

0 commit comments

Comments
 (0)
Please sign in to comment.