Переглянути джерело

fix: 修改编码 修改执行顺序

nicetry12138 10 місяців тому
батько
коміт
4fb455051c

+ 2 - 1
图形学/OpenGL学习/src/OpenGLDemo/OpenGLDemo/src/main.cpp

@@ -118,9 +118,10 @@ int main()
         float deltaTime = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - prevTime).count() / 1000.0f;
         prevTime = std::move(currentTime);
 
-        TestApp.ClearRender(window);
         TestApp.InputProcess(window);
         TestApp.Update(window, deltaTime);
+
+        TestApp.ClearRender(window);
         TestApp.Render(window);
 
         glfwSwapBuffers(window);    // 交换缓冲区

+ 11 - 9
图形学/OpenGL学习/src/OpenGLDemo/OpenGLDemo/src/testModule/TestPosition.cpp

@@ -2,7 +2,7 @@
 
 void TestPosition::OnEnter(GLFWwindow* window)
 {
-	//					 坐标					颜色						UV 坐标			贴图序号
+	//					 鍧愭爣					棰滆壊						UV 鍧愭爣			璐村浘搴忓彿
 	m_vertexs.push_back({ 0.5f,  0.5f, 0.0f,	1.0f, 1.0f, 0.0f, 1.0f,		1.0f, 1.0f,		0 });
 	m_vertexs.push_back({ 0.5f, -0.5f, 0.0f,	1.0f, 1.0f, 0.0f, 1.0f,		1.0f, 0.0f,		0 });
 	m_vertexs.push_back({ -0.5f, -0.5f, 0.0f,	0.0f, 1.0f, 1.0f, 1.0f,		0.0f, 0.0f,		1 });
@@ -13,25 +13,25 @@ void TestPosition::OnEnter(GLFWwindow* window)
 		2, 3, 0
 	};
 
-	// 创建 VAO
+	// 鍒涘缓 VAO
 	glGenVertexArrays(1, &m_VAO);
 
-	// 绑定 VAO
+	// 缁戝畾 VAO
 	glBindVertexArray(m_VAO);
 
-	// 创建 VBO IB
+	// 鍒涘缓 VBO IB
 	glGenBuffers(1, &m_VBO);
 	glGenBuffers(1, &m_IB);
 
-	// 绑定 VBO 和 数据
+	// 缁戝畾 VBO 鍜� 鏁版嵁
 	GL_CALL(glBindBuffer(GL_ARRAY_BUFFER, m_VBO));
 	GL_CALL(glBufferData(GL_ARRAY_BUFFER, m_vertexs.size() * sizeof(Vertex_v0), m_vertexs.data(), GL_STATIC_DRAW));
 
-	// 绑定 IB 和 数据
+	// 缁戝畾 IB 鍜� 鏁版嵁
 	GL_CALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IB));
 	GL_CALL(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW));
 
-	// 设置 VAO 内存结构
+	// 璁剧疆 VAO 鍐呭瓨缁撴瀯
 	GL_CALL(glEnableVertexAttribArray(0));
 	GL_CALL(glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex_v0), (void *)offsetof(Vertex_v0, position)));
 
@@ -44,13 +44,14 @@ void TestPosition::OnEnter(GLFWwindow* window)
 	GL_CALL(glEnableVertexAttribArray(3));
 	GL_CALL(glVertexAttribPointer(3, 1, GL_INT, GL_FALSE, sizeof(Vertex_v0), (void*)offsetof(Vertex_v0, texIndex)));
 
-	// 初始化 shader
+	// 鍒濆�鍖� shader
 	//m_Shader.NewInit("res/shader/TextPosition/Vertex.vert", "res/shader/TextPosition/Fragment.frag");
 	m_Shader.Init("res/shader/TextPosition/Vertex.vert", "res/shader/TextPosition/Fragment.frag");
 
-	// 初始化 texture
+	// 鍒濆�鍖� texture
 	m_Tex1.Init("res/textures/test2.png");
 	m_Tex2.Init("res/textures/test3.png");
+
 	m_Tex1.Bind(0);
 	m_Tex2.Bind(1);
 
@@ -64,6 +65,7 @@ void TestPosition::OnExit(GLFWwindow* window)
 
 void TestPosition::UpdateLogic(float delayTime)
 {
+	
 }
 
 void TestPosition::ClearRender(GLFWwindow* window)

+ 3 - 3
图形学/OpenGL学习/src/OpenGLDemo/OpenGLDemo/src/testModule/TestPosition.h

@@ -17,9 +17,9 @@ public:
 	virtual void UpdateImGUI(GLFWwindow* window) override;
 
 private:
-	GLuint m_VBO;
-	GLuint m_VAO;
-	GLuint m_IB;
+	GLuint m_VBO{ GL_ZERO };
+	GLuint m_VAO{ GL_ZERO };
+	GLuint m_IB{ GL_ZERO };
 
 	Shader m_Shader;
 	Texture m_Tex1;