Browse Source

tested the engine

meemknight 2 years ago
parent
commit
9fd7bc4163

+ 19 - 18
Pika/CMakeLists.txt

@@ -100,23 +100,23 @@ target_link_libraries(pikaGameplay PRIVATE glad glfw gl2d gl3d glui glm stb_imag
 
 
 #pikaProduction ###########################################
-#add_executable(pikaProduction)
-#
-#target_compile_definitions(pikaProduction PUBLIC PIKA_PRODUCTION)
-#set_property(TARGET pikaProduction PROPERTY CXX_STANDARD 17)
-#
-#target_sources(pikaProduction PRIVATE 
-#	"${PIKA_SOURCES_CORE_CONFIG}" "${PIKA_SOURCES_CORE_EDITOR}" "${PIKA_SOURCES_PLUGGINS}"
-#	"${PIKA_SOURCES_CORE_RUNTIME}" "${PIKA_SOURCES_CORE_STD}" "${PIKA_SOURCES_GAMEPLAY}" "${PIKA_SOURCES_CORE_SHARED_RUNTIME}")
-#target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/coreConfig/")
-#target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/pikaEditor/")
-#target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/pikaRuntime/")
-#target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/pikaSTD/")
-#target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/gameplay/")
-#target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/sharedRuntime/")
-#target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/pluggins/")
-#
-#target_link_libraries(pikaProduction PRIVATE glad glfw gl2d gl3d glui glm stb_image stb_truetype imgui safeSave profilerLib)
+add_executable(pikaProduction)
+
+target_compile_definitions(pikaProduction PUBLIC PIKA_PRODUCTION)
+set_property(TARGET pikaProduction PROPERTY CXX_STANDARD 17)
+
+target_sources(pikaProduction PRIVATE 
+	"${PIKA_SOURCES_CORE_CONFIG}" "${PIKA_SOURCES_CORE_EDITOR}" "${PIKA_SOURCES_PLUGGINS}"
+	"${PIKA_SOURCES_CORE_RUNTIME}" "${PIKA_SOURCES_CORE_STD}" "${PIKA_SOURCES_GAMEPLAY}" "${PIKA_SOURCES_CORE_SHARED_RUNTIME}")
+target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/coreConfig/")
+target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/pikaEditor/")
+target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/pikaRuntime/")
+target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/pikaSTD/")
+target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/gameplay/")
+target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/sharedRuntime/")
+target_include_directories(pikaProduction PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/pluggins/")
+
+target_link_libraries(pikaProduction PRIVATE glad glfw gl2d gl3d glui glm stb_image stb_truetype imgui safeSave profilerLib)
 
 
 
@@ -126,7 +126,8 @@ target_link_libraries(pikaGameplay PRIVATE glad glfw gl2d gl3d glui glm stb_imag
 #set exe type to be windowed
 if(MSVC)
 	
-	 #set_target_properties(pikaProduction PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
+	#todo maybe try to bring back console in production in the future
+	 set_target_properties(pikaProduction PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
 	 set_target_properties(pikaCore PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
 
 endif()

+ 0 - 5
Pika/core/coreConfig/pikaConfig.h

@@ -45,11 +45,6 @@
 
 #define PIKA_REMOVE_PUSH_NOTIFICATION_IN_PRODUCTION 0
 
-//#define PIKA_ENABLE_CONSOLE_IN_PRODUCTION 1 //removed for now
-
-
-#define PIKA_CLEAR_SCREEN_BY_ENGINE_IN_PRODUCTION 0 //todo
-#define PIKA_CLEAR_DEPTH_BY_ENGINE_IN_PRODUCTION 0
 
 
 #define PIKA_REMOVE_IMGUI_IN_PRODUCTION 1

+ 8 - 7
Pika/core/pikaRuntime/containerManager/containerManager.cpp

@@ -86,7 +86,7 @@ bool pika::ContainerManager::setRecordingToContainer(pika::containerId_t contain
 			pika::logError);
 		return false;
 	}
-	//todo not reset imgui id on input recording
+	
 	if (!setSnapshotToContainer(containerId, recordingName, logManager, imguiIdManager))
 	{
 		return false;
@@ -234,7 +234,7 @@ pika::containerId_t pika::ContainerManager::createContainer
 	container.requestedContainerInfo.logManager = &logManager;
 #pragma endregion
 
-	pika::StaticString<256> cmdArgs = {}; //todo magic number
+	pika::StaticString<256> cmdArgs = {};
 	
 	if (cmd.size() > cmdArgs.MAX_SIZE)
 	{
@@ -284,9 +284,9 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 
 	if (loadedDll.shouldReloadDll())
 	{
-		reloadDll(loadedDll, window, logs); //todo return 0 on fail
+		reloadDll(loadedDll, window, logs);
 
-		//todo mark shouldCallReaload or just call reload
+		//todo mark that it failed so it doesn't repeat on a loop
 		
 	}
 
@@ -616,7 +616,7 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 
 }
 
-void pika::ContainerManager::reloadDll(pika::LoadedDll &loadedDll, pika::PikaWindow &window, pika::LogManager &logs)
+bool pika::ContainerManager::reloadDll(pika::LoadedDll &loadedDll, pika::PikaWindow &window, pika::LogManager &logs)
 {
 
 	std::this_thread::sleep_for(std::chrono::milliseconds(200)); // make sure that the compiler had enough time 
@@ -625,10 +625,10 @@ void pika::ContainerManager::reloadDll(pika::LoadedDll &loadedDll, pika::PikaWin
 
 	auto oldContainerInfo = loadedDll.containerInfo;
 
-	if (!loadedDll.tryToloadDllUntillPossible(loadedDll.id, logs, std::chrono::seconds(5)))
+	if (!loadedDll.tryToloadDllUntillPossible(loadedDll.id, logs, std::chrono::seconds(2)))
 	{
 		logs.log("Couldn't reloaded dll", pika::logWarning);
-		return;
+		return 0;
 	}
 	//todo pospone dll reloading and make this timer shorter
 
@@ -765,6 +765,7 @@ void pika::ContainerManager::reloadDll(pika::LoadedDll &loadedDll, pika::PikaWin
 
 	logs.log("Reloaded dll");
 
+	return 1;
 }
 
 //not verbose flag

+ 1 - 1
Pika/core/pikaRuntime/containerManager/containerManager.h

@@ -57,7 +57,7 @@ namespace pika
 			pika::pikaImgui::ImGuiIdsManager &imguiIdManager,
 			pika::ConsoleWindow *consoleWindow);
 
-		void reloadDll(pika::LoadedDll &loadedDll,
+		bool reloadDll(pika::LoadedDll &loadedDll,
 			pika::PikaWindow &window,
 			pika::LogManager &logs);
 

+ 7 - 7
Pika/core/pikaRuntime/pikaMain.cpp

@@ -214,13 +214,13 @@ int main()
 	#pragma region clear screen
 
 	#if PIKA_PRODUCTION
-		#if PIKA_CLEAR_SCREEN_BY_ENGINE_IN_PRODUCTION && PIKA_CLEAR_DEPTH_BY_ENGINE _IN_PRODUCTION
-			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-		#elif PIKA_CLEAR_SCREEN_BY_ENGINE_IN_PRODUCTION
-			glClear(GL_COLOR_BUFFER_BIT);
-		#elif PIKA_CLEAR_DEPTH_BY_ENGINE_IN_PRODUCTION
-			glClear(GL_DEPTH_BUFFER_BIT);
-		#endif
+		//#if PIKA_CLEAR_SCREEN_BY_ENGINE_IN_PRODUCTION && PIKA_CLEAR_DEPTH_BY_ENGINE _IN_PRODUCTION
+		//	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+		//#elif PIKA_CLEAR_SCREEN_BY_ENGINE_IN_PRODUCTION
+		//	glClear(GL_COLOR_BUFFER_BIT);
+		//#elif PIKA_CLEAR_DEPTH_BY_ENGINE_IN_PRODUCTION
+		//	glClear(GL_DEPTH_BUFFER_BIT);
+		//#endif
 
 	#else
 

+ 27 - 3
Pika/core/pikaSTD/engineLibraresSupport/engineGL2DSupport.cpp

@@ -14,10 +14,18 @@
 			t.createFromFileDataWithPixelPadding((unsigned char *)data, s, blockSize, pixelated, useMipMaps);
 
 		}
+		else
+		{
+			info.consoleWrite(std::string("error loading texture: ") + path);
+		}
 
 		delete[] data;
 	}
-	else { return {}; }
+	else 
+	{
+		info.consoleWrite(std::string("error loading texture: ") + path);
+		return {}; 
+	}
 
 	return t;
 }
@@ -33,10 +41,18 @@
 		{
 			t.createFromFileData((unsigned char *)data, s, pixelated, useMipMaps);
 		}
+		else
+		{
+			info.consoleWrite(std::string("error loading texture: ") + path);
+		}
 
 		delete[] data;
 	}
-	else { return {}; }
+	else
+	{
+		info.consoleWrite(std::string("error loading texture: ") + path);
+		return {}; 
+	}
 
 	return t;
 }
@@ -52,10 +68,18 @@
 		{
 			f.createFromTTF((unsigned char *)data, s);
 		}
+		else
+		{
+			info.consoleWrite(std::string("error loading font: ") + path);
+		}
 
 		delete[] data;
 	}
-	else { return f; }
+	else
+	{
+		info.consoleWrite(std::string("error loading font: ") + path);
+		return {};
+	}
 
 	return f;
 }

+ 5 - 0
Pika/core/sharedRuntime/baseContainer.h

@@ -132,6 +132,11 @@ struct RequestedContainerInfo
 		return true;
 	}
 
+	bool consoleWrite(std::string &s)
+	{
+		return consoleWrite(s.c_str());
+	}
+
 	bool writeEntireFile(const char *name, const std::string &content)
 	{
 		std::ofstream f(name);

+ 2 - 2
Pika/gameplay/containers.h

@@ -29,8 +29,8 @@ Container *getContainer(const char* name, pika::memory::MemoryArena *memoryArena
 #if PIKA_PRODUCTION == 1
 
 #define PIKA_ALL_CONTAINERS() \
-	//PIKA_DECLARE_CONTAINER(McDungeonsGameplay) \
-	//PIKA_DECLARE_CONTAINER(McDungeonsMenu) 
+	PIKA_DECLARE_CONTAINER(McDungeonsGameplay) \
+	PIKA_DECLARE_CONTAINER(McDungeonsMenu) 
 
 #else
 

+ 1 - 1
Pika/gameplay/containers/minecraftDungeons/mcDungeonsMenu.h

@@ -35,7 +35,7 @@ struct McDungeonsMenu : public Container
 
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument)
 	{
-		renderer.create();
+		renderer.create(requestedInfo.requestedFBO.fbo);
 		//pika::initShortcutApi(); //todo do this in dll load
 
 		font = pika::gl2d::loadFont(PIKA_RESOURCES_PATH "mcDungeons/CommodorePixeled.ttf", requestedInfo);

+ 1 - 1
Pika/gameplay/containers/minecraftDungeons/mcDungeonsgameplay.h

@@ -428,7 +428,7 @@ struct McDungeonsGameplay: public Container
 		playerPhysics.position = {14,26};
 		playerPhysics.lastPos = {14,26};
 
-		renderer2d.create();
+		renderer2d.create(requestedInfo.requestedFBO.fbo);
 		
 		diamondTexture = pika::gl2d::loadTexture(PIKA_RESOURCES_PATH "mcDungeons/diamond.png", requestedInfo, true, false);
 		hearthTexture = pika::gl2d::loadTexture(PIKA_RESOURCES_PATH "mcDungeons/hearth.png", requestedInfo, true, false);

+ 3 - 1
Pika/gameplay/dll/dllMain.cpp

@@ -1,3 +1,6 @@
+#define PIKA_DECLARE_CONTAINER(x) info.push_back( pika::ContainerInformation(sizeof(x), #x, x::containerInfo()) );
+
+
 #include "dllMain.h"
 
 #include <gl2d/gl2d.h>
@@ -15,7 +18,6 @@
 
 //todo use a global static array that can be accessed from other cpps and the macro will create an instance of a struct 
 //that will push that container
-#define PIKA_DECLARE_CONTAINER(x) info.push_back( pika::ContainerInformation(sizeof(x), #x, x::containerInfo()) );
 
 PIKA_API void getContainersInfo(std::vector<pika::ContainerInformation> &info)
 {

+ 5 - 3
Pika/resources/logs.txt

@@ -1,3 +1,5 @@
-#2023-06-21 15:36:18: Created container: Gameplay
-#2023-06-21 15:36:18: Loaded snapshot
-#2023-06-21 15:36:27: Destroyed continer: Gameplay #1
+#2023-06-21 16:40:42: Created container: McDungeonsMenu
+#2023-06-21 16:40:51: Terminated container because it returned 0: McDungeonsMenu #1
+#2023-06-21 16:40:51: Destroyed continer: McDungeonsMenu #1
+#2023-06-21 16:40:53: Created container: McDungeonsGameplay
+#2023-06-21 16:41:22: Destroyed continer: McDungeonsGameplay #2