Renderer: Improve texture view support (and support emulation for OGL)

This commit is contained in:
SirLynix
2022-12-02 22:58:34 +01:00
committed by Jérôme Leclercq
parent 08ea4c87a7
commit 56acbb2694
9 changed files with 99 additions and 24 deletions

View File

@@ -27,6 +27,7 @@ namespace Nz::GL
inline void DrawBuffers(GLsizei n, const GLenum* bufs);
inline void Renderbuffer(GLenum attachment, GLenum renderbuffer);
inline void Texture2D(GLenum attachment, GLenum textarget, GLuint texture, GLint level = 0);
inline void TextureLayer(GLenum attachment, GLuint texture, GLint level = 0, GLint layer = 0);
Framebuffer& operator=(const Framebuffer&) = delete;
Framebuffer& operator=(Framebuffer&&) noexcept = default;

View File

@@ -44,6 +44,15 @@ namespace Nz::GL
context.glFramebufferTexture2D(target, attachment, textarget, texture, level);
}
inline void Framebuffer::TextureLayer(GLenum attachment, GLuint texture, GLint level, GLint layer)
{
assert(m_objectId);
const Context& context = EnsureContext();
GLenum target = context.BindFramebuffer(m_objectId);
context.glFramebufferTextureLayer(target, attachment, texture, level, layer);
}
inline GLuint Framebuffer::CreateHelper(const Context& context)
{
GLuint fbo = 0;

View File

@@ -39,7 +39,7 @@ namespace Nz::GL
inline void TexStorage3D(TextureTarget target, GLint levels, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth);
inline void TexSubImage2D(TextureTarget target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data);
inline void TexSubImage3D(TextureTarget target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* data);
inline void TextureView(GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
inline void TextureView(TextureTarget target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
Texture& operator=(const Texture&) = delete;
Texture& operator=(Texture&&) noexcept = default;

View File

@@ -111,10 +111,12 @@ namespace Nz::GL
//< TODO: Handle errors
}
inline void Texture::TextureView(GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers)
inline void Texture::TextureView(TextureTarget target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers)
{
m_target = target;
const Context& context = EnsureDeviceContext();
context.glTextureView(m_objectId, target, origtexture, internalformat, minlevel, numlevels, minlayer, numlayers);
context.glTextureView(m_objectId, ToOpenGL(target), origtexture, internalformat, minlevel, numlevels, minlayer, numlayers);
}
inline GLuint Texture::CreateHelper(OpenGLDevice& /*device*/, const Context& context)