some improvements
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
build/
|
build/
|
||||||
linux-build/
|
linux-build/
|
||||||
|
.cache/
|
||||||
@@ -3,6 +3,10 @@ project(MinecraftPE)
|
|||||||
|
|
||||||
include(cmake/CPM.cmake)
|
include(cmake/CPM.cmake)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
|
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-invalid-source-encoding")
|
||||||
|
|
||||||
CPMAddPackage("gh:madler/zlib@1.3.2")
|
CPMAddPackage("gh:madler/zlib@1.3.2")
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME "libpng"
|
NAME "libpng"
|
||||||
@@ -116,15 +120,33 @@ file(GLOB SOURCES
|
|||||||
"src/NinecraftApp.cpp"
|
"src/NinecraftApp.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(NOT DEFINED PLATFORM)
|
||||||
|
set(PLATFORM "PLATFORM_GLFW")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if(PLATFORM STREQUAL "PLATFORM_WIN32")
|
||||||
|
list(APPEND SOURCES "src/AppPlatform_win32.cpp")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(PLATFORM STREQUAL "PLATFORM_GLFW")
|
||||||
|
list(APPEND SOURCES "src/AppPlatform_glfw.cpp")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}
|
add_executable(${PROJECT_NAME}
|
||||||
${SOURCES}
|
${SOURCES}
|
||||||
|
|
||||||
#TODO: if PLATFORM=PLATFORM_GLFW
|
|
||||||
"src/AppPlatform_glfw.cpp"
|
|
||||||
|
|
||||||
"glad/src/glad.c"
|
"glad/src/glad.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(EXTRA_LIBS "ws2_32")
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PUBLIC "_CRT_SECURE_NO_WARNINGS")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(PLATFORM STREQUAL "PLATFORM_WIN32" OR PLATFORM STREQUAL "PLATFORM_GLFW")
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLATFORM_DESKTOP")
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||||
"${CMAKE_SOURCE_DIR}/glad/include/"
|
"${CMAKE_SOURCE_DIR}/glad/include/"
|
||||||
"${CMAKE_SOURCE_DIR}/src"
|
"${CMAKE_SOURCE_DIR}/src"
|
||||||
@@ -133,14 +155,10 @@ target_include_directories(${PROJECT_NAME} PUBLIC
|
|||||||
"lib/include"
|
"lib/include"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" "_CRT_SECURE_NO_WARNINGS" "PLATFORM_GLFW")
|
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
|
||||||
|
target_link_libraries(${PROJECT_NAME} zlib png_shared alsoft.common OpenAL::OpenAL glfw ${EXTRA_LIBS})
|
||||||
|
|
||||||
# TODO: add ws2_32 lib if windows
|
if (NOT UNIX)
|
||||||
# TODO: fix openal linking for windows
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} zlib png_shared alsoft.common OpenAL glfw)
|
|
||||||
|
|
||||||
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${PROJECT_NAME}
|
TARGET ${PROJECT_NAME}
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#define NO_NETWORK
|
#define NO_NETWORK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(RPI)
|
#ifdef PLATFORM_DESKTOP
|
||||||
#define CREATORMODE
|
#define CREATORMODE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -574,7 +574,7 @@ void Minecraft::tick(int nTick, int maxTick) {
|
|||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
textures->loadAndBindTexture("terrain.png");
|
textures->loadAndBindTexture("terrain.png");
|
||||||
if (!pause && !(screen && !screen->renderGameBehind())) {
|
if (!pause && !(screen && !screen->renderGameBehind())) {
|
||||||
#if !defined(RPI)
|
#ifndef PLATFORM_DESKTOP
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
if (isSuperFast())
|
if (isSuperFast())
|
||||||
#endif
|
#endif
|
||||||
@@ -691,7 +691,7 @@ void Minecraft::tickInput() {
|
|||||||
if (isPressed) {
|
if (isPressed) {
|
||||||
gui.handleKeyPressed(key);
|
gui.handleKeyPressed(key);
|
||||||
|
|
||||||
#if defined(WIN32) || defined(RPI)//|| defined(_DEBUG) || defined(DEBUG)
|
#ifdef PLATFORM_DESKTOP //|| defined(_DEBUG) || defined(DEBUG)
|
||||||
if (key >= '0' && key <= '9') {
|
if (key >= '0' && key <= '9') {
|
||||||
int digit = key - '0';
|
int digit = key - '0';
|
||||||
int slot = digit - 1;
|
int slot = digit - 1;
|
||||||
@@ -714,16 +714,14 @@ void Minecraft::tickInput() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if defined(RPI)
|
|
||||||
if (key == Keyboard::KEY_E) {
|
if (key == Keyboard::KEY_E) {
|
||||||
screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||||
}
|
}
|
||||||
if (!screen && key == Keyboard::KEY_O || key == 250) {
|
if (!screen && key == Keyboard::KEY_O || key == 250) {
|
||||||
releaseMouse();
|
releaseMouse();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if defined(WIN32)
|
|
||||||
if (key == Keyboard::KEY_F) {
|
if (key == Keyboard::KEY_F) {
|
||||||
options.isFlying = !options.isFlying;
|
options.isFlying = !options.isFlying;
|
||||||
player->noPhysics = options.isFlying;
|
player->noPhysics = options.isFlying;
|
||||||
@@ -831,7 +829,7 @@ void Minecraft::tickInput() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(RPI) && !defined(PLATFORM_GLFW)
|
#ifndef PLATFORM_DESKTOP
|
||||||
if (key == 82)
|
if (key == 82)
|
||||||
pauseGame(false);
|
pauseGame(false);
|
||||||
#else
|
#else
|
||||||
@@ -848,7 +846,7 @@ void Minecraft::tickInput() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef PLATFORM_DESKTOP
|
||||||
if (key == Keyboard::KEY_M) {
|
if (key == Keyboard::KEY_M) {
|
||||||
for (int i = 0; i < 5 * SharedConstants::TicksPerSecond; ++i)
|
for (int i = 0; i < 5 * SharedConstants::TicksPerSecond; ++i)
|
||||||
level->tick();
|
level->tick();
|
||||||
@@ -892,7 +890,7 @@ void Minecraft::tickInput() {
|
|||||||
|| (buildHandled && bai.isRemove());
|
|| (buildHandled && bai.isRemove());
|
||||||
|
|
||||||
TIMER_POP_PUSH("handlemouse");
|
TIMER_POP_PUSH("handlemouse");
|
||||||
#if defined(RPI) || defined(PLATFORM_GLFW)
|
#ifdef PLATFORM_DESKTOP
|
||||||
handleMouseDown(MouseAction::ACTION_LEFT, isTryingToDestroyBlock);
|
handleMouseDown(MouseAction::ACTION_LEFT, isTryingToDestroyBlock);
|
||||||
handleMouseClick(buildHandled && bai.isInteract()
|
handleMouseClick(buildHandled && bai.isInteract()
|
||||||
|| options.useMouseForDigging && Mouse::isButtonDown(MouseAction::ACTION_RIGHT));
|
|| options.useMouseForDigging && Mouse::isButtonDown(MouseAction::ACTION_RIGHT));
|
||||||
@@ -1123,7 +1121,7 @@ void Minecraft::releaseMouse()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Minecraft::useTouchscreen() {
|
bool Minecraft::useTouchscreen() {
|
||||||
#if defined(RPI) || defined(PLATFORM_GLFW)
|
#ifdef PLATFORM_DESKTOP
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
return options.useTouchScreen || !_supportsNonTouchscreen;
|
return options.useTouchScreen || !_supportsNonTouchscreen;
|
||||||
@@ -1366,7 +1364,7 @@ void Minecraft::_levelGenerated()
|
|||||||
netCallback->levelGenerated(level);
|
netCallback->levelGenerated(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WIN32) || defined(RPI)
|
#ifdef PLATFORM_DESKTOP
|
||||||
if (_commandServer) {
|
if (_commandServer) {
|
||||||
delete _commandServer;
|
delete _commandServer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ void Options::initDefaultValues() {
|
|||||||
keyJump = KeyMapping("key.jump", Keyboard::KEY_SPACE);
|
keyJump = KeyMapping("key.jump", Keyboard::KEY_SPACE);
|
||||||
keyBuild = KeyMapping("key.inventory", Keyboard::KEY_E);
|
keyBuild = KeyMapping("key.inventory", Keyboard::KEY_E);
|
||||||
keySneak = KeyMapping("key.sneak", Keyboard::KEY_LSHIFT);
|
keySneak = KeyMapping("key.sneak", Keyboard::KEY_LSHIFT);
|
||||||
#if defined(RPI) || defined(PLATFORM_GLFW)
|
#ifdef PLATFORM_DESKTOP
|
||||||
keyCraft = KeyMapping("key.crafting", Keyboard::KEY_Q);
|
keyCraft = KeyMapping("key.crafting", Keyboard::KEY_Q);
|
||||||
keyDrop = KeyMapping("key.drop", Keyboard::KEY_Q);
|
keyDrop = KeyMapping("key.drop", Keyboard::KEY_Q);
|
||||||
keyChat = KeyMapping("key.chat", Keyboard::KEY_T);
|
keyChat = KeyMapping("key.chat", Keyboard::KEY_T);
|
||||||
|
|||||||
@@ -112,10 +112,10 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
|||||||
unsigned int max = 10;
|
unsigned int max = 10;
|
||||||
bool isChatting = false;
|
bool isChatting = false;
|
||||||
renderChatMessages(screenHeight, max, isChatting, font);
|
renderChatMessages(screenHeight, max, isChatting, font);
|
||||||
#if !defined(RPI)
|
#ifndef PLATFORM_DESKTOP
|
||||||
renderOnSelectItemNameText(screenWidth, font, ySlot);
|
renderOnSelectItemNameText(screenWidth, font, ySlot);
|
||||||
#endif
|
#endif
|
||||||
#if defined(RPI)
|
#ifdef PLATFORM_DESKTOP
|
||||||
renderDebugInfo();
|
renderDebugInfo();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ static char ILLEGAL_FILE_CHARACTERS[] = {
|
|||||||
void SelectWorldScreen::tick()
|
void SelectWorldScreen::tick()
|
||||||
{
|
{
|
||||||
if (_state == _STATE_CREATEWORLD) {
|
if (_state == _STATE_CREATEWORLD) {
|
||||||
#if defined(RPI)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
std::string levelId = getUniqueLevelName("world");
|
std::string levelId = getUniqueLevelName("world");
|
||||||
LevelSettings settings(getEpochTimeS(), GameType::Creative);
|
LevelSettings settings(getEpochTimeS(), GameType::Creative);
|
||||||
minecraft->selectLevel(levelId, levelId, settings);
|
minecraft->selectLevel(levelId, levelId, settings);
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ static char ILLEGAL_FILE_CHARACTERS[] = {
|
|||||||
void SelectWorldScreen::tick()
|
void SelectWorldScreen::tick()
|
||||||
{
|
{
|
||||||
if (_state == _STATE_CREATEWORLD) {
|
if (_state == _STATE_CREATEWORLD) {
|
||||||
#if defined(RPI)
|
#ifdef PLATFORM_DESKTOP
|
||||||
std::string levelId = getUniqueLevelName("perf");
|
std::string levelId = getUniqueLevelName("perf");
|
||||||
//int seed = Util::hashCode("/r/Minecraft");
|
//int seed = Util::hashCode("/r/Minecraft");
|
||||||
LevelSettings settings(getEpochTimeS(), GameType::Creative);
|
LevelSettings settings(getEpochTimeS(), GameType::Creative);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ void KeyboardInput::tick( Player* player )
|
|||||||
ya *= 0.3f;
|
ya *= 0.3f;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(RPI) || defined(PLATFORM_GLFW)
|
#ifdef PLATFORM_DESKTOP
|
||||||
wantUp = jumping;
|
wantUp = jumping;
|
||||||
wantDown = sneaking;
|
wantDown = sneaking;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
/*static*/ int Textures::textureChanges = 0;
|
/*static*/ int Textures::textureChanges = 0;
|
||||||
/*static*/ bool Textures::MIPMAP = false;
|
/*static*/ bool Textures::MIPMAP = false;
|
||||||
|
const TextureId Textures::InvalidId = -1;
|
||||||
|
|
||||||
Textures::Textures( Options* options_, AppPlatform* platform_ )
|
Textures::Textures( Options* options_, AppPlatform* platform_ )
|
||||||
: clamp(false),
|
: clamp(false),
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
static bool MIPMAP;
|
static bool MIPMAP;
|
||||||
static int textureChanges;
|
static int textureChanges;
|
||||||
static const TextureId InvalidId = -1;
|
static const TextureId InvalidId;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextureMap idMap;
|
TextureMap idMap;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "../Options.h"
|
#include "../Options.h"
|
||||||
|
|
||||||
// Android should always run OPENGL_ES
|
// Android should always run OPENGL_ES
|
||||||
#if defined(ANDROID) || defined(__APPLE__) || defined(RPI)
|
#if defined(ANDROID) || defined(__APPLE__) || defined(PLATFORM_DESKTOP)
|
||||||
#define OPENGL_ES
|
#define OPENGL_ES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user