Parcourir la source

gpu: add a 16-bit depth buffer to framebuffers on WebGL and GL ES.

legacy
Sam Hocevar sam il y a 11 ans
Parent
révision
01547a0a20
2 fichiers modifiés avec 19 ajouts et 5 suppressions
  1. +13
    -5
      src/gpu/framebuffer.cpp
  2. +6
    -0
      src/lolgl.h

+ 13
- 5
src/gpu/framebuffer.cpp Voir le fichier

@@ -344,12 +344,17 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format)
* GL_RGBA16F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB, GL_LUMINANCE32F_ARB. */
GLenum internal_format = fbo_format.GetFormat();
GLenum format = fbo_format.GetFormatOrder();
# elif GL_ES_VERSION_2_0
/* In OpenGL ES, internal format and format must match. */
GLenum internal_format = fbo_format.GetFormat();
GLenum format = fbo_format.GetFormat();
GLenum depth = GL_DEPTH_COMPONENT16; /* for WebGL */
# else
/* In OpenGL ES, internal format and format must match. */
GLenum internal_format = fbo_format.GetFormat();
GLenum format = fbo_format.GetFormat();
# endif
GLenum wrapmode = GL_REPEAT;
GLenum wrapmode = GL_CLAMP_TO_EDGE;
GLenum filtering = GL_NEAREST;

# if GL_VERSION_1_1 || GL_ES_VERSION_2_0
@@ -379,11 +384,12 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format)
# endif

m_data->m_depth = GL_INVALID_ENUM;
# if GL_VERSION_1_1
/* FIXME: not implemented on GL ES, see
* http://stackoverflow.com/q/4041682/111461 */
# if GL_VERSION_1_1 || GL_ES_VERSION_2_0
if (depth != GL_INVALID_ENUM)
{
/* XXX: might not work on GL ES, see
* http://stackoverflow.com/q/4041682/111461
* See also http://qt-project.org/forums/viewthread/11734 */
glGenRenderbuffers(1, &m_data->m_depth);
glBindRenderbuffer(GL_RENDERBUFFER, m_data->m_depth);
glRenderbufferStorage(GL_RENDERBUFFER, depth, size.x, size.y);
@@ -392,6 +398,8 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format)
}
# endif

glBindTexture(GL_TEXTURE_2D, 0);

# if GL_VERSION_1_1 || GL_ES_VERSION_2_0
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
ASSERT(status == GL_FRAMEBUFFER_COMPLETE,
@@ -418,7 +426,7 @@ Framebuffer::~Framebuffer()
glDeleteFramebuffersOES(1, &m_data->m_fbo);
# endif
glDeleteTextures(1, &m_data->m_texture);
# if GL_VERSION_1_1
# if GL_VERSION_1_1 || GL_ES_VERSION_2_0
if (m_data->m_depth != GL_INVALID_ENUM)
glDeleteRenderbuffers(1, &m_data->m_depth);
# endif


+ 6
- 0
src/lolgl.h Voir le fichier

@@ -59,5 +59,11 @@
# endif
#endif

#define LOL_CHECK_GLERROR() \
{ \
GLenum error = glGetError(); \
ASSERT(error == GL_NO_ERROR, "OpenGL error: 0x%04x\n", error); \
}

#endif // __LOL_LOLGL_H__


Chargement…
Annuler
Enregistrer