Просмотр исходного кода

pointers to game functions removed, now device use function defined in Game.cpp

mikymod 12 лет назад
Родитель
Сommit
084b8a2f5f
1 измененных файлов с 25 добавлено и 24 удалено
  1. 25 24
      src/Device.cpp

+ 25 - 24
src/Device.cpp

@@ -50,13 +50,14 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "JSONParser.h"
 #include "DiskFile.h"
 #include "Memory.h"
+#include "Game.h"
 
 namespace crown
 {
 
-static void (*game_init)(void) = NULL;
-static void (*game_shutdown)(void) = NULL;
-static void (*game_frame)(float) = NULL;
+// static void (*game_init)(void) = NULL;
+// static void (*game_shutdown)(void) = NULL;
+// static void (*game_frame)(float) = NULL;
 
 //-----------------------------------------------------------------------------
 Device::Device() :
@@ -130,30 +131,30 @@ bool Device::init(int argc, char** argv)
 
 	Log::i("Initializing Game...");
 
-	// Try to locate the game library
-	if (!m_filesystem->exists(GAME_LIBRARY_NAME))
-	{
-		Log::e("Unable to find the game library in the root path.", GAME_LIBRARY_NAME);
-		return false;
-	}
+	// // Try to locate the game library
+	// if (!m_filesystem->exists(GAME_LIBRARY_NAME))
+	// {
+	// 	Log::e("Unable to find the game library in the root path.", GAME_LIBRARY_NAME);
+	// 	return false;
+	// }
 
-	// Try to load the game library and bind functions
-	const char* game_library_path = m_filesystem->os_path(GAME_LIBRARY_NAME);
+	// // Try to load the game library and bind functions
+	// const char* game_library_path = m_filesystem->os_path(GAME_LIBRARY_NAME);
 
-	m_game_library = os::open_library(game_library_path);
+	// m_game_library = os::open_library(game_library_path);
 
-	if (m_game_library == NULL)
-	{
-		Log::e("Unable to load the game.");
-		return false;
-	}
+	// if (m_game_library == NULL)
+	// {
+	// 	Log::e("Unable to load the game.");
+	// 	return false;
+	// }
 
-	*(void**)(&game_init) = os::lookup_symbol(m_game_library, "init");
-	*(void**)(&game_shutdown) = os::lookup_symbol(m_game_library, "shutdown_1");
-	*(void**)(&game_frame) = os::lookup_symbol(m_game_library, "frame");
+	// *(void**)(&game_init) = os::lookup_symbol(m_game_library, "init");
+	// *(void**)(&game_shutdown) = os::lookup_symbol(m_game_library, "shutdown_1");
+	// *(void**)(&game_frame) = os::lookup_symbol(m_game_library, "frame");
 
-	// Initialize the game
-	game_init();
+	// Initialize the game through init game function
+	crown::init();
 
 	m_is_init = true;
 
@@ -177,7 +178,7 @@ void Device::shutdown()
 	}
 
 	// Shutdowns the game
-	game_shutdown();
+	crown::shutdown();
 
 	// Unload the game library
 	if (m_game_library)
@@ -355,7 +356,7 @@ void Device::frame()
 	m_window->frame();
 	m_input_manager->frame();
 
-	game_frame(last_delta_time());
+	crown::frame(last_delta_time());
 
 	m_debug_renderer->draw_all();
 	m_renderer->frame();