|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
void TestPosition::OnEnter(GLFWwindow* window)
|
|
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, 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, 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 });
|
|
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
|
|
2, 3, 0
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // 创建 VAO
|
|
|
|
|
|
|
+ // 鍒涘缓 VAO
|
|
|
glGenVertexArrays(1, &m_VAO);
|
|
glGenVertexArrays(1, &m_VAO);
|
|
|
|
|
|
|
|
- // 绑定 VAO
|
|
|
|
|
|
|
+ // 缁戝畾 VAO
|
|
|
glBindVertexArray(m_VAO);
|
|
glBindVertexArray(m_VAO);
|
|
|
|
|
|
|
|
- // 创建 VBO IB
|
|
|
|
|
|
|
+ // 鍒涘缓 VBO IB
|
|
|
glGenBuffers(1, &m_VBO);
|
|
glGenBuffers(1, &m_VBO);
|
|
|
glGenBuffers(1, &m_IB);
|
|
glGenBuffers(1, &m_IB);
|
|
|
|
|
|
|
|
- // 绑定 VBO 和 数据
|
|
|
|
|
|
|
+ // 缁戝畾 VBO 鍜� 鏁版嵁
|
|
|
GL_CALL(glBindBuffer(GL_ARRAY_BUFFER, m_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));
|
|
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(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IB));
|
|
|
GL_CALL(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW));
|
|
GL_CALL(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW));
|
|
|
|
|
|
|
|
- // 设置 VAO 内存结构
|
|
|
|
|
|
|
+ // 璁剧疆 VAO 鍐呭瓨缁撴瀯
|
|
|
GL_CALL(glEnableVertexAttribArray(0));
|
|
GL_CALL(glEnableVertexAttribArray(0));
|
|
|
GL_CALL(glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex_v0), (void *)offsetof(Vertex_v0, position)));
|
|
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(glEnableVertexAttribArray(3));
|
|
|
GL_CALL(glVertexAttribPointer(3, 1, GL_INT, GL_FALSE, sizeof(Vertex_v0), (void*)offsetof(Vertex_v0, texIndex)));
|
|
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.NewInit("res/shader/TextPosition/Vertex.vert", "res/shader/TextPosition/Fragment.frag");
|
|
|
m_Shader.Init("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_Tex1.Init("res/textures/test2.png");
|
|
|
m_Tex2.Init("res/textures/test3.png");
|
|
m_Tex2.Init("res/textures/test3.png");
|
|
|
|
|
+
|
|
|
m_Tex1.Bind(0);
|
|
m_Tex1.Bind(0);
|
|
|
m_Tex2.Bind(1);
|
|
m_Tex2.Bind(1);
|
|
|
|
|
|
|
@@ -64,6 +65,7 @@ void TestPosition::OnExit(GLFWwindow* window)
|
|
|
|
|
|
|
|
void TestPosition::UpdateLogic(float delayTime)
|
|
void TestPosition::UpdateLogic(float delayTime)
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void TestPosition::ClearRender(GLFWwindow* window)
|
|
void TestPosition::ClearRender(GLFWwindow* window)
|