OpenGL: Implement textures

This commit is contained in:
Lynix
2020-04-19 15:33:56 +02:00
parent 349e915e10
commit b4b15f826d
12 changed files with 227 additions and 298 deletions

View File

@@ -22,6 +22,41 @@ namespace Nz::GL
m_device->NotifyContextDestruction(*this);
}
void Context::BindTexture(TextureTarget target, GLuint texture) const
{
if (!SetCurrentContext(this))
throw std::runtime_error("failed to activate context");
if (m_state.boundTextures[UnderlyingCast(target)] != texture)
{
GLenum glTarget;
switch (target)
{
case TextureTarget::Cubemap:
glTarget = GL_TEXTURE_CUBE_MAP;
break;
case TextureTarget::Target2D:
glTarget = GL_TEXTURE_2D;
break;
case TextureTarget::Target2D_Array:
glTarget = GL_TEXTURE_2D_ARRAY;
break;
case TextureTarget::Target3D:
glTarget = GL_TEXTURE_3D;
break;
default:
break;
}
glBindTexture(glTarget, texture);
m_state.boundTextures[UnderlyingCast(target)] = texture;
}
}
bool Context::Initialize(const ContextParams& params)
{
@@ -31,6 +66,8 @@ namespace Nz::GL
return false;
}
m_state.boundTextures.fill(0);
const Loader& loader = GetLoader();
auto LoadSymbol = [&](auto& func, const char* funcName, bool mandatory)