mirror of
https://github.com/celisej567/mcpe.git
synced 2026-01-04 14:09:47 +03:00
WIP Android SDL
This commit is contained in:
committed by
iProgramInCpp
parent
811bc7a6fa
commit
0559f66102
@@ -1,12 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
project(reminecraftpe-core)
|
||||
|
||||
if(NOT ANDROID)
|
||||
set(INCLUDES . .. ../thirdparty/zlib)
|
||||
else()
|
||||
set(INCLUDES . ..)
|
||||
endif()
|
||||
|
||||
# Build
|
||||
add_library(reminecraftpe-core STATIC
|
||||
common/Random.cpp
|
||||
@@ -275,21 +269,23 @@ add_library(reminecraftpe-core STATIC
|
||||
renderer/GL/GL.cpp
|
||||
)
|
||||
|
||||
target_include_directories(reminecraftpe-core PUBLIC ${INCLUDES})
|
||||
target_include_directories(reminecraftpe-core PUBLIC . .. ../thirdparty/zlib)
|
||||
|
||||
# RakNet
|
||||
add_subdirectory(../thirdparty/raknet raknet)
|
||||
target_link_libraries(reminecraftpe-core PUBLIC raknet)
|
||||
|
||||
# zlib - Android builds with its own version
|
||||
# Hack - If we're not building for Android, surely we're building with SDL
|
||||
# zlib
|
||||
add_subdirectory(../thirdparty/zlib zlib)
|
||||
target_link_libraries(reminecraftpe-core PUBLIC zlib)
|
||||
|
||||
# SDL
|
||||
if(USE_SDL)
|
||||
add_subdirectory(../thirdparty/zlib zlib)
|
||||
target_link_libraries(reminecraftpe-core PUBLIC zlib)
|
||||
|
||||
# SDL
|
||||
add_library(SDL INTERFACE)
|
||||
if(EMSCRIPTEN)
|
||||
if(ANDROID)
|
||||
add_subdirectory(../thirdparty/SDL-src SDL EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(SDL INTERFACE SDL2::SDL2)
|
||||
elseif(EMSCRIPTEN)
|
||||
set(SDL_FLAG -sUSE_SDL=2)
|
||||
target_compile_options(SDL INTERFACE "${SDL_FLAG}")
|
||||
target_link_options(SDL INTERFACE "${SDL_FLAG}")
|
||||
@@ -298,7 +294,7 @@ if(USE_SDL)
|
||||
target_link_libraries(SDL INTERFACE SDL2::SDL2)
|
||||
endif()
|
||||
target_link_libraries(reminecraftpe-core PUBLIC SDL)
|
||||
|
||||
|
||||
# OpenGL
|
||||
if(NOT EMSCRIPTEN)
|
||||
option(USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE)
|
||||
@@ -318,8 +314,6 @@ if(USE_SDL)
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(reminecraftpe-core PUBLIC OpenGL::OpenGL OpenGL::GLU)
|
||||
endif()
|
||||
elseif(ANDROID)
|
||||
# Add Android related stuff here.
|
||||
endif()
|
||||
|
||||
# Sound Data
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "client/app/Minecraft.hpp"
|
||||
#ifndef ORIGINAL_CODE
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#if defined(ANDROID) && !defined(USE_SDL)
|
||||
#define HANDLE_CHARS_SEPARATELY // faked though, see platforms/android/minecraftcpp/minecraftcpp.NativeActivity/main.cpp
|
||||
#endif
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ void Options::_initDefaultValues()
|
||||
KM(KM_FLY_DOWN, SDLVK_x);
|
||||
KM(KM_CHAT_CMD, SDLVK_SLASH);
|
||||
#endif
|
||||
#ifdef __ANDROID__
|
||||
#if defined(ANDROID) && !defined(USE_SDL)
|
||||
// -- Original xperia play controls
|
||||
//KM(KM_FORWARD, AKEYCODE_DPAD_UP);
|
||||
//KM(KM_LEFT, AKEYCODE_DPAD_LEFT);
|
||||
|
||||
@@ -13,7 +13,7 @@ bool Controller::isTouchedValues[2];
|
||||
float Controller::stickValuesX[2];
|
||||
float Controller::stickValuesY[2];
|
||||
|
||||
#ifndef __ANDROID__
|
||||
#if !defined(ANDROID) || defined(USE_SDL)
|
||||
const float Controller_unk_1[3] = { 0.0f, 0.64f, -0.64f };
|
||||
#endif
|
||||
|
||||
@@ -52,7 +52,7 @@ void Controller::feed(int stickNo, int touched, float x, float y)
|
||||
if (!isValidStick(stickNo))
|
||||
return;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#if defined(ANDROID) && !defined(USE_SDL)
|
||||
int index = stickNo - 1;
|
||||
#else
|
||||
int index = (x >= 0.0f) ? 1 : 0;
|
||||
@@ -61,7 +61,7 @@ void Controller::feed(int stickNo, int touched, float x, float y)
|
||||
// maybe the 2 'touch sticks' are actually internally 1 single surface??
|
||||
|
||||
isTouchedValues[index] = touched != 0;
|
||||
#ifdef __ANDROID__
|
||||
#if defined(ANDROID) && !defined(USE_SDL)
|
||||
stickValuesX[index] = x;
|
||||
#else
|
||||
stickValuesX[index] = linearTransform(x + Controller_unk_1[index + 1], 0.0f, 2.78f, true);
|
||||
|
||||
@@ -22,7 +22,7 @@ ControllerTurnInput::ControllerTurnInput()
|
||||
|
||||
TurnDelta ControllerTurnInput::getTurnDelta()
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
#if defined(ANDROID) && !defined(USE_SDL)
|
||||
return TurnDelta(Controller::getX(m_stickNo) * 50.f, Controller::getY(m_stickNo) * 60.f);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ void GameRenderer::setupFog(int i)
|
||||
|
||||
if (m_pMinecraft->m_pMobPersp->isUnderLiquid(Material::water))
|
||||
{
|
||||
#if defined(ORIGINAL_CODE) || defined(__ANDROID__)
|
||||
#if defined(ORIGINAL_CODE) || defined(ANDROID)
|
||||
glFogx(GL_FOG_MODE, GL_EXP);
|
||||
#else
|
||||
glFogi(GL_FOG_MODE, GL_EXP);
|
||||
@@ -336,7 +336,7 @@ void GameRenderer::setupFog(int i)
|
||||
}
|
||||
else if (m_pMinecraft->m_pMobPersp->isUnderLiquid(Material::lava))
|
||||
{
|
||||
#if defined(ORIGINAL_CODE) || defined(__ANDROID__)
|
||||
#if defined(ORIGINAL_CODE) || defined(ANDROID)
|
||||
glFogx(GL_FOG_MODE, GL_EXP);
|
||||
#else
|
||||
glFogi(GL_FOG_MODE, GL_EXP);
|
||||
@@ -346,7 +346,7 @@ void GameRenderer::setupFog(int i)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(ORIGINAL_CODE) || defined(__ANDROID__)
|
||||
#if defined(ORIGINAL_CODE) || defined(ANDROID)
|
||||
glFogx(GL_FOG_MODE, GL_LINEAR);
|
||||
#else
|
||||
glFogi(GL_FOG_MODE, GL_LINEAR);
|
||||
|
||||
@@ -2,12 +2,23 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
|
||||
enum eLogLevel
|
||||
{
|
||||
LOG_INFO = ANDROID_LOG_INFO,
|
||||
LOG_WARN = ANDROID_LOG_WARN,
|
||||
LOG_ERR = ANDROID_LOG_ERROR,
|
||||
};
|
||||
#else
|
||||
enum eLogLevel
|
||||
{
|
||||
LOG_INFO,
|
||||
LOG_WARN,
|
||||
LOG_ERR,
|
||||
};
|
||||
#endif
|
||||
|
||||
class Logger
|
||||
{
|
||||
@@ -26,39 +37,19 @@ public:
|
||||
virtual void printf(eLogLevel, const char* const fmt, ...);
|
||||
};
|
||||
|
||||
// TODO: For now
|
||||
#ifdef __ANDROID__
|
||||
#ifndef NDEBUG
|
||||
#define _DEBUG
|
||||
#endif
|
||||
#endif
|
||||
#if defined(_DEBUG) || !defined(NDEBUG)
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#define LOG(level, ...) Logger::singleton()->printf(level, __VA_ARGS__)
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
#undef LOG
|
||||
#define LOG_INFO ANDROID_LOG_INFO
|
||||
#define LOG_ERR ANDROID_LOG_ERROR
|
||||
#define LOG_WARN ANDROID_LOG_WARN
|
||||
|
||||
#include <android/log.h>
|
||||
#ifdef ANDROID
|
||||
// TODO: Add a LoggerAndroid
|
||||
#define LOG(level, ...) __android_log_print(level, "ReMinecraftPE", __VA_ARGS__)
|
||||
#define LOG_I(...) __android_log_print(ANDROID_LOG_INFO, "ReMinecraftPE", __VA_ARGS__)
|
||||
#define LOG_W(...) __android_log_print(ANDROID_LOG_WARN, "ReMinecraftPE", __VA_ARGS__)
|
||||
#define LOG_E(...) __android_log_print(ANDROID_LOG_ERROR, "ReMinecraftPE", __VA_ARGS__)
|
||||
|
||||
#define LOG(level, ...) __android_log_print(level, "ReMinecraftPE", __VA_ARGS__)
|
||||
#else
|
||||
#define LOG(level, ...) Logger::singleton()->printf(level, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define LOG_I(...) LOG(LOG_INFO, __VA_ARGS__)
|
||||
#define LOG_W(...) LOG(LOG_WARN, __VA_ARGS__)
|
||||
#define LOG_E(...) LOG(LOG_ERR, __VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define LOG(...) ((void)0)
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "StandardOut.hpp"
|
||||
#include "Util.hpp"
|
||||
|
||||
StandardOut* const StandardOut::singleton()
|
||||
{
|
||||
// This is automatically allocated when accessed for the first time,
|
||||
// and automatically deallocated when runtime concludes.
|
||||
static StandardOut standardOut = StandardOut();
|
||||
return &standardOut;
|
||||
}
|
||||
|
||||
void StandardOut::print(const char* const str)
|
||||
{
|
||||
std::cout << str << std::endl;
|
||||
#ifdef _WIN32
|
||||
OutputDebugStringA(str);
|
||||
OutputDebugStringA("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void StandardOut::print(std::string str)
|
||||
{
|
||||
print(str.c_str());
|
||||
}
|
||||
|
||||
void StandardOut::vprintf(const char* const fmt, va_list argPtr)
|
||||
{
|
||||
print(Util::vformat(fmt, argPtr));
|
||||
}
|
||||
|
||||
void StandardOut::printf(const char* const fmt, ...)
|
||||
{
|
||||
va_list argList;
|
||||
va_start(argList, fmt);
|
||||
|
||||
vprintf(fmt, argList);
|
||||
|
||||
va_end(argList);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class StandardOut
|
||||
{
|
||||
public:
|
||||
static StandardOut* const singleton();
|
||||
|
||||
void print(const char* const str);
|
||||
void print(std::string str);
|
||||
void vprintf(const char* const fmt, va_list argPtr);
|
||||
void printf(const char* const fmt, ...);
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#define LOG(...) StandardOut::singleton()->printf(__VA_ARGS__)
|
||||
|
||||
#ifdef PLATFORM_ANDROID
|
||||
#define LOG_I(...) __android_log_print(ANDROID_LOG_INFO, "MinecraftPE", __VA_ARGS__)
|
||||
#define LOG_W(...) __android_log_print(ANDROID_LOG_WARN, "MinecraftPE", __VA_ARGS__)
|
||||
#define LOG_E(...) __android_log_print(ANDROID_LOG_ERROR, "MinecraftPE", __VA_ARGS__)
|
||||
#else
|
||||
#define LOG_I(...) LOG("[Info]: " __VA_ARGS__)
|
||||
#define LOG_W(...) LOG("[WARN]: " __VA_ARGS__)
|
||||
#define LOG_E(...) LOG("[ERROR]: " __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define LOG(...)
|
||||
#define LOG_I(...)
|
||||
#define LOG_W(...)
|
||||
#define LOG_E(...)
|
||||
|
||||
#endif
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
int g_TimeSecondsOnInit = 0;
|
||||
|
||||
#if (!defined(USE_SDL) || defined(_WIN32)) && !defined(__ANDROID__)
|
||||
#if (!defined(USE_SDL) || defined(_WIN32)) && !defined(ANDROID)
|
||||
|
||||
DIR* opendir(const char* name)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user