mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-09-23 09:02:27 +00:00
Revert "Initial Android Support"
This commit is contained in:
@@ -73,13 +73,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#ifdef __android__
|
||||
#include <android/log.h>
|
||||
|
||||
#define TAG "4JCRAFT"
|
||||
#define AndroidPrintf(...) do { __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__); printf( __VA_ARGS__); } while( 0 );
|
||||
#endif
|
||||
|
||||
#include "platform/sdl2/Input.h"
|
||||
#include "app/common/src/Audio/SoundEngine.h"
|
||||
#include "app/common/src/Colours/ColourTable.h"
|
||||
@@ -256,12 +249,8 @@ void Game::DebugPrintf(const char* szFormat, ...) {
|
||||
va_start(ap, szFormat);
|
||||
vsnprintf(buf, sizeof(buf), szFormat, ap);
|
||||
va_end(ap);
|
||||
#if defined(__android__)
|
||||
AndroidPrintf("%s", buf);
|
||||
#else
|
||||
OutputDebugStringA(buf);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Game::DebugPrintf(int user, const char* szFormat, ...) {
|
||||
@@ -272,11 +261,7 @@ void Game::DebugPrintf(int user, const char* szFormat, ...) {
|
||||
va_start(ap, szFormat);
|
||||
vsnprintf(buf, sizeof(buf), szFormat, ap);
|
||||
va_end(ap);
|
||||
#if defined(__android__)
|
||||
AndroidPrintf("%s", buf);
|
||||
#else
|
||||
OutputDebugStringA(buf);
|
||||
#endif
|
||||
if (user == USER_UI) {
|
||||
ui.logDebugString(buf);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "app/common/src/UI/Controls/UIControl_MinecraftHorse.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "UIControl_MinecraftPlayer.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
|
||||
@@ -2,12 +2,8 @@
|
||||
|
||||
#include <string>
|
||||
#ifdef __linux__
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#undef GL_SMOOTH
|
||||
#undef GL_FLAT
|
||||
@@ -170,13 +166,7 @@ public:
|
||||
static const int GL_FLAT = 0x1D00;
|
||||
#undef glShadeModel
|
||||
#define GL_SHADEMODEL_IS_FUNCTION
|
||||
static void glShadeModel(int mode) {
|
||||
#ifdef GLES
|
||||
glShadeModel(mode);
|
||||
#else
|
||||
::glShadeModel(mode);
|
||||
#endif
|
||||
}
|
||||
static void glShadeModel(int mode) { ::glShadeModel(mode); }
|
||||
};
|
||||
#undef GL_ARRAY_BUFFER_ARB
|
||||
#undef GL_STREAM_DRAW_ARB
|
||||
|
||||
@@ -2,16 +2,6 @@
|
||||
|
||||
#include "gdraw.h"
|
||||
|
||||
// Do we really really need gdraw for the java ui?
|
||||
#ifndef _ENABLEIGGY
|
||||
void gdraw_GL_BeginCustomDraw_4J(IggyCustomDrawCallbackRegion* region, F32* matrix) {}
|
||||
void gdraw_GL_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion* region, F32* matrix) {}
|
||||
void gdraw_GL_EndCustomDraw(IggyCustomDrawCallbackRegion* region) {}
|
||||
void gdraw_GL_SetTileOrigin(S32 vx, S32 vy, unsigned int framebuffer) {}
|
||||
void gdraw_GL_WrappedTextureDestroy(GDrawTexture* handle) {}
|
||||
|
||||
#else
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdbool.h>
|
||||
@@ -848,4 +838,3 @@ void gdraw_GL_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion* region,
|
||||
F32* matrix) {
|
||||
gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, 0.0f, 0);
|
||||
}
|
||||
#endif
|
||||
@@ -11,14 +11,17 @@ extern C4JRender RenderManager;
|
||||
|
||||
#ifdef GLES
|
||||
extern "C" {
|
||||
void glTexGeni(GLenum, GLenum, GLint) {}
|
||||
}
|
||||
extern void glClearDepthf(float depth);
|
||||
void glClearDepth(double depth) { glClearDepthf((float)depth); }
|
||||
void glTexGeni(unsigned int, unsigned int, int) {}
|
||||
void glTexGenfv(unsigned int, unsigned int, const float*) {}
|
||||
void glTexCoordPointer(int, unsigned int, int) {}
|
||||
void glNormalPointer(unsigned int, int) {}
|
||||
void glTexCoordPointer(int, unsigned int, int, const void*) {}
|
||||
void glNormalPointer(unsigned int, int, const void*) {}
|
||||
void glColorPointer(int, unsigned int, int, const void*) {}
|
||||
void glVertexPointer(int, unsigned int, int) {}
|
||||
void glCallLists(int) {}
|
||||
void glVertexPointer(int, unsigned int, int, const void*) {}
|
||||
void glEndList(void) {}
|
||||
void glCallLists(int, unsigned int, const void*) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
inline int* getIntPtr(IntBuffer* buf) {
|
||||
@@ -107,32 +110,14 @@ void glTexGen_4J(int, int, FloatBuffer*) {}
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef GLES
|
||||
static PFNGLGENQUERIESPROC _glGenQueriesARB = nullptr;
|
||||
static PFNGLBEGINQUERYPROC _glBeginQueryARB = nullptr;
|
||||
static PFNGLENDQUERYPROC _glEndQueryARB = nullptr;
|
||||
static PFNGLGETQUERYOBJECTUIVPROC _glGetQueryObjectuivARB = nullptr;
|
||||
static bool _queriesInitialized = false;
|
||||
#else
|
||||
static PFNGLGENQUERIESARBPROC _glGenQueriesARB = nullptr;
|
||||
static PFNGLBEGINQUERYARBPROC _glBeginQueryARB = nullptr;
|
||||
static PFNGLENDQUERYARBPROC _glEndQueryARB = nullptr;
|
||||
static PFNGLGETQUERYOBJECTUIVARBPROC _glGetQueryObjectuivARB = nullptr;
|
||||
static bool _queriesInitialized = false;
|
||||
#endif
|
||||
|
||||
static void initQueryFuncs() {
|
||||
if (_queriesInitialized) return;
|
||||
#ifdef GLES
|
||||
_queriesInitialized = true;
|
||||
_glGenQueriesARB =
|
||||
(PFNGLGENQUERIESPROC)dlsym(RTLD_DEFAULT, "glGenQueries");
|
||||
_glBeginQueryARB =
|
||||
(PFNGLBEGINQUERYPROC)dlsym(RTLD_DEFAULT, "glBeginQuery");
|
||||
_glEndQueryARB = (PFNGLENDQUERYPROC)dlsym(RTLD_DEFAULT, "glEndQuery");
|
||||
_glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVPROC)dlsym(
|
||||
RTLD_DEFAULT, "glGetQueryObjectuiv");
|
||||
#else
|
||||
_queriesInitialized = true;
|
||||
_glGenQueriesARB =
|
||||
(PFNGLGENQUERIESARBPROC)dlsym(RTLD_DEFAULT, "glGenQueriesARB");
|
||||
@@ -141,7 +126,6 @@ static void initQueryFuncs() {
|
||||
_glEndQueryARB = (PFNGLENDQUERYARBPROC)dlsym(RTLD_DEFAULT, "glEndQueryARB");
|
||||
_glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)dlsym(
|
||||
RTLD_DEFAULT, "glGetQueryObjectuivARB");
|
||||
#endif
|
||||
}
|
||||
|
||||
void glGenQueriesARB_4J(IntBuffer* buf) {
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
// GDraw GL backend for Linux
|
||||
#include "platform/sdl2/Render.h"
|
||||
#include "Linux_UIController.h"
|
||||
|
||||
+1
-23
@@ -29,7 +29,7 @@ platform_sources = run_command(
|
||||
).stdout().strip().split('\n')
|
||||
|
||||
# linux-specific files
|
||||
if host_machine.system() == 'linux' or host_machine.system() == 'android'
|
||||
if host_machine.system() == 'linux'
|
||||
platform_sources += run_command(
|
||||
'sh',
|
||||
'-c', 'find "'
|
||||
@@ -69,27 +69,6 @@ endif
|
||||
|
||||
platform_services_src = files('../platform/PlatformServices.cpp')
|
||||
|
||||
if host_machine.system() == 'android'
|
||||
client_dependencies += declare_dependency(dependencies: cc.find_library('log', required: true))
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'android'
|
||||
client = shared_library(
|
||||
'MinecraftClient',
|
||||
client_sources + platform_sources + platform_services_src + localisation[1],
|
||||
include_directories: include_directories('include', '..'),
|
||||
dependencies: client_dependencies,
|
||||
cpp_args: global_cpp_args
|
||||
+ global_cpp_defs
|
||||
+ [
|
||||
'-DUNICODE',
|
||||
'-D_UNICODE',
|
||||
],
|
||||
c_args: global_cpp_defs + ['-DUNICODE', '-D_UNICODE'],
|
||||
install: true,
|
||||
install_dir: '',
|
||||
)
|
||||
else
|
||||
client = executable(
|
||||
'Minecraft.Client',
|
||||
client_sources + platform_sources + platform_services_src + localisation[1],
|
||||
@@ -105,7 +84,6 @@ client = executable(
|
||||
install: true,
|
||||
install_dir: '',
|
||||
)
|
||||
endif
|
||||
|
||||
custom_target(
|
||||
'copy_assets_to_client',
|
||||
|
||||
@@ -205,10 +205,7 @@ bool File::mkdirs() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Previous behavior could return false even if the directory did not exist
|
||||
// and was successfully created, at least this happens on Android
|
||||
fs::create_directories(path, error);
|
||||
return !error;
|
||||
return fs::create_directories(path, error);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "Camera.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <glm/glm.hpp>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
@@ -13,7 +9,6 @@
|
||||
|
||||
#include "MemoryTracker.h"
|
||||
#include "app/include/stubs.h"
|
||||
#include "platform/sdl2/Render.h"
|
||||
#include "java/FloatBuffer.h"
|
||||
#include "minecraft/world/entity/LivingEntity.h"
|
||||
#include "minecraft/world/entity/player/Player.h"
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "Lighting.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include "platform/sdl2/Render.h"
|
||||
#include "app/include/stubs.h"
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "GuiComponent.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "platform/sdl2/Render.h"
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "Minimap.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "AchievementPopup.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include "platform/sdl2/Render.h"
|
||||
#include "java/System.h"
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "AchievementScreen.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "BeaconScreen.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "CreativeInventoryScreen.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "RepairScreen.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "ChestModel.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include "minecraft/client/model/geom/ModelPart.h"
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "ModelPart.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <numbers>
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "FootstepParticle.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "HugeExplosionParticle.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include "platform/sdl2/Render.h"
|
||||
#include "app/common/App_enums.h"
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "ParticleEngine.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "TakeAnimationParticle.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "Chunk.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "ItemInHandRenderer.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "LevelRenderer.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "Tesselator.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "TileRenderer.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "Frustum.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <format>
|
||||
#include <string>
|
||||
@@ -18,19 +13,12 @@ class BufferedImage;
|
||||
class Texture {
|
||||
public:
|
||||
static const int WM_WRAP = GL_REPEAT;
|
||||
#ifdef GLES
|
||||
static const int WM_CLAMP = GL_CLAMP_TO_EDGE;
|
||||
#else
|
||||
static const int WM_CLAMP = GL_CLAMP;
|
||||
#endif
|
||||
static const int WM_MIRROR = 0; // GL_MIRRORED_REPEAT;
|
||||
|
||||
static const int TFMT_RGBA = GL_RGBA;
|
||||
#ifdef GLES
|
||||
static const int TFMT_BGRA = GL_BGRA_EXT;
|
||||
#else
|
||||
static const int TFMT_BGRA = GL_BGRA;
|
||||
#endif
|
||||
|
||||
static const int TFLT_NEAREST = GL_NEAREST;
|
||||
static const int TFLT_LINEAR = GL_LINEAR;
|
||||
static const int TFLT_LINEAR_MIP_NEAREST = 0; // GL_LINEAR_MIPMAP_NEAREST;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "AbstractTexturePack.h"
|
||||
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <wchar.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include <numbers> // for std::numbers
|
||||
|
||||
#include "platform/sdl2/Render.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
|
||||
@@ -64,16 +64,8 @@ lib_minecraft = static_library('minecraft',
|
||||
cpp_args : global_cpp_args + global_cpp_defs,
|
||||
)
|
||||
|
||||
_inc_dir = '../../' / inc_dir
|
||||
|
||||
zlib_dep = dependency('zlib')
|
||||
if host_machine.system() == 'android'
|
||||
crypto_dep = declare_dependency(
|
||||
dependencies: cc.find_library('crypto', dirs: lib_dir, required: true ),
|
||||
include_directories: _inc_dir)
|
||||
else
|
||||
crypto_dep = dependency('libcrypto') # for MD5 in Hasher.cpp on Linux
|
||||
endif
|
||||
crypto_dep = dependency('libcrypto') # for MD5 in Hasher.cpp on Linux
|
||||
|
||||
minecraft_dep = declare_dependency(
|
||||
link_with : lib_minecraft,
|
||||
|
||||
@@ -75,18 +75,13 @@ public:
|
||||
}
|
||||
|
||||
std::filesystem::path getBasePath() override {
|
||||
#if defined(__linux__) && !defined (__android__)
|
||||
#if defined(__linux__)
|
||||
char buf[4096];
|
||||
ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
|
||||
if (len > 0) {
|
||||
buf[len] = '\0';
|
||||
return std::filesystem::path(buf).parent_path();
|
||||
}
|
||||
#elif defined(__android__)
|
||||
// Because of the static init fiasco
|
||||
// I need to set the path before loading the library
|
||||
// I can only do this through ENV
|
||||
return std::filesystem::path( getenv("MC_PATH") );
|
||||
#endif
|
||||
return std::filesystem::current_path();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
platform_inc = include_directories('.')
|
||||
_inc_dir = '../../' / inc_dir
|
||||
_threads = dependency('threads')
|
||||
|
||||
lib_platform_core = static_library('platform_core',
|
||||
@@ -15,39 +14,16 @@ platform_dep = declare_dependency(
|
||||
)
|
||||
|
||||
# SDL2-based platform implementations (formerly 4J.* modules)
|
||||
if host_machine.system() == 'android'
|
||||
_sdl2 = declare_dependency(
|
||||
dependencies: cc.find_library('SDL2', dirs: lib_dir, required: true ),
|
||||
include_directories: _inc_dir)
|
||||
else
|
||||
_sdl2 = dependency('sdl2')
|
||||
endif
|
||||
_sdl2 = dependency('sdl2')
|
||||
_defs = []
|
||||
|
||||
if get_option('renderer') == 'gles'
|
||||
if host_machine.system() == 'android'
|
||||
_gl = cc.find_library('GLESv3', required: true )
|
||||
_egl = cc.find_library('EGL', required: true )
|
||||
else
|
||||
_gl = dependency('glesv2', required: true)
|
||||
endif
|
||||
_gl = dependency('glesv2', required: true)
|
||||
_defs += ['-DGLES']
|
||||
else
|
||||
_gl = dependency('gl', required: true)
|
||||
endif
|
||||
|
||||
deps = [
|
||||
_sdl2,
|
||||
_gl,
|
||||
_threads,
|
||||
glm_dep,
|
||||
stb_dep,
|
||||
]
|
||||
|
||||
if host_machine.system() == 'android'
|
||||
deps += _egl
|
||||
endif
|
||||
|
||||
sdl2_sources = files(
|
||||
'sdl2/Input.cpp',
|
||||
'sdl2/Profile.cpp',
|
||||
@@ -59,7 +35,7 @@ sdl2_sources = files(
|
||||
lib_platform_sdl2 = static_library('platform_sdl2',
|
||||
sdl2_sources,
|
||||
include_directories: [platform_inc, include_directories('sdl2')],
|
||||
dependencies: deps,
|
||||
dependencies: [_sdl2, _gl, _threads, glm_dep, stb_dep],
|
||||
cpp_args: _defs + global_cpp_args + global_cpp_defs,
|
||||
)
|
||||
|
||||
@@ -68,7 +44,7 @@ lib_platform_sdl2 = static_library('platform_sdl2',
|
||||
render_dep = declare_dependency(
|
||||
link_with: lib_platform_sdl2,
|
||||
include_directories: [platform_inc, include_directories('sdl2')],
|
||||
dependencies: deps,
|
||||
dependencies: [_sdl2, _gl, _threads, glm_dep],
|
||||
)
|
||||
input_dep = render_dep
|
||||
profile_dep = render_dep
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "Render.h"
|
||||
|
||||
#include "../PlatformTypes.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_error.h>
|
||||
#include <SDL2/SDL_events.h>
|
||||
#include <SDL2/SDL_stdinc.h>
|
||||
#include <SDL2/SDL_video.h>
|
||||
#include "SDL.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_video.h"
|
||||
#include "gl3_loader.h"
|
||||
|
||||
// undefine macros from header to avoid argument mismatch
|
||||
@@ -41,11 +41,6 @@
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#ifdef __android__
|
||||
#include <android/log.h>
|
||||
#include <EGL/egl.h>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
@@ -56,12 +51,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#ifdef __android__
|
||||
#define fprintf(file, ...) ((void)__android_log_print(ANDROID_LOG_INFO, "4JRENDER", __VA_ARGS__))
|
||||
#define printf(...) ((void)__android_log_print(ANDROID_LOG_INFO, "4JRENDER", __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
C4JRender RenderManager;
|
||||
|
||||
// MARK: Shaders
|
||||
@@ -92,11 +81,6 @@ static const char* FRAG_SRC =
|
||||
// MARK: OpenGL state
|
||||
|
||||
// Hello SDL and opengl 3.3
|
||||
#ifdef __android__
|
||||
static EGLDisplay s_eglDisplay = EGL_NO_DISPLAY;
|
||||
static EGLContext s_mainEglContext = EGL_NO_CONTEXT;
|
||||
static EGLSurface s_mainEglSurface = EGL_NO_SURFACE;
|
||||
#endif
|
||||
static SDL_Window* s_window = nullptr;
|
||||
static SDL_GLContext s_glContext = nullptr;
|
||||
static bool s_shouldClose = false;
|
||||
@@ -110,14 +94,8 @@ static pthread_key_t s_glCtxKey;
|
||||
static pthread_once_t s_glCtxKeyOnce = PTHREAD_ONCE_INIT;
|
||||
static void makeGLCtxKey() { pthread_key_create(&s_glCtxKey, nullptr); }
|
||||
static const int MAX_SHARED_CTXS = 6;
|
||||
|
||||
#ifdef __android__
|
||||
static EGLSurface s_sharedWins[MAX_SHARED_CTXS] = {};
|
||||
static EGLContext s_sharedCtxs[MAX_SHARED_CTXS] = {};
|
||||
#else
|
||||
static SDL_Window* s_sharedWins[MAX_SHARED_CTXS] = {};
|
||||
static SDL_GLContext s_sharedCtxs[MAX_SHARED_CTXS] = {};
|
||||
#endif
|
||||
static int s_sharedCtxCount = 0;
|
||||
static int s_nextSharedCtx = 0;
|
||||
static pthread_mutex_t s_sharedMtx = PTHREAD_MUTEX_INITIALIZER;
|
||||
@@ -669,9 +647,6 @@ void C4JRender::Initialise() {
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
#ifdef __android__
|
||||
SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight");
|
||||
#endif
|
||||
Uint32 wf = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
|
||||
if (s_fullscreen) wf |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
s_window = SDL_CreateWindow("Minecraft Console Edition",
|
||||
@@ -711,50 +686,16 @@ void C4JRender::Initialise() {
|
||||
s_mainThread = pthread_self();
|
||||
s_mainThreadSet = true;
|
||||
pthread_setspecific(s_glCtxKey, (void*)s_window);
|
||||
|
||||
#ifdef __android__
|
||||
s_eglDisplay = eglGetCurrentDisplay();
|
||||
|
||||
EGLint pb_atr[] = {
|
||||
EGL_WIDTH, 1,
|
||||
EGL_HEIGHT, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
EGLint cfg_id;
|
||||
if (!eglQueryContext(s_eglDisplay, (EGLContext)s_glContext, EGL_CONFIG_ID, &cfg_id))
|
||||
{
|
||||
printf("BRUH\n");
|
||||
}
|
||||
|
||||
EGLConfig cfg;
|
||||
EGLint cfgs;
|
||||
EGLint atrs[] = { EGL_CONFIG_ID, cfg_id, EGL_NONE };
|
||||
|
||||
eglChooseConfig(s_eglDisplay, atrs, &cfg, 1, &cfgs);
|
||||
#endif
|
||||
|
||||
SDL_GL_MakeCurrent(s_window, s_glContext);
|
||||
for (int i = 0; i < MAX_SHARED_CTXS; i++) {
|
||||
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
|
||||
#ifndef __android__
|
||||
SDL_Window* w = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED, 1, 1,
|
||||
SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL);
|
||||
if (!w) break;
|
||||
SDL_GLContext ctx = SDL_GL_CreateContext(w);
|
||||
#else
|
||||
EGLint ctx_atr[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE };
|
||||
EGLContext ctx = eglCreateContext(s_eglDisplay, cfg, (EGLContext)s_glContext, ctx_atr);
|
||||
EGLSurface w = eglCreatePbufferSurface(s_eglDisplay, cfg, pb_atr);
|
||||
if ( w == EGL_NO_SURFACE ) {
|
||||
printf("EGL_NO_SURFACE: %d\n", eglGetError() );
|
||||
}
|
||||
#endif
|
||||
if (!ctx) {
|
||||
#ifndef __android__
|
||||
SDL_DestroyWindow(w);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
s_sharedWins[s_sharedCtxCount] = w;
|
||||
@@ -781,18 +722,10 @@ void C4JRender::InitialiseContext() {
|
||||
}
|
||||
void* cp = pthread_getspecific(s_glCtxKey);
|
||||
if (cp) {
|
||||
#ifdef __android__
|
||||
EGLContext ctx = (EGLContext)cp;
|
||||
#else
|
||||
SDL_GLContext ctx = (SDL_GLContext)cp;
|
||||
#endif
|
||||
for (int i = 0; i < s_sharedCtxCount; i++)
|
||||
if (s_sharedCtxs[i] == ctx) {
|
||||
#ifdef __android__
|
||||
eglMakeCurrent(s_eglDisplay, s_sharedWins[i], s_sharedWins[i], ctx );
|
||||
#else
|
||||
SDL_GL_MakeCurrent(s_sharedWins[i], ctx);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
return;
|
||||
@@ -805,11 +738,7 @@ void C4JRender::InitialiseContext() {
|
||||
if (!shared) return;
|
||||
for (int i = 0; i < s_sharedCtxCount; i++)
|
||||
if (s_sharedCtxs[i] == shared)
|
||||
#ifdef __android__
|
||||
eglMakeCurrent(s_eglDisplay, s_sharedWins[i], s_sharedWins[i], shared );
|
||||
#else
|
||||
SDL_GL_MakeCurrent(s_sharedWins[i], shared);
|
||||
#endif
|
||||
pthread_setspecific(s_glCtxKey, (void*)shared);
|
||||
}
|
||||
|
||||
@@ -872,14 +801,8 @@ void C4JRender::Shutdown() {
|
||||
s_window = nullptr;
|
||||
}
|
||||
for (int i = 0; i < s_sharedCtxCount; i++) {
|
||||
#ifdef __android__
|
||||
eglMakeCurrent(s_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
if (s_sharedCtxs[i]) eglDestroySurface(s_eglDisplay, s_sharedWins[i]);
|
||||
if (s_sharedWins[i]) eglDestroyContext(s_eglDisplay, s_sharedCtxs[i]);
|
||||
#else
|
||||
if (s_sharedCtxs[i]) SDL_GL_DeleteContext(s_sharedCtxs[i]);
|
||||
if (s_sharedWins[i]) SDL_DestroyWindow(s_sharedWins[i]);
|
||||
#endif
|
||||
}
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,8 @@
|
||||
|
||||
#include "gl3_loader.h"
|
||||
// NOTE: gl3_loader.h must be included before these two
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
@@ -390,34 +386,6 @@ extern C4JRender RenderManager;
|
||||
#define GL_TRIANGLE_STRIP 0x0005
|
||||
#endif
|
||||
|
||||
// These constants do not exist on the GLES,
|
||||
// so for now it is just stub
|
||||
#ifdef GLES
|
||||
|
||||
#ifndef GL_COLOR_MATERIAL
|
||||
#define GL_COLOR_MATERIAL 0x0B57
|
||||
#endif
|
||||
#ifndef GL_RESCALE_NORMAL
|
||||
#define GL_RESCALE_NORMAL 0x803A
|
||||
#endif
|
||||
#ifndef GL_NORMALIZE
|
||||
#define GL_NORMALIZE 0x0BA1
|
||||
#endif
|
||||
#ifndef GL_POLYGON_OFFSET_LINE
|
||||
#define GL_POLYGON_OFFSET_LINE 0x2A02
|
||||
#endif
|
||||
#ifndef GL_AMBIENT_AND_DIFFUSE
|
||||
#define GL_AMBIENT_AND_DIFFUSE 0x1602
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
void glShadeModel(GLenum);
|
||||
void glColorMaterial(GLenum, GLenum);
|
||||
void glNormal3f(GLfloat, GLfloat, GLfloat);
|
||||
void glTexGeni(GLenum, GLenum, GLint);
|
||||
}
|
||||
#endif
|
||||
|
||||
// glCallList / display list macros
|
||||
#undef glNewList
|
||||
#define glNewList(_list, _mode) RenderManager.CBuffStart(_list)
|
||||
@@ -758,7 +726,3 @@ void glGetQueryObjectu_4J_Helper(unsigned int id, unsigned int pname,
|
||||
#define glLight(a, b, c) glLight_4J(a, b, c)
|
||||
#define glLightModel(a, b) glLightModel_4J(a, b)
|
||||
#define glTexGen(a, b, c) glTexGen_4J(a, b, c)
|
||||
|
||||
#ifdef GLES
|
||||
#define glClearDepth(a) glClearDepthf((float)a)
|
||||
#endif
|
||||
@@ -2,13 +2,9 @@
|
||||
#ifndef GL_GLEXT_PROTOTYPES
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#endif
|
||||
#ifdef GLES
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl3ext.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include <cstdio>
|
||||
#ifndef GL_ARRAY_BUFFER
|
||||
|
||||
Reference in New Issue
Block a user