fix: changed android defines

This commit is contained in:
2021-11-04 17:42:31 +01:00
parent a3712febca
commit 95e9c270db
9 changed files with 46 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#ifdef ANDROID #ifdef __ANDROID__
#include <GLES3/gl3.h> #include <GLES3/gl3.h>
#else #else
#include "glbinding/gl/gl.h" #include "glbinding/gl/gl.h"

View File

@@ -107,7 +107,7 @@ namespace ImGui
} }
*/ */
#ifdef ANDROID #ifdef __ANDROID__
#define IMGUI_IMPL_OPENGL_ES3 #define IMGUI_IMPL_OPENGL_ES3
#else #else
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2 #define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2

View File

@@ -21,7 +21,7 @@ int main(int argc, const char* args[]) {
return 0; return 0;
} }
#ifdef ANDROID #ifdef __ANDROID__
extern "C" { extern "C" {
int SDL_main(int argc, const char* args[]) { int SDL_main(int argc, const char* args[]) {
return main(argc, args); return main(argc, args);

View File

@@ -29,7 +29,7 @@ static std::unique_ptr<td::gui::GameMenu> gameMenu;
static std::unique_ptr<td::gui::FrameMenu> frameMenu; static std::unique_ptr<td::gui::FrameMenu> frameMenu;
void initWidgets(){ void initWidgets() {
mainMenu = std::make_unique<td::gui::MainMenu>(client.get()); mainMenu = std::make_unique<td::gui::MainMenu>(client.get());
gameMenu = std::make_unique<td::gui::GameMenu>(client.get()); gameMenu = std::make_unique<td::gui::GameMenu>(client.get());
frameMenu = std::make_unique<td::gui::FrameMenu>(client.get()); frameMenu = std::make_unique<td::gui::FrameMenu>(client.get());
@@ -73,9 +73,11 @@ void tick() {
lastTime = td::utils::getTime(); lastTime = td::utils::getTime();
} }
void render() { void render() {
tick(); tick();
beginFrame(); beginFrame();
client->render(); client->render();
if (client->isConnected()) if (client->isConnected())
gameMenu->render(); gameMenu->render();
@@ -85,6 +87,7 @@ void render() {
if (demo_open) if (demo_open)
ImGui::ShowDemoWindow(&demo_open); ImGui::ShowDemoWindow(&demo_open);
frameMenu->render(); frameMenu->render();
endFrame(); endFrame();
} }

View File

@@ -21,7 +21,7 @@
#include "Dirent/dirent.h" #include "Dirent/dirent.h"
#include <windows.h> #include <windows.h>
#else #else
#include "dirent.h" #include <dirent.h>
#endif // defined (WIN32) || defined (_WIN32) #endif // defined (WIN32) || defined (_WIN32)
namespace imgui_addons namespace imgui_addons
@@ -1156,6 +1156,23 @@ namespace imgui_addons
if(path_max_def) if(path_max_def)
buffer = new char[PATH_MAX]; buffer = new char[PATH_MAX];
#ifdef __ANDROID__
char* real_path = realpath("/storage/emulated/0/Download", buffer);
if (real_path == nullptr)
{
current_path = "/storage/emulated/0/Download";
current_dirlist.push_back("/storage/emulated/0/Download");
}
else
{
current_path = std::string(real_path);
current_path += "/";
parsePathTabs(current_path);
}
#else
char* real_path = realpath("./", buffer); char* real_path = realpath("./", buffer);
if (real_path == nullptr) if (real_path == nullptr)
{ {
@@ -1169,6 +1186,8 @@ namespace imgui_addons
parsePathTabs(current_path); parsePathTabs(current_path);
} }
#endif
if(path_max_def) if(path_max_def)
delete[] buffer; delete[] buffer;
else else

View File

@@ -7,7 +7,7 @@
#include "render/shaders/EntityShader.h" #include "render/shaders/EntityShader.h"
#ifdef ANDROID #ifdef __ANDROID__
static const char vertexSource[] = static const char vertexSource[] =
R"(#version 300 es R"(#version 300 es

View File

@@ -12,7 +12,7 @@
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
#ifdef ANDROID #ifdef __ANDROID__
#include <android/log.h> #include <android/log.h>
#endif #endif
@@ -116,7 +116,7 @@ int ShaderProgram::loadShader(const std::string& source, GLenum type) {
char error[size]; char error[size];
glGetShaderInfoLog(shaderID, size, &size, error); glGetShaderInfoLog(shaderID, size, &size, error);
std::cout << error << std::endl; std::cout << error << std::endl;
#ifdef ANDROID #ifdef __ANDROID__
__android_log_print(ANDROID_LOG_ERROR, "TRACKERS", "Could not compile shader !\n %s", error); __android_log_print(ANDROID_LOG_ERROR, "TRACKERS", "Could not compile shader !\n %s", error);
#endif #endif
} }

View File

@@ -7,7 +7,7 @@
#include "render/shaders/WorldShader.h" #include "render/shaders/WorldShader.h"
#ifdef ANDROID #ifdef __ANDROID__
static const char vertexSource[] = static const char vertexSource[] =
R"(#version 300 es R"(#version 300 es

View File

@@ -22,7 +22,7 @@
#include <SDL2/SDL_render.h> #include <SDL2/SDL_render.h>
#ifdef ANDROID #ifdef __ANDROID__
#include <sstream> #include <sstream>
#include <android/log.h> #include <android/log.h>
#endif #endif
@@ -49,7 +49,7 @@ void windowResizeEvent(int width, int height) {
bool create() { bool create() {
window = SDL_CreateWindow(WINDOW_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); window = SDL_CreateWindow(WINDOW_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
// Prepare and create context // Prepare and create context
#ifdef ANDROID #ifdef __ANDROID__
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
@@ -151,6 +151,19 @@ void pollEvents() {
} }
ImGui_ImplSDL2_ProcessEvent(&event); ImGui_ImplSDL2_ProcessEvent(&event);
} }
// activating screen keyboard for Android devices
#ifdef __ANDROID__
static bool keyboardShown = false;
if(ImGui::GetIO().WantTextInput != keyboardShown){
if(ImGui::GetIO().WantTextInput){
SDL_StartTextInput();
}else{
SDL_StopTextInput();
}
keyboardShown = ImGui::GetIO().WantTextInput;
}
#endif
} }
bool isCloseRequested() { bool isCloseRequested() {