Browse Source

fixed gl3d bug

meemknight 2 years ago
parent
commit
9dadc557c7

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

@@ -139,6 +139,8 @@ int main()
 
 	PIKA_PERMA_ASSERT(gladLoadGL(), "Problem initializing glad");
 
+	//logs.log((const char*)glGetString(GL_VERSION));
+
 
 	pika::pikaImgui::initImgui(window.context);
 

+ 8 - 1
Pika/core/sharedRuntime/windowSystemm/window.cpp

@@ -35,7 +35,13 @@ void pika::PikaWindow::create()
 	}
 	
 	//todo debug from engine
-	glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, true);
+	//glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, true);
+
+	//glfwWindowHint(GLFW_SAMPLES, 1);
+
+	//glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
+	//glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
+	//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
 
 	context.wind = glfwCreateWindow(wr.z, wr.w, "Pika", NULL, NULL);
 	glfwSetWindowPos(context.wind, wr.x, wr.y);
@@ -52,6 +58,7 @@ void pika::PikaWindow::create()
 	glfwSetCharCallback(context.wind, characterCallback);
 	glfwSetKeyCallback(context.wind, keyCallback);
 
+
 	//todo macro
 	context.imguiAllocator.init(malloc(pika::MB(20)), pika::MB(20));
 

BIN
Pika/engineResources/engineSaves/windowPos1.bin


BIN
Pika/engineResources/engineSaves/windowPos2.bin


+ 16 - 1
Pika/gameplay/containers/threedtest.h

@@ -83,7 +83,7 @@ struct ThreeDTest: public Container
 		info.defaultHeapMemorySize = pika::MB(20);
 
 		info.requestImguiFbo = true;
-
+		info.requestImguiIds = 1;
 
 		return info;
 	}
@@ -138,6 +138,7 @@ struct ThreeDTest: public Container
 	void update(pika::Input input, pika::WindowState windowState,
 		RequestedContainerInfo &requestedInfo)
 	{
+		
 
 		renderer.setErrorCallback(&errorCallbackCustom, &requestedInfo);
 		renderer.fileOpener.userData = &requestedInfo;
@@ -178,6 +179,20 @@ struct ThreeDTest: public Container
 
 
 		glDisable(GL_DEPTH_TEST);
+
+
+		//if (!ImGui::Begin("Test window"))
+		//{
+		//	ImGui::End();
+		//	return;
+		//}
+		//
+		//auto t = renderer.getEntityMeshMaterialTextures(helmetEntity, 0);
+		//
+		//ImGui::Image((void*)renderer.getTextureOpenglId(t.albedoTexture), {200, 200});
+		//
+		//ImGui::End();
+
 	}
 
 };

+ 5 - 4
Pika/resources/logs.txt

@@ -1,4 +1,5 @@
-#2023-01-23 16:28:03: Created container: Gameplay
-#2023-01-23 16:28:17: Created container: ThreeDTest
-#2023-01-23 16:28:21: Destroyed continer: Gameplay #1
-#2023-01-23 16:28:21: Destroyed continer: ThreeDTest #2
+#2023-01-23 21:44:36: Created container: Gameplay
+#2023-01-23 21:44:52: Reloaded dll
+#2023-01-23 21:45:12: Created container: ThreeDTest
+#2023-01-23 21:45:26: Destroyed continer: Gameplay #1
+#2023-01-23 21:45:26: Destroyed continer: ThreeDTest #2

+ 85 - 15
Pika/thirdparty/gl3d/gl3d.cpp

@@ -31289,24 +31289,103 @@ void gl3d::ErrorReporter::callErrorCallback(std::string s)
 	}
 }
 
+
 void gl3d::defaultErrorCallback(std::string err, void *userData)
 {
-	//std::cout << err << "\n";
+#if GL3D_REMOVE_IOSTREAM == 0
+	std::cout << err << "\n";
+#endif
 }
 
 std::string gl3d::defaultReadEntireFile(const char* fileName, bool &couldNotOpen, void *userData)
 {
+#if GL3D_REMOVE_FSTREAM == 0
+
+	std::ifstream file;
+	file.open(fileName);
+
+	if (!file.is_open())
+	{
+		couldNotOpen = true;
+		return "";
+}
+
+	couldNotOpen = false;
+
+	size_t size = 0;
+	file.seekg(0, file.end);
+	size = file.tellg();
+	file.seekg(0, file.beg);
+
+	std::string ret;
+	ret.reserve(size + 1);
+
+	ret.assign((std::istreambuf_iterator<char>(file)),
+		std::istreambuf_iterator<char>());
+
+	file.close();
+
+	return ret;
+
+#else
+
 	return "";
+
+#endif
 }
 
 std::vector<char> gl3d::defaultReadEntireFileBinary(const char *fileName, bool &couldNotOpen, void *userData)
 {
+#if GL3D_REMOVE_FSTREAM == 0
+	std::ifstream file;
+	file.open(fileName, std::ios::binary);
+
+	if (!file.is_open())
+	{
+		couldNotOpen = true;
+		return {};
+	}
+
+	couldNotOpen = false;
+
+	size_t size = 0;
+	file.seekg(0, file.end);
+	size = file.tellg();
+	file.seekg(0, file.beg);
+
+	std::vector<char> ret;
+	ret.reserve(size + 1);
+
+	ret.assign((std::istreambuf_iterator<char>(file)),
+		std::istreambuf_iterator<char>());
+
+	file.close();
+
+	return ret;
+#else
 	return {};
+#endif
 }
 
 bool gl3d::defaultFileExists(const char *fileName, void *userData)
 {
-	return 0;
+
+#if GL3D_REMOVE_FSTREAM == 0
+	std::ifstream file;
+	file.open(fileName);
+
+	if (!file.is_open())
+	{
+		return false;
+	}
+	else
+	{
+		return true;
+	}
+#else
+	return false;
+#endif
+	
 }
 
 #pragma endregion
@@ -31974,7 +32053,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"skyBox.vert", "#version 330\n"
-"#pragma debug(on)\n"
 "layout (location = 0) in vec3 aPos;\n"
 "out vec3 v_texCoords;\n"
 "uniform mat4 u_viewProjection;\n"
@@ -32114,7 +32192,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"hdrToCubeMap.vert", "#version 330\n"
-"#pragma debug(on)\n"
 "layout (location = 0) in vec3 aPos;\n"
 "out vec3 v_localPos;\n"
 "uniform mat4 u_viewProjection;\n"
@@ -32296,7 +32373,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"pointShadow.vert", "#version 430\n"
-"#pragma debug(on)\n"
 "layout(location = 0) in vec3 a_positions;\n"
 "layout(location = 1) in vec3 a_normals; \n"
 "layout(location = 2) in vec2 a_texCoord;\n"
@@ -32828,7 +32904,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"zPrePass.vert", "#version 430\n"
-"#pragma debug(on)\n"
 "layout(location = 0) in vec3 a_positions;\n"
 "layout(location = 2) in vec2 a_texCoord;\n"
 "layout(location = 3) in ivec4 a_jointsId;\n"
@@ -32876,7 +32951,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"lightingPass.frag", "#version 430 core\n"
-"#pragma debug(on)\n"
 "#extension GL_ARB_bindless_texture: require\n"
 "layout(location = 0) out vec4 a_outColor;\n"
 "layout(location = 1) out vec4 a_outBloom;\n"
@@ -33584,7 +33658,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"geometryPass.vert", "#version 430\n"
-"#pragma debug(on)\n"
 "layout(location = 0) in vec3 a_positions;\n"
 "layout(location = 1) in vec3 a_normals;\n"
 "layout(location = 2) in vec2 a_texCoord;\n"
@@ -33632,7 +33705,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"geometryPass.frag", "#version 430\n"
-"#pragma debug(on)\n"
 "#extension GL_ARB_bindless_texture: require\n"
 "layout(location = 0) out vec3 a_pos;\n"
 "layout(location = 1) out ivec3 a_normal;\n"
@@ -33902,7 +33974,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"stencil.vert", "#version 330\n"
-"#pragma debug(on)\n"
 "in layout(location = 0) vec3 a_positions;\n"
 "in layout(location = 1) vec3 a_normals;\n"
 "uniform mat4 u_transform;\n"
@@ -33920,7 +33991,6 @@ namespace gl3d
       std::pair<std::string, const char*>{"stencil.frag", "#pragma once\n"},
 
       std::pair<std::string, const char*>{"showNormals.vert", "#version 330\n"
-"#pragma debug(on)\n"
 "in layout(location = 0) vec3 a_positions;\n"
 "in layout(location = 1) vec3 a_normals;\n"
 "uniform mat4 u_modelTransform; \n"
@@ -33965,7 +34035,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"normals.vert", "#version 330\n"
-"#pragma debug(on)\n"
 "in layout(location = 0) vec3 a_positions;\n"
 "in layout(location = 1) vec3 a_normals;\n"
 "in layout(location = 2) vec2 a_texCoord;\n"
@@ -33984,7 +34053,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"normals.frag", "#version 430\n"
-"#pragma debug(on)\n"
 "#extension GL_NV_shadow_samplers_cube : enable\n"
 "out layout(location = 0) vec4 a_outColor;\n"
 "in vec3 v_normals;\n"
@@ -34216,7 +34284,6 @@ namespace gl3d
 "}\n"},
 
       std::pair<std::string, const char*>{"color.vert", "#version 330\n"
-"#pragma debug(on)\n"
 "in layout(location = 0) vec3 positions;\n"
 "in layout(location = 1) vec3 colors;\n"
 "uniform mat4 u_transform;\n"
@@ -35790,6 +35857,7 @@ namespace gl3d
 	void SkyBoxLoaderAndDrawer::createConvolutedAndPrefilteredTextureData(SkyBox &skyBox
 		, GLuint frameBuffer, float sampleQuality, unsigned int specularSamples)
 	{
+
 		glBindTexture(GL_TEXTURE_CUBE_MAP, skyBox.texture);
 		glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
 		glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
@@ -38980,7 +39048,9 @@ namespace gl3d
 
 	void Renderer3D::render(float deltaTime)
 	{
-	
+		glEnable(GL_DEPTH_TEST);
+		glDisable(GL_BLEND);
+
 		if (internal.w <= 0 || internal.h <= 0)
 		{
 			return;

+ 15 - 0
Pika/thirdparty/gl3d/gl3d.h

@@ -17,6 +17,20 @@
 #include <stb_image/stb_image.h>
 
 
+#define GL3D_REMOVE_IOSTREAM 1 //you can remove this if neded to. It is just used for the default errorcallback
+#define GL3D_REMOVE_FSTREAM 1 //you can remove this if neded to. It is used for the default file callback, supply your own function for file oppening so the library still works :))
+
+
+#if GL3D_REMOVE_IOSTREAM == 0
+#include <iostream> 
+#endif
+
+#if GL3D_REMOVE_FSTREAM == 0
+#include <fstream> 
+#endif
+
+
+
 #include <glm/vec4.hpp>
 #include <glm/vec3.hpp>
 #include <glm/mat4x4.hpp>
@@ -34461,6 +34475,7 @@ namespace gl3d
 #include <algorithm>
 
 
+//todo get mesh material?
 
 namespace gl3d
 {