@@ -148,8 +148,6 @@ void gl::GLTextures::uploadTexture(TextureProperties* textureProperties, Texture
148148
149149 if (dynamic_cast <DepthTexture*>(&texture)) {
150150
151- glInternalFormat = GL_DEPTH_COMPONENT;
152-
153151 if (texture.type == Type::Float) {
154152
155153 glInternalFormat = GL_DEPTH_COMPONENT32F;
@@ -164,39 +162,7 @@ void gl::GLTextures::uploadTexture(TextureProperties* textureProperties, Texture
164162
165163 } else {
166164
167- glInternalFormat = GL_DEPTH_COMPONENT16;
168- }
169-
170- if (texture.format == Format::Depth && glInternalFormat == GL_DEPTH_COMPONENT) {
171-
172- // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
173- // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
174- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
175- if (texture.type != Type::UnsignedShort && texture.type != Type::UnsignedInt) {
176-
177- std::cerr << " THREE.GLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture." << std::endl;
178-
179- texture.type = Type::UnsignedShort;
180- glType = toGLType (texture.type );
181- }
182- }
183-
184- if (texture.format == Format::DepthStencil && glInternalFormat == GL_DEPTH_COMPONENT) {
185-
186- // Depth stencil textures need the DEPTH_STENCIL internal format
187- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
188- glInternalFormat = GL_DEPTH_STENCIL;
189-
190- // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
191- // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
192- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
193- if (texture.type != Type::UnsignedInt248) {
194-
195- std::cerr << " THREE.GLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture." << std::endl;
196-
197- texture.type = Type::UnsignedInt248;
198- glType = toGLType (texture.type );
199- }
165+ glInternalFormat = GL_DEPTH_COMPONENT24;
200166 }
201167
202168 //
@@ -514,11 +480,17 @@ void gl::GLTextures::setupDepthTexture(unsigned int framebuffer, GLRenderTarget*
514480 if (renderTarget->depthTexture ->format == Format::Depth) {
515481
516482 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, *glDepthTexture, 0 );
517-
483+ GLenum status = glCheckFramebufferStatus (GL_FRAMEBUFFER);
484+ if (status != GL_FRAMEBUFFER_COMPLETE) {
485+ std::cerr << " GLTextures: Depth texture framebuffer (depth) incomplete: 0x" << std::hex << status << std::dec << std::endl;
486+ }
518487 } else if (renderTarget->depthTexture ->format == Format::DepthStencil) {
519488
520489 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, *glDepthTexture, 0 );
521-
490+ GLenum status = glCheckFramebufferStatus (GL_FRAMEBUFFER);
491+ if (status != GL_FRAMEBUFFER_COMPLETE) {
492+ std::cerr << " GLTextures: Depth texture framebuffer (stencil) incomplete: 0x" << std::hex << status << std::dec << std::endl;
493+ }
522494 } else {
523495
524496 throw std::runtime_error (" Unknown depthTexture format" );
0 commit comments