aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2019-07-25 00:01:25 +0200
committersfan5 <sfan5@live.de>2019-08-04 16:12:52 +0200
commitca363d3ef805a39fe4e821813b1efa53b2c9c805 (patch)
tree20ed44b34cdbd66b53d7c0c8e7275f134276811f /src/client
parent526a9e4b66abaf83eb6b1aaa3e93375acd87b830 (diff)
downloadminetest-ca363d3ef805a39fe4e821813b1efa53b2c9c805.tar.gz
minetest-ca363d3ef805a39fe4e821813b1efa53b2c9c805.tar.bz2
minetest-ca363d3ef805a39fe4e821813b1efa53b2c9c805.zip
Unify OpenGL ES support
Diffstat (limited to 'src/client')
-rw-r--r--src/client/renderingengine.cpp7
-rw-r--r--src/client/sky.cpp5
-rw-r--r--src/client/tile.cpp18
-rw-r--r--src/client/tile.h5
4 files changed, 23 insertions, 12 deletions
diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp
index 631616c06..6e6509eeb 100644
--- a/src/client/renderingengine.cpp
+++ b/src/client/renderingengine.cpp
@@ -48,7 +48,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif
-#ifdef __ANDROID__
+#if ENABLE_GLES
#include "filesys.h"
#endif
@@ -131,6 +131,11 @@ RenderingEngine::RenderingEngine(IEventReceiver *receiver)
params.OGLES2ShaderPath = std::string(porting::path_user + DIR_DELIM + "media" +
DIR_DELIM + "Shaders" + DIR_DELIM).c_str();
// clang-format on
+#elif ENABLE_GLES
+ // there is no standardized path for these on desktop
+ std::string rel_path = std::string("client") + DIR_DELIM
+ + "shaders" + DIR_DELIM + "Irrlicht";
+ params.OGLES2ShaderPath = (porting::path_share + DIR_DELIM + rel_path + DIR_DELIM).c_str();
#endif
m_device = createDeviceEx(params);
diff --git a/src/client/sky.cpp b/src/client/sky.cpp
index 9d0957450..346cd0642 100644
--- a/src/client/sky.cpp
+++ b/src/client/sky.cpp
@@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/renderingengine.h"
#include "settings.h"
#include "camera.h" // CameraModes
+#include "config.h"
Sky::Sky(s32 id, ITextureSource *tsrc):
@@ -44,7 +45,7 @@ Sky::Sky(s32 id, ITextureSource *tsrc):
video::SMaterial mat;
mat.Lighting = false;
-#ifdef __ANDROID__
+#if ENABLE_GLES
mat.ZBuffer = video::ECFN_DISABLED;
#else
mat.ZBuffer = video::ECFN_NEVER;
@@ -273,7 +274,7 @@ void Sky::render()
// Stars are only drawn when brighter than skycolor
if (starcolor.getBlue() < m_skycolor.getBlue())
break;
-#ifdef __ANDROID__
+#if ENABLE_GLES
u16 indices[SKY_STAR_COUNT * 3];
video::S3DVertex vertices[SKY_STAR_COUNT * 3];
for (u32 i = 0; i < SKY_STAR_COUNT; i++) {
diff --git a/src/client/tile.cpp b/src/client/tile.cpp
index 72f7358b1..82f989d89 100644
--- a/src/client/tile.cpp
+++ b/src/client/tile.cpp
@@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <algorithm>
#include <ICameraSceneNode.h>
+#include <IrrCompileConfig.h>
#include "util/string.h"
#include "util/container.h"
#include "util/thread.h"
@@ -34,8 +35,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "renderingengine.h"
-#ifdef __ANDROID__
+#if ENABLE_GLES
+#ifdef _IRR_COMPILE_WITH_OGLES1_
#include <GLES/gl.h>
+#else
+#include <GLES2/gl2.h>
+#endif
#endif
/*
@@ -595,7 +600,7 @@ u32 TextureSource::generateTexture(const std::string &name)
video::ITexture *tex = NULL;
if (img != NULL) {
-#ifdef __ANDROID__
+#if ENABLE_GLES
img = Align2Npot2(img, driver);
#endif
// Create texture from resulting image
@@ -752,7 +757,7 @@ void TextureSource::rebuildImagesAndTextures()
// Recreate textures
for (TextureInfo &ti : m_textureinfo_cache) {
video::IImage *img = generateImage(ti.name);
-#ifdef __ANDROID__
+#if ENABLE_GLES
img = Align2Npot2(img, driver);
#endif
// Create texture from resulting image
@@ -989,8 +994,7 @@ video::IImage* TextureSource::generateImage(const std::string &name)
return baseimg;
}
-#ifdef __ANDROID__
-#include <GLES/gl.h>
+#if ENABLE_GLES
/**
* Check and align image to npot2 if required by hardware
* @param image image to check for npot2 alignment
@@ -998,7 +1002,7 @@ video::IImage* TextureSource::generateImage(const std::string &name)
* @return image or copy of image aligned to npot2
*/
-inline u16 get_GL_major_version()
+static inline u16 get_GL_major_version()
{
const GLubyte *gl_version = glGetString(GL_VERSION);
return (u16) (gl_version[0] - '0');
@@ -1078,7 +1082,7 @@ bool TextureSource::generateImagePart(std::string part_of_name,
// Stuff starting with [ are special commands
if (part_of_name.empty() || part_of_name[0] != '[') {
video::IImage *image = m_sourcecache.getOrLoad(part_of_name);
-#ifdef __ANDROID__
+#if ENABLE_GLES
image = Align2Npot2(image, driver);
#endif
if (image == NULL) {
diff --git a/src/client/tile.h b/src/client/tile.h
index d0c45b4a4..3021e119d 100644
--- a/src/client/tile.h
+++ b/src/client/tile.h
@@ -27,8 +27,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <SMaterial.h>
#include <memory>
#include "util/numeric.h"
+#include "config.h"
-#if __ANDROID__
+#if ENABLE_GLES
#include <IVideoDriver.h>
#endif
@@ -133,7 +134,7 @@ public:
IWritableTextureSource *createTextureSource();
-#ifdef __ANDROID__
+#if ENABLE_GLES
video::IImage * Align2Npot2(video::IImage * image, irr::video::IVideoDriver* driver);
#endif