Get 24bit/32bit rendertarget textures working in WebGL.
WEBGL_depth_texture doesn't use same symbols as OES_packed_depth_stencil & OES_depth32 and also does not allow attaching depth and stencil buffers to RTT like other GL versions. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5557 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
54ba627a72
commit
56317e5278
|
@ -218,6 +218,19 @@ public:
|
|||
{
|
||||
GLuint textureID = static_cast<TOpenGLTexture*>(DepthStencil)->getOpenGLTextureName();
|
||||
|
||||
#ifdef _IRR_EMSCRIPTEN_PLATFORM_ // The WEBGL_depth_texture extension does not allow attaching stencil+depth separate.
|
||||
if (textureFormat == ECF_D24S8)
|
||||
{
|
||||
GLenum attachment = 0x821A; // GL_DEPTH_STENCIL_ATTACHMENT
|
||||
Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, textureID, 0);
|
||||
AssignedStencil = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, textureID, 0);
|
||||
AssignedStencil = false;
|
||||
}
|
||||
#else
|
||||
Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, textureID, 0);
|
||||
|
||||
if (textureFormat == ECF_D24S8)
|
||||
|
@ -233,7 +246,7 @@ public:
|
|||
|
||||
AssignedStencil = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
AssignedDepth = true;
|
||||
}
|
||||
else
|
||||
|
@ -301,7 +314,7 @@ protected:
|
|||
{
|
||||
if (ColorAttachment == 0)
|
||||
return true;
|
||||
|
||||
|
||||
GLenum status = driver->irrGlCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
|
||||
switch (status)
|
||||
|
|
|
@ -904,7 +904,6 @@ bool CWebGL1Driver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern
|
|||
pixelType = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
case ECF_D32:
|
||||
#if defined(GL_OES_depth32)
|
||||
if (WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_depth_texture))
|
||||
{
|
||||
// NOTE: There is still no guarantee it will return a 32 bit depth buffer. It might convert stuff internally to 16 bit :-(
|
||||
|
@ -912,17 +911,14 @@ bool CWebGL1Driver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern
|
|||
pixelFormat = GL_DEPTH_COMPONENT;
|
||||
pixelType = GL_UNSIGNED_INT;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case ECF_D24S8:
|
||||
#ifdef GL_OES_packed_depth_stencil
|
||||
if (WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_depth_texture))
|
||||
{
|
||||
supported = true;
|
||||
pixelFormat = GL_DEPTH_STENCIL_OES;
|
||||
pixelType = GL_UNSIGNED_INT_24_8_OES;
|
||||
pixelFormat = 0x84F9; // GL_DEPTH_STENCIL
|
||||
pixelType = 0x84FA; // UNSIGNED_INT_24_8_WEBGL
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case ECF_R8:
|
||||
// Does not seem to be supported in WebGL so far (missing GL_EXT_texture_rg)
|
||||
|
|
Loading…
Reference in New Issue