代码拉取完成,页面将自动刷新
同步操作将从 2144/Gut 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "Mesh.h"
void VertexArray::Bind()
{
glBindVertexArray(VAO);
}
void VertexArrayNoIndice::DrawArrays() const
{
glBindVertexArray(this->VAO);
glDrawArrays(this->faceType, 0, vertexNum);
glBindVertexArray(0);
}
bool VertexArrayIndice::CreateFromDesc(const VertexArrayIndiceDesc& desc)
{
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glGenBuffers(1, &EBO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, desc.vertexStride * desc.vertexNum, desc.vertexheader, desc.usage);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, desc.indiceNum* desc.indiceStride, desc.indiceHeader, desc.usage);
for(int i=0;i<desc.numLayout;i++)
{
const auto& l = desc.layout[i];
glEnableVertexAttribArray(l.index);
if (l.type == GL_FLOAT) {
glVertexAttribPointer(l.index, l.size, l.type, l.normalized,
desc.vertexStride, (void*)l.offset);
}
else if (l.type == GL_INT) {
glVertexAttribIPointer(l.index, l.size, l.type, desc.vertexStride, (void*)l.offset);
}
}
glBindVertexArray(0);
this->numIndices = desc.indiceNum;
this->faceType = desc.face;
this->indiceStride = desc.indiceStride;
if (desc.indiceStride == 2)
{
this->indiceType = GL_UNSIGNED_SHORT;
}
else if (desc.indiceStride == 4)
{
this->indiceType = GL_UNSIGNED_INT;
}
else if (desc.indiceStride == 1)
{
this->indiceType = GL_UNSIGNED_BYTE;
}
else
{
return false;
}
glBindVertexArray(0);
return true;
}
void VertexArrayIndice::Draw() const
{
glBindVertexArray(VAO);
glDrawElements(this->faceType, this->numIndices, this->indiceType, (void*)(this->startIndex * this->indiceStride));
glBindVertexArray(0);
}
void VertexArrayIndice::DrawInstanced(unsigned int count) const
{
glBindVertexArray(VAO);
glDrawElementsInstanced(this->faceType, this->numIndices, this->indiceType, 0, count);
glBindVertexArray(0);
}
bool VertexArrayNoIndice::CreateFromDesc(const VertexArrayNoIndiceDesc& desc)
{
bool gr = true;
unsigned int VBO;
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, desc.vertexStride * desc.vertexNum, desc.vertexheader, desc.usage);
for (int i = 0; i < desc.numLayout; i++)
{
const auto& l = desc.layout[i];
glEnableVertexAttribArray(l.index);
if (l.type == GL_FLOAT) {
glVertexAttribPointer(l.index, l.size, l.type, l.normalized,
desc.vertexStride, (void*)l.offset);
}
else if (l.type == GL_INT) {
glVertexAttribIPointer(l.index, l.size, l.type, desc.vertexStride, (void*)l.offset);
}
}
glBindVertexArray(0);
this->vertexNum = desc.vertexNum;
return true;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。