Remove OpenGLMesh (not needed, D3D12 has no Mesh)

This commit is contained in:
2026-03-16 19:15:18 +08:00
parent 801c563eb5
commit 4a0f6d65d1
3 changed files with 0 additions and 130 deletions

View File

@@ -1,84 +0,0 @@
#define GLFW_INCLUDE_NONE
#include "XCEngine/RHI/OpenGL/OpenGLMesh.h"
#include <glad/glad.h>
#include <GLFW/glfw3.h>
namespace XCEngine {
namespace RHI {
OpenGLMesh::OpenGLMesh() {
}
OpenGLMesh::~OpenGLMesh() {
Shutdown();
}
bool OpenGLMesh::Initialize(const void* vertices, size_t vertexCount, const void* indices, size_t indexCount) {
m_vertexBuffer.InitializeVertexBuffer(vertices, vertexCount * sizeof(MeshVertex));
m_indexBuffer.InitializeIndexBuffer(indices, indexCount * sizeof(unsigned int));
m_vertexArray.Initialize();
VertexAttribute attr0;
attr0.index = 0;
attr0.count = 3;
attr0.type = GL_FLOAT;
attr0.normalized = GL_FALSE;
attr0.stride = sizeof(MeshVertex);
attr0.offset = 0;
m_vertexArray.AddVertexBuffer(m_vertexBuffer.GetID(), attr0);
VertexAttribute attr1;
attr1.index = 1;
attr1.count = 3;
attr1.type = GL_FLOAT;
attr1.normalized = GL_FALSE;
attr1.stride = sizeof(MeshVertex);
attr1.offset = sizeof(float) * 3;
m_vertexArray.AddVertexBuffer(m_vertexBuffer.GetID(), attr1);
VertexAttribute attr2;
attr2.index = 2;
attr2.count = 2;
attr2.type = GL_FLOAT;
attr2.normalized = GL_FALSE;
attr2.stride = sizeof(MeshVertex);
attr2.offset = sizeof(float) * 6;
m_vertexArray.AddVertexBuffer(m_vertexBuffer.GetID(), attr2);
m_vertexArray.SetIndexBuffer(m_indexBuffer.GetID(), GL_UNSIGNED_INT);
return true;
}
void OpenGLMesh::Shutdown() {
m_vertexArray.Shutdown();
m_vertexBuffer.Shutdown();
m_indexBuffer.Shutdown();
}
void OpenGLMesh::Draw(unsigned int shaderProgram, const std::vector<MeshTexture>& textures) {
unsigned int diffuseNr = 1;
unsigned int specularNr = 1;
for (unsigned int i = 0; i < textures.size(); i++)
{
glActiveTexture(GL_TEXTURE0 + i);
std::string number;
std::string name = textures[i].type;
if (name == "texture_diffuse")
number = std::to_string(diffuseNr++);
else if (name == "texture_specular")
number = std::to_string(specularNr++);
glUniform1i(glGetUniformLocation(shaderProgram, ("material." + name + number).c_str()), i);
glBindTexture(GL_TEXTURE_2D, textures[i].id);
}
m_vertexArray.Bind();
glDrawElements(GL_TRIANGLES, m_vertexArray.GetIndexCount(), GL_UNSIGNED_INT, 0);
glActiveTexture(GL_TEXTURE0);
}
} // namespace RHI
} // namespace XCEngine