mirror of
				https://github.com/edubart/otclient.git
				synced 2025-11-04 04:36:23 +01:00 
			
		
		
		
	Compiling for android but have some bugs
This commit is contained in:
		@@ -126,10 +126,10 @@ set(framework_SOURCES ${framework_SOURCES}
 | 
			
		||||
 | 
			
		||||
    # crash handler
 | 
			
		||||
    ${CMAKE_CURRENT_LIST_DIR}/platform/crashhandler.h
 | 
			
		||||
    #${CMAKE_CURRENT_LIST_DIR}/platform/unixcrashhandler.cpp
 | 
			
		||||
    ${CMAKE_CURRENT_LIST_DIR}/platform/unixcrashhandler.cpp
 | 
			
		||||
    ${CMAKE_CURRENT_LIST_DIR}/platform/win32crashhandler.cpp
 | 
			
		||||
    ${CMAKE_CURRENT_LIST_DIR}/platform/win32platform.cpp
 | 
			
		||||
    #${CMAKE_CURRENT_LIST_DIR}/platform/unixplatform.cpp
 | 
			
		||||
    ${CMAKE_CURRENT_LIST_DIR}/platform/unixplatform.cpp
 | 
			
		||||
    ${CMAKE_CURRENT_LIST_DIR}/platform/platform.cpp
 | 
			
		||||
    ${CMAKE_CURRENT_LIST_DIR}/platform/platform.h
 | 
			
		||||
)
 | 
			
		||||
@@ -140,7 +140,11 @@ set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp
 | 
			
		||||
# some build options
 | 
			
		||||
option(LUAJIT "Use lua jit" OFF)
 | 
			
		||||
if(NOT APPLE)
 | 
			
		||||
    option(CRASH_HANDLER "Generate crash reports" ON)
 | 
			
		||||
    if(ANDROID)
 | 
			
		||||
        set(CRASH_HANDLER OFF)
 | 
			
		||||
    else()
 | 
			
		||||
        option(CRASH_HANDLER "Generate crash reports" ON)
 | 
			
		||||
    endif()
 | 
			
		||||
    option(USE_STATIC_LIBS "Don't use shared libraries (dlls)" ON)
 | 
			
		||||
    option(USE_LIBCPP "Use the new libc++ library instead of stdc++" OFF)
 | 
			
		||||
    option(USE_LTO "Use link time optimizations" OFF)
 | 
			
		||||
@@ -206,12 +210,7 @@ if(WIN32)
 | 
			
		||||
endif()
 | 
			
		||||
set(Boost_USE_MULTITHREADED ON)
 | 
			
		||||
set(Boost_USE_STATIC_LIBS ${USE_STATIC_LIBS})
 | 
			
		||||
 | 
			
		||||
if(ANDROID)
 | 
			
		||||
    
 | 
			
		||||
else()
 | 
			
		||||
    find_package(Boost 1.48.0 COMPONENTS ${REQUIRED_BOOST_COMPONENTS} REQUIRED)
 | 
			
		||||
endif()
 | 
			
		||||
find_package(Boost 1.48.0 COMPONENTS ${REQUIRED_BOOST_COMPONENTS} REQUIRED)
 | 
			
		||||
 | 
			
		||||
#find lua
 | 
			
		||||
if(LUAJIT)
 | 
			
		||||
@@ -230,11 +229,10 @@ message(STATUS "LuaJIT: " ${LUAJIT})
 | 
			
		||||
find_package(PhysFS REQUIRED)
 | 
			
		||||
find_package(OpenSSL REQUIRED)
 | 
			
		||||
 | 
			
		||||
# android already has zlib
 | 
			
		||||
if(NOT ANDROID)
 | 
			
		||||
    find_package(ZLIB REQUIRED)
 | 
			
		||||
else()
 | 
			
		||||
    set(framework_LIBRARIES ${framework_LIBRARIES} android)
 | 
			
		||||
    set(framework_LIBRARIES ${framework_LIBRARIES} z android log)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
set(framework_LIBRARIES ${framework_LIBRARIES}
 | 
			
		||||
@@ -292,7 +290,11 @@ else()
 | 
			
		||||
    else()
 | 
			
		||||
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
 | 
			
		||||
        set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic -Wl,-rpath,./libs") # rdynamic is needed by backtrace.h used in crash handler
 | 
			
		||||
        set(SYSTEM_LIBRARIES dl rt)
 | 
			
		||||
        if(ANDROID)
 | 
			
		||||
            set(SYSTEM_LIBRARIES dl)
 | 
			
		||||
        else()
 | 
			
		||||
            set(SYSTEM_LIBRARIES dl rt)
 | 
			
		||||
        endif()
 | 
			
		||||
    endif()
 | 
			
		||||
endif()
 | 
			
		||||
set(framework_LIBRARIES ${framework_LIBRARIES} ${SYSTEM_LIBRARIES})
 | 
			
		||||
@@ -303,7 +305,7 @@ endif()
 | 
			
		||||
 | 
			
		||||
if(FRAMEWORK_GRAPHICS)
 | 
			
		||||
    set(OPENGLES "OFF" CACHE "Use OpenGL ES 1.0 or 2.0 (for mobiles devices)" STRING)
 | 
			
		||||
    if(OPENGLES STREQUAL "2.0" OR ANDROID_NATIVE_API_LEVEL VERSION_GREATER 7)
 | 
			
		||||
    if(OPENGLES STREQUAL "2.0" OR (ANDROID_NATIVE_API_LEVEL AND ANDROID_NATIVE_API_LEVEL VERSION_GREATER 7))
 | 
			
		||||
        if(NOT ANDROID)
 | 
			
		||||
            find_package(OpenGLES2 REQUIRED)
 | 
			
		||||
            find_package(EGL REQUIRED)
 | 
			
		||||
@@ -313,7 +315,7 @@ if(FRAMEWORK_GRAPHICS)
 | 
			
		||||
            set(framework_LIBRARIES ${framework_LIBRARIES} GLESv2)
 | 
			
		||||
        endif()
 | 
			
		||||
        set(framework_DEFINITIONS ${framework_DEFINITIONS} -DOPENGL_ES=2)
 | 
			
		||||
    ELSEif(OPENGLES STREQUAL "1.0" OR ANDROID_NATIVE_API_LEVEL VERSION_LESS 8)
 | 
			
		||||
    ELSEif(OPENGLES STREQUAL "1.0" OR (ANDROID_NATIVE_API_LEVEL AND ANDROID_NATIVE_API_LEVEL VERSION_LESS 8))
 | 
			
		||||
        if(NOT ANDROID)
 | 
			
		||||
            find_package(OpenGLES1 REQUIRED)
 | 
			
		||||
            find_package(EGL REQUIRED)
 | 
			
		||||
@@ -460,8 +462,8 @@ if(FRAMEWORK_GRAPHICS)
 | 
			
		||||
        ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.h
 | 
			
		||||
        ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp
 | 
			
		||||
        ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.h
 | 
			
		||||
        ${CMAKE_CURRENT_LIST_DIR}/platform/sdlplatform.cpp
 | 
			
		||||
        ${CMAKE_CURRENT_LIST_DIR}/platform/sdlplatform.h
 | 
			
		||||
        ${CMAKE_CURRENT_LIST_DIR}/platform/sdlwindow.cpp
 | 
			
		||||
        ${CMAKE_CURRENT_LIST_DIR}/platform/sdlwindow.h
 | 
			
		||||
 | 
			
		||||
        # window input
 | 
			
		||||
        ${CMAKE_CURRENT_LIST_DIR}/input/mouse.cpp
 | 
			
		||||
 
 | 
			
		||||
@@ -101,7 +101,7 @@ void Application::init(std::vector<std::string>& args)
 | 
			
		||||
    registerLuaFunctions();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Application::deinit()
 | 
			
		||||
void Application::unloadModules()
 | 
			
		||||
{
 | 
			
		||||
    g_lua.callGlobalField("g_app", "onTerminate");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,9 +34,9 @@ public:
 | 
			
		||||
    virtual ~Application() {}
 | 
			
		||||
 | 
			
		||||
    virtual void init(std::vector<std::string>& args);
 | 
			
		||||
    virtual void deinit();
 | 
			
		||||
    virtual void unloadModules();
 | 
			
		||||
    virtual void terminate();
 | 
			
		||||
    virtual void run() = 0;
 | 
			
		||||
    virtual void runAppMainLoop() = 0;
 | 
			
		||||
    virtual void poll();
 | 
			
		||||
    virtual void exit();
 | 
			
		||||
    virtual void close();
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@
 | 
			
		||||
 | 
			
		||||
ConsoleApplication g_app;
 | 
			
		||||
 | 
			
		||||
void ConsoleApplication::run()
 | 
			
		||||
void ConsoleApplication::runAppMainLoop()
 | 
			
		||||
{
 | 
			
		||||
    m_running = true;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@
 | 
			
		||||
class ConsoleApplication : public Application
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    void run();
 | 
			
		||||
    void runAppMainLoop();
 | 
			
		||||
 | 
			
		||||
    int getFps() { return m_frameCounter.getLastFps(); }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -66,12 +66,12 @@ void GraphicalApplication::init(std::vector<std::string>& args)
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GraphicalApplication::deinit()
 | 
			
		||||
void GraphicalApplication::unloadModules()
 | 
			
		||||
{
 | 
			
		||||
    // hide the window because there is no render anymore
 | 
			
		||||
    g_window.hide();
 | 
			
		||||
 | 
			
		||||
    Application::deinit();
 | 
			
		||||
    Application::unloadModules();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GraphicalApplication::terminate()
 | 
			
		||||
@@ -101,7 +101,7 @@ void GraphicalApplication::terminate()
 | 
			
		||||
    m_terminated = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GraphicalApplication::run()
 | 
			
		||||
void GraphicalApplication::runAppMainLoop()
 | 
			
		||||
{
 | 
			
		||||
    m_running = true;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -36,9 +36,9 @@ class GraphicalApplication : public Application
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    void init(std::vector<std::string>& args);
 | 
			
		||||
    void deinit();
 | 
			
		||||
    void unloadModules();
 | 
			
		||||
    void terminate();
 | 
			
		||||
    void run();
 | 
			
		||||
    void runAppMainLoop();
 | 
			
		||||
    void poll();
 | 
			
		||||
    void close();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,8 +26,8 @@
 | 
			
		||||
#include "win32window.h"
 | 
			
		||||
WIN32Window window;
 | 
			
		||||
#elif defined ANDROID
 | 
			
		||||
#include "sdlplatform.h"
 | 
			
		||||
SDLPlatform window;
 | 
			
		||||
#include "sdlwindow.h"
 | 
			
		||||
SDLWindow window;
 | 
			
		||||
#else
 | 
			
		||||
#include "x11window.h"
 | 
			
		||||
#include <framework/core/clock.h>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,75 +0,0 @@
 | 
			
		||||
#include "sdlplatform.h"
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::init() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::terminate() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::move(const Point& pos) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::resize(const Size& size) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::show() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::hide() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::maximize() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::poll() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::swapBuffers() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::showMouse() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::hideMouse() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SDLPlatform::internalLoadMouseCursor(const ImagePtr& image, const Point& hotSpot) {
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::setMouseCursor(int cursorId) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::restoreMouseCursor() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::setTitle(const std::string& title) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::setMinimumSize(const Size& minimumSize) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::setFullscreen(bool fullscreen) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::setVerticalSync(bool enable) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::setIcon(const std::string& iconFile) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLPlatform::setClipboardText(const std::string& text) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Size SDLPlatform::getDisplaySize() {
 | 
			
		||||
    Size TODO;
 | 
			
		||||
    return TODO;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::string SDLPlatform::getClipboardText() {
 | 
			
		||||
    return nullptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::string SDLPlatform::getPlatformType() {
 | 
			
		||||
    return nullptr;
 | 
			
		||||
}
 | 
			
		||||
@@ -1,39 +0,0 @@
 | 
			
		||||
#ifndef SDL_PLATFORM_H
 | 
			
		||||
#define SDL_PLATFORM_H
 | 
			
		||||
 | 
			
		||||
#include "platformwindow.h"
 | 
			
		||||
 | 
			
		||||
class SDLPlatform : public PlatformWindow
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    void init();
 | 
			
		||||
    void terminate();
 | 
			
		||||
 | 
			
		||||
    void move(const Point& pos);
 | 
			
		||||
    void resize(const Size& size);
 | 
			
		||||
    void show();
 | 
			
		||||
    void hide();
 | 
			
		||||
    void maximize();
 | 
			
		||||
    void poll();
 | 
			
		||||
    void swapBuffers();
 | 
			
		||||
    void showMouse();
 | 
			
		||||
    void hideMouse();
 | 
			
		||||
 | 
			
		||||
    void setMouseCursor(int cursorId);
 | 
			
		||||
    void restoreMouseCursor();
 | 
			
		||||
 | 
			
		||||
    void setTitle(const std::string& title);
 | 
			
		||||
    void setMinimumSize(const Size& minimumSize);
 | 
			
		||||
    void setFullscreen(bool fullscreen);
 | 
			
		||||
    void setVerticalSync(bool enable);
 | 
			
		||||
    void setIcon(const std::string& iconFile);
 | 
			
		||||
    void setClipboardText(const std::string& text);
 | 
			
		||||
 | 
			
		||||
    Size getDisplaySize();
 | 
			
		||||
    std::string getClipboardText();
 | 
			
		||||
    std::string getPlatformType();
 | 
			
		||||
protected:
 | 
			
		||||
    int internalLoadMouseCursor(const ImagePtr& image, const Point& hotSpot);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@@ -1,5 +1,12 @@
 | 
			
		||||
#include "sdlwindow.h"
 | 
			
		||||
 | 
			
		||||
SDLWindow::SDLWindow() {
 | 
			
		||||
    m_window = 0;
 | 
			
		||||
    m_cursor = 0;
 | 
			
		||||
    m_minimumSize = Size(600,480);
 | 
			
		||||
    m_size = Size(600,480);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SDLWindow::init() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -83,7 +90,7 @@ Size SDLWindow::getDisplaySize() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::string SDLWindow::getClipboardText() {
 | 
			
		||||
    return nullptr;
 | 
			
		||||
    return "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::string SDLWindow::getPlatformType() {
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#if !defined(WIN32) && defined(CRASH_HANDLER)
 | 
			
		||||
#if !defined(WIN32) && !defined(ANDROID) && defined(CRASH_HANDLER)
 | 
			
		||||
 | 
			
		||||
#include "crashhandler.h"
 | 
			
		||||
#include <framework/global.h>
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,12 @@
 | 
			
		||||
#include <framework/stdext/stdext.h>
 | 
			
		||||
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
 | 
			
		||||
#ifdef ANDROID
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#else
 | 
			
		||||
#include <execinfo.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void Platform::processArgs(std::vector<std::string>& args)
 | 
			
		||||
{
 | 
			
		||||
@@ -169,6 +174,7 @@ std::string Platform::getOSName()
 | 
			
		||||
    return std::string();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef ANDROID
 | 
			
		||||
std::string Platform::traceback(const std::string& where, int level, int maxDepth)
 | 
			
		||||
{
 | 
			
		||||
    std::stringstream ss;
 | 
			
		||||
@@ -199,5 +205,8 @@ std::string Platform::traceback(const std::string& where, int level, int maxDept
 | 
			
		||||
 | 
			
		||||
    return ss.str();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
std::string Platform::traceback(const std::string& where, int level, int maxDepth){ return "TODO"; }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user