OpenGLRenderer: Fix textures
This commit is contained in:
@@ -13,7 +13,8 @@ namespace Nz::GL
|
||||
assert(m_objectId);
|
||||
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.glTexParameterf(m_objectId, pname, param);
|
||||
context.BindTexture(m_target, m_objectId);
|
||||
context.glTexParameterf(ToOpenGL(m_target), pname, param);
|
||||
}
|
||||
|
||||
inline void Texture::SetParameteri(GLenum pname, GLint param)
|
||||
@@ -21,7 +22,8 @@ namespace Nz::GL
|
||||
assert(m_objectId);
|
||||
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.glTexParameteri(m_objectId, pname, param);
|
||||
context.BindTexture(m_target, m_objectId);
|
||||
context.glTexParameteri(ToOpenGL(m_target), pname, param);
|
||||
}
|
||||
|
||||
inline void Texture::SetParameterfv(GLenum pname, const GLfloat* param)
|
||||
@@ -29,7 +31,8 @@ namespace Nz::GL
|
||||
assert(m_objectId);
|
||||
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.glTexParameterfv(m_objectId, pname, param);
|
||||
context.BindTexture(m_target, m_objectId);
|
||||
context.glTexParameterfv(ToOpenGL(m_target), pname, param);
|
||||
}
|
||||
|
||||
inline void Texture::SetParameteriv(GLenum pname, const GLint* param)
|
||||
@@ -37,38 +40,39 @@ namespace Nz::GL
|
||||
assert(m_objectId);
|
||||
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.glTexParameteriv(m_objectId, pname, param);
|
||||
context.BindTexture(m_target, m_objectId);
|
||||
context.glTexParameteriv(ToOpenGL(m_target), pname, param);
|
||||
}
|
||||
|
||||
inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border)
|
||||
inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type)
|
||||
{
|
||||
return TexImage2D(level, internalFormat, width, height, border, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
|
||||
return TexImage2D(level, internalFormat, width, height, border, format, type, nullptr);
|
||||
}
|
||||
|
||||
inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* data)
|
||||
{
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.BindTexture(TextureTarget::Target2D, m_objectId);
|
||||
m_target = TextureTarget::Target2D;
|
||||
|
||||
context.glTexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, border, format, type, data);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.BindTexture(m_target, m_objectId);
|
||||
context.glTexImage2D(ToOpenGL(m_target), level, internalFormat, width, height, border, format, type, data);
|
||||
//< TODO: Handle errors
|
||||
}
|
||||
|
||||
inline void Texture::TexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data)
|
||||
{
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.BindTexture(TextureTarget::Target2D, m_objectId);
|
||||
|
||||
context.glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, width, height, format, type, data);
|
||||
context.BindTexture(m_target, m_objectId);
|
||||
context.glTexSubImage2D(ToOpenGL(m_target), level, xoffset, yoffset, width, height, format, type, data);
|
||||
//< TODO: Handle errors
|
||||
}
|
||||
|
||||
inline GLuint Texture::CreateHelper(OpenGLDevice& device, const Context& context)
|
||||
{
|
||||
GLuint sampler = 0;
|
||||
context.glGenTextures(1U, &sampler);
|
||||
GLuint texture = 0;
|
||||
context.glGenTextures(1U, &texture);
|
||||
|
||||
return sampler;
|
||||
return texture;
|
||||
}
|
||||
|
||||
inline void Texture::DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId)
|
||||
|
||||
Reference in New Issue
Block a user