Doxygen Samurai Engine 0.0.1
Doxygen Samurai Engine Documentation
Loading...
Searching...
No Matches
dllMain.cpp
Go to the documentation of this file.
1#include "dllMain.h"
2
3
4
6#include <containers.h>
7
8#include "windowGraphic/gui.h"
9
10//todo use a global static array that can be accessed from other cpps and the macro will create an instance of a struct
11//that will push that container
12#define SAMURAI_DECLARE_CONTAINER(x) info.push_back( samurai::ContainerInformation(sizeof(x), #x, x::containerInfo()) );
13
14CORE_API void getContainersInfo(std::vector<samurai::ContainerInformation> &info)
15{
16 info.clear();
18
19}
20
21#undef SAMURAI_DECLARE_CONTAINER
22
23//this should not allocate memory
24CORE_API bool constructContainer(Container **c, samurai::memory::MemoryArena *arena, const char *name)
25{
26 *c = getContainer(name, arena);
27 return *c != 0;
28
29}
30
32{
33 //no need to call delete.
34 (*c)->~Container();
35
36}
37
42
47
52
53//used to initialize libraries
54CORE_API void gameplayStart(samurai::Context &context)
55{
57
58
59#pragma region init stuff
60#if !SAMURAI_SDL
61 SAMURAI_ASSERT(gladLoadGL(), "Problem initializing glad from dll");
63 gl2d::init();
64#else
65 // TODO: SDL stuff here
67
68#endif
69
70#pragma endregion
71}
72
73
74//this won't be ever called in production so we can remove the code
75CORE_API void gameplayReload(samurai::Context &context)
76{
77
79 //samurai::initShortcutApi();
80
81#if !SAMURAI_SDL
82 SAMURAI_ASSERT(gladLoadGL(), "Problem initializing glad from dll");
84
85 gl2d::init();
86#else
88#endif
89
90
91}
92
93#if SAMURAI_WINDOWS
94#ifdef SAMURAI_DEVELOPMENT
95
96
97#include <Windows.h>
98//https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain
99BOOL WINAPI DllMain(
100 HINSTANCE hinstDLL, // handle to DLL module
101 DWORD fdwReason, // reason for calling function
102 LPVOID lpvReserved) // reserved
103{
104 // Perform actions based on the reason for calling.
105 switch (fdwReason)
106 {
107 case DLL_PROCESS_ATTACH:
108 // Initialize once for each new process.
109 // Return FALSE to fail DLL load.
110 break;
111
112 case DLL_THREAD_ATTACH:
113 // Do thread-specific initialization.
114 break;
115
116 case DLL_THREAD_DETACH:
117 // Do thread-specific cleanup.
118 break;
119
120 case DLL_PROCESS_DETACH:
121
122 if (lpvReserved != nullptr)
123 {
124 break; // do not do cleanup if process termination scenario
125 }
126
127 //if (old)
128 //{
129 // std::cout.rdbuf(old);
130 //}
131
132 // Perform any necessary cleanup.
133 break;
134 }
135 return TRUE; // Successful DLL_PROCESS_ATTACH.
136}
137
138
139#endif
140#endif
#define SAMURAI_ASSERT(expression, comment)
Definition assert.h:40
Container * getContainer(const char *name, samurai::memory::MemoryArena *memoryArena)
#define SAMURAI_ALL_CONTAINERS()
Definition containers.h:16
CORE_API void getContainersInfo(std::vector< samurai::ContainerInformation > &info)
Definition dllMain.cpp:14
CORE_API void gameplayStart(samurai::Context &context)
Definition dllMain.cpp:54
CORE_API void bindAllocator(samurai::memory::CustomAllocator *arena)
Definition dllMain.cpp:38
CORE_API void destructContainer(Container **c, samurai::memory::MemoryArena *arena)
Definition dllMain.cpp:31
CORE_API bool constructContainer(Container **c, samurai::memory::MemoryArena *arena, const char *name)
Definition dllMain.cpp:24
CORE_API void gameplayReload(samurai::Context &context)
Definition dllMain.cpp:75
CORE_API void resetAllocator()
Definition dllMain.cpp:43
CORE_API void dissableAllocators()
Definition dllMain.cpp:48
void setGlobalAllocator(samurai::memory::CustomAllocator *allocator)
void setGlobalAllocatorToStandard()
void setImguiContext(Context pikaContext)
Definition gui.cpp:88
void setImguiAllocator(samurai::memory::CustomAllocator &allocator)
Definition gui.cpp:21
virtual ~Container()
samurai::memory::CustomAllocator imguiAllocator
Definition Context.h:25