Android Fixes
This commit is contained in:
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include <IAEngine/EngineLibraryInterface.hpp>
|
#include <IAEngine/EngineLibraryInterface.hpp>
|
||||||
|
|
||||||
|
#include <SDL3/SDL_iostream.h>
|
||||||
|
|
||||||
namespace ia::iae
|
namespace ia::iae
|
||||||
{
|
{
|
||||||
EXTERN SDL_Window *g_windowHandle;
|
EXTERN SDL_Window *g_windowHandle;
|
||||||
@ -36,10 +38,25 @@ namespace ia::iae
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector<UINT8> Engine::ReadBinaryAsset(IN CONST String &path)
|
||||||
|
{
|
||||||
|
SDL_IOStream* f = SDL_IOFromFile(path.c_str(), "rb");
|
||||||
|
if(!f)
|
||||||
|
THROW_FILE_OPEN_READ(path);
|
||||||
|
Vector<UINT8> result;
|
||||||
|
SDL_SeekIO(f, 0, SDL_IO_SEEK_END);
|
||||||
|
result.resize(SDL_TellIO(f));
|
||||||
|
SDL_SeekIO(f, 0, SDL_IO_SEEK_SET);
|
||||||
|
SDL_ReadIO(f, result.data(), result.size());
|
||||||
|
SDL_CloseIO(f);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Direction Engine::GetVectorPointingDirection(IN Vec2 v)
|
Direction Engine::GetVectorPointingDirection(IN Vec2 v)
|
||||||
{
|
{
|
||||||
STATIC CONSTEXPR Direction DIRECTION_MAP[] = {Direction::RIGHT, Direction::DOWN_RIGHT, Direction::DOWN, Direction::DOWN_LEFT,
|
STATIC CONSTEXPR Direction DIRECTION_MAP[] = {Direction::RIGHT, Direction::DOWN_RIGHT, Direction::DOWN,
|
||||||
Direction::LEFT, Direction::UP_LEFT, Direction::UP, Direction::UP_RIGHT};
|
Direction::DOWN_LEFT, Direction::LEFT, Direction::UP_LEFT,
|
||||||
|
Direction::UP, Direction::UP_RIGHT};
|
||||||
if ((abs(v.x) <= FLOAT32_EPSILON) && (abs(v.y) <= FLOAT32_EPSILON))
|
if ((abs(v.x) <= FLOAT32_EPSILON) && (abs(v.y) <= FLOAT32_EPSILON))
|
||||||
return Direction::NONE;
|
return Direction::NONE;
|
||||||
|
|
||||||
|
|||||||
@ -47,10 +47,12 @@ namespace ia::iae
|
|||||||
|
|
||||||
IAE_LOG_INFO("Booting IAEngine for ", g_gameName);
|
IAE_LOG_INFO("Booting IAEngine for ", g_gameName);
|
||||||
|
|
||||||
|
SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeRight");
|
||||||
|
|
||||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_GAMEPAD))
|
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_GAMEPAD))
|
||||||
THROW_UNKNOWN("Failed to intialize SDL: ", SDL_GetError());
|
THROW_UNKNOWN("Failed to intialize SDL: ", SDL_GetError());
|
||||||
|
|
||||||
if (!(g_windowHandle = SDL_CreateWindow(g_gameName.c_str(), config.ScreenWidth, config.ScreenHeight,
|
if (!(g_windowHandle = SDL_CreateWindow(g_gameName.c_str(), config->ScreenWidth, config->ScreenHeight,
|
||||||
SDL_WINDOW_RESIZABLE)))
|
SDL_WINDOW_RESIZABLE)))
|
||||||
THROW_UNKNOWN("Failed to create the SDL window: ", SDL_GetError());
|
THROW_UNKNOWN("Failed to create the SDL window: ", SDL_GetError());
|
||||||
|
|
||||||
|
|||||||
@ -119,6 +119,7 @@ namespace ia::iae
|
|||||||
|
|
||||||
// Utility Functions
|
// Utility Functions
|
||||||
STATIC Direction GetVectorPointingDirection(IN Vec2 v);
|
STATIC Direction GetVectorPointingDirection(IN Vec2 v);
|
||||||
|
STATIC Vector<UINT8> ReadBinaryAsset(IN CONST String& path);
|
||||||
|
|
||||||
// Random Functions
|
// Random Functions
|
||||||
STATIC FLOAT32 GetRandomFloat();
|
STATIC FLOAT32 GetRandomFloat();
|
||||||
|
|||||||
@ -27,7 +27,7 @@ struct GameRequestedConfig
|
|||||||
INT32 ScreenHeight{};
|
INT32 ScreenHeight{};
|
||||||
};
|
};
|
||||||
|
|
||||||
C_DECL(GameRequestedConfig Game_GetConfigRequest());
|
C_DECL(GameRequestedConfig* Game_GetConfigRequest());
|
||||||
C_DECL(VOID Game_OnInitialize());
|
C_DECL(VOID Game_OnInitialize());
|
||||||
C_DECL(VOID Game_OnTerminate());
|
C_DECL(VOID Game_OnTerminate());
|
||||||
C_DECL(VOID Game_OnDebugDraw());
|
C_DECL(VOID Game_OnDebugDraw());
|
||||||
@ -41,7 +41,7 @@ namespace ia::iae
|
|||||||
} // namespace ia::iae
|
} // namespace ia::iae
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
#define IAENGINE_RUN(name, packageName, developerName, publisherName, versionMajor, versionMinor, versionPatch) int SDL_main(int argc, char *argv[]) { return ia::iae::Run(name, packageName, developerName, publisherName, IA_MAKE_VERSION(versionMajor, versionMinor, versionPatch)); }
|
#define IAENGINE_RUN(name, packageName, developerName, publisherName, versionMajor, versionMinor, versionPatch) extern "C" int SDL_main(int argc, char *argv[]) { return ia::iae::Run(name, packageName, developerName, publisherName, IA_MAKE_VERSION(versionMajor, versionMinor, versionPatch)); }
|
||||||
#else
|
#else
|
||||||
#define IAENGINE_RUN(name, packageName, developerName, publisherName, versionMajor, versionMinor, versionPatch) int main(int argc, char *argv[]) { return ia::iae::Run(name, packageName, developerName, publisherName, IA_MAKE_VERSION(versionMajor, versionMinor, versionPatch)); }
|
#define IAENGINE_RUN(name, packageName, developerName, publisherName, versionMajor, versionMinor, versionPatch) int main(int argc, char *argv[]) { return ia::iae::Run(name, packageName, developerName, publisherName, IA_MAKE_VERSION(versionMajor, versionMinor, versionPatch)); }
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -39,7 +39,7 @@ namespace ia::iae
|
|||||||
{
|
{
|
||||||
for (auto &c : m_components)
|
for (auto &c : m_components)
|
||||||
{
|
{
|
||||||
_component_type *comp = dynamic_cast<_component_type *>(c.get());
|
_component_type *comp = dynamic_cast<_component_type *>(c);
|
||||||
if (comp)
|
if (comp)
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ namespace ia::iae
|
|||||||
Vector<_component_type *> result;
|
Vector<_component_type *> result;
|
||||||
for (auto &c : m_components)
|
for (auto &c : m_components)
|
||||||
{
|
{
|
||||||
_component_type *comp = dynamic_cast<_component_type *>(c.get());
|
_component_type *comp = dynamic_cast<_component_type *>(c);
|
||||||
if (comp)
|
if (comp)
|
||||||
result.pushBack(comp);
|
result.pushBack(comp);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user