瀏覽代碼

made immage viewer work

vlod 3 年之前
父節點
當前提交
209831c149

+ 7 - 0
Pika/CMakeLists.txt

@@ -45,6 +45,13 @@ add_compile_definitions(PIKA_RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resourc
 
 if(MSVC)
 add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
+
+#https://stackoverflow.com/questions/5559357/debugheapdelete-access-violation-at-termination
+#add_compile_definitions(_STATIC_CPPLIB)
+#add_compile_definitions(_DISABLE_DEPRECATE_STATIC_CPPLIB)
+
+
+
 endif()
 
 

+ 2 - 2
Pika/core/pikaRuntime/containerManager/containerManager.cpp

@@ -165,7 +165,7 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 void pika::ContainerManager::reloadDll(pika::LoadedDll &loadedDll, pika::PikaWindow &window, pika::LogManager &logs)
 {
 
-	std::this_thread::sleep_for(std::chrono::milliseconds(10)); // make sure that the compiler had enough time 
+	std::this_thread::sleep_for(std::chrono::milliseconds(200)); // make sure that the compiler had enough time 
 		//to get hold onto the dll 
 
 
@@ -190,7 +190,7 @@ void pika::ContainerManager::reloadDll(pika::LoadedDll &loadedDll, pika::PikaWin
 		logs.log("Couldn't reloaded dll", pika::logWarning);
 		return;
 	}
-
+	//todo pospone dll reloading
 
 	std::unordered_map<std::string, pika::ContainerInformation> containerNames;
 	for (auto &c : loadedDll.containerInfo)

+ 1 - 1
Pika/core/pikaRuntime/dllLoader/dllLoader.cpp

@@ -214,7 +214,7 @@ void pika::LoadedDll::unloadDll()
 {
 	if (dllHand == 0) { return; }
 
-	dissableAllocators_();
+	//dissableAllocators_();
 
 	FreeLibrary(dllHand);
 	dllHand = {};

+ 1 - 0
Pika/core/pikaRuntime/pikaMain.cpp

@@ -209,6 +209,7 @@ int main()
 
 	containerManager.destroyAllContainers(loadedDll, logs);
 
+
 	//terminate();
 
 	return 0;

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

@@ -6,14 +6,45 @@
 #include <pikaAllocator/freeListAllocator.h>
 #include <staticVector.h>
 
+#define READENTIREFILE(x) bool x(const char* name, void* buffer, size_t size)
+typedef READENTIREFILE(readEntireFile_t);
+#undef READENTIREFILE
+
+#define GETFILESIZE(x) bool x(const char* name, size_t &size)
+typedef GETFILESIZE(getFileSize_t);
+#undef GETFILESIZE
+
 //this is passed by the engine. You should not modify the data
+//this is also used by the engine to give you acces to some io functions
 struct RequestedContainerInfo
 {
 	pika::memory::FreeListAllocator *mainAllocator = {};
 
 
+	//readEntireFile_t *readEntireFilePointer = {};
+	//getFileSize_t *getFileSizePointer = {};
+
+	bool readEntireFile(const char *name, void *buffer, size_t size)
+	{
+		//PIKA_DEVELOPMENT_ONLY_ASSERT(readEntireFilePointer, "read entire file pointer not assigned");
+
+		//bool rez = readEntireFilePointer(name, buffer, size);
+
+		//pika::memory::setGlobalAllocator(mainAllocator);
+
+		//return rez;
+	}
+
+	bool getFileSize(const char *name, size_t &size)
+	{
+		//PIKA_DEVELOPMENT_ONLY_ASSERT(getFileSizePointer, "get file size pointer not assigned");
+
+
+
+	}
 };
 
+
 struct ContainerStaticInfo
 {
 	static constexpr size_t MaxAllocatorsCount = 128;

+ 3 - 0
Pika/core/sharedRuntime/globalAllocator/globalAllocator.cpp

@@ -1,6 +1,9 @@
 #include "globalAllocator.h"
 #include <malloc.h>
 #include <pikaAllocator/freeListAllocator.h>
+#include <fstream>
+
+
 
 
 void *DefaultAllocator(size_t size)

+ 1 - 1
Pika/gameplay/containers/pikaGameplay.h

@@ -70,7 +70,7 @@ struct Gameplay : public Container
 
 		*r += deltaTime * 4.f;
 
-		renderer.renderRectangle({10, 10, 100, 100}, Colors_Turqoise, {}, *r);
+		renderer.renderRectangle({10, 10, 100, 100}, Colors_Green, {}, *r);
 
 		//if (input.lMouse.pressed())
 		//{

+ 12 - 3
Pika/pluggins/pluggins/immageViewer.h

@@ -7,7 +7,8 @@
 #include <shortcutApi/shortcutApi.h>
 #include <pikaSizes.h>
 #include <imgui_spinner.h>
-
+#include <fstream>
+#include <globalAllocator/globalAllocator.h>
 
 struct ImmageViewer: public Container
 {
@@ -26,7 +27,15 @@ struct ImmageViewer: public Container
 
 	void create(RequestedContainerInfo &requestedInfo)
 	{
-		texture.loadFromFile(PIKA_RESOURCES_PATH "map.png", true, true);
+		
+
+
+		pika::memory::setGlobalAllocatorToStandard();
+		{
+			texture.loadFromFile(PIKA_RESOURCES_PATH "map.png", true, true);
+		}
+		pika::memory::setGlobalAllocator(requestedInfo.mainAllocator);
+
 		//texture.cleanup();
 		//GLuint b = 0;
 		//glGenBuffers(1, &b);
@@ -46,7 +55,7 @@ struct ImmageViewer: public Container
 			return;
 		}
 
-		float xsize = 200.f;
+		float xsize = 400.f;
 		float aspect = 1.f;
 
 		ImGui::Image((void *)texture.id, {xsize,xsize / aspect},

+ 5 - 6
Pika/resources/logs.txt

@@ -1,6 +1,5 @@
-#2022-09-30 22:32:24: Created container: ImmageViewer
-#2022-09-30 22:32:31: Reloaded dll
-#2022-09-30 22:32:34: Reloaded dll
-#2022-09-30 22:32:36: Reloaded dll
-#2022-09-30 22:32:39: Reloaded dll
-#2022-09-30 22:32:39: Destroyed continer: ImmageViewer #1
+#2022-10-02 17:01:06: Created container: ImmageViewer
+#2022-10-02 17:01:08: Reloaded dll
+#2022-10-02 17:01:17: Reloaded dll
+#2022-10-02 17:01:23: Reloaded dll
+#2022-10-02 17:02:15: Destroyed continer: ImmageViewer #1