load basic 3d model
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "render/loader/GLLoader.h"
|
||||
#include "render/GL.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace GL {
|
||||
|
||||
@@ -69,4 +70,37 @@ void VertexBuffer::BindVertexAttribs() const {
|
||||
glVertexAttribPointer(pointer.m_Index, static_cast<GLint>(pointer.m_Size), GL_FLOAT, false, m_DataStride * sizeof(float), reinterpret_cast<void*>(pointer.m_Offset));
|
||||
}
|
||||
}
|
||||
|
||||
Texture::Texture(const char* textureData, int width, int height, int comp) {
|
||||
glGenTextures(1, &m_ID);
|
||||
|
||||
Bind();
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
assert(comp == 3 || comp == 4);
|
||||
|
||||
if (comp == 3)
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
|
||||
GL_UNSIGNED_BYTE, textureData);
|
||||
else
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, textureData);
|
||||
|
||||
Unbind();
|
||||
}
|
||||
|
||||
Texture::~Texture() {
|
||||
glDeleteTextures(1, &m_ID);
|
||||
}
|
||||
|
||||
void Texture::Bind() const {
|
||||
glBindTexture(GL_TEXTURE_2D, m_ID);
|
||||
}
|
||||
|
||||
void Texture::Unbind() {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user