---------------------------------------------------------------------
| 689 | |
| 690 | //--------------------------------------------------------------------- |
| 691 | DepthBuffer* GLES2RenderSystem::_createDepthBufferFor( RenderTarget *renderTarget, bool exactMatchFormat ) |
| 692 | { |
| 693 | GLES2DepthBuffer *retVal = 0; |
| 694 | |
| 695 | // Only FBOs support different depth buffers, so everything |
| 696 | // else creates dummy (empty) containers |
| 697 | // retVal = mRTTManager->_createDepthBufferFor( renderTarget ); |
| 698 | GLES2FrameBufferObject *fbo = 0; |
| 699 | renderTarget->getCustomAttribute("FBO", &fbo); |
| 700 | |
| 701 | if( fbo || renderTarget->getForceDisableColourWrites() ) |
| 702 | { |
| 703 | PixelFormat desiredDepthBufferFormat = renderTarget->getDesiredDepthBufferFormat(); |
| 704 | |
| 705 | if( !exactMatchFormat ) |
| 706 | { |
| 707 | if( desiredDepthBufferFormat == PF_D24_UNORM_X8 && renderTarget->prefersDepthTexture() ) |
| 708 | desiredDepthBufferFormat = PF_D24_UNORM; |
| 709 | else |
| 710 | desiredDepthBufferFormat = PF_D24_UNORM_S8_UINT; |
| 711 | } |
| 712 | |
| 713 | PixelFormat renderTargetFormat; |
| 714 | |
| 715 | if( fbo ) |
| 716 | renderTargetFormat = fbo->getFormat(); |
| 717 | else |
| 718 | { |
| 719 | //Deal with depth textures |
| 720 | renderTargetFormat = desiredDepthBufferFormat; |
| 721 | } |
| 722 | |
| 723 | // Presence of an FBO means the manager is an FBO Manager, that's why it's safe to downcast |
| 724 | // Find best depth & stencil format suited for the RT's format |
| 725 | GLuint depthFormat, stencilFormat; |
| 726 | static_cast<GLES2FBOManager*>(mRTTManager)->getBestDepthStencil( desiredDepthBufferFormat, |
| 727 | renderTargetFormat, |
| 728 | &depthFormat, |
| 729 | &stencilFormat ); |
| 730 | |
| 731 | // OpenGL specs explicitly disallow depth textures with separate stencil. |
| 732 | if( stencilFormat == GL_NONE || !renderTarget->prefersDepthTexture() ) |
| 733 | { |
| 734 | // No "custom-quality" multisample for now in GL |
| 735 | retVal = OGRE_NEW GLES2DepthBuffer( 0, this, mCurrentContext, depthFormat, stencilFormat, |
| 736 | renderTarget->getWidth(), renderTarget->getHeight(), |
| 737 | renderTarget->getFSAA(), 0, |
| 738 | desiredDepthBufferFormat, |
| 739 | renderTarget->prefersDepthTexture(), false ); |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | return retVal; |
| 744 | } |
| 745 | //--------------------------------------------------------------------- |
| 746 | void GLES2RenderSystem::_getDepthStencilFormatFor( GLenum internalColourFormat, GLenum *depthFormat, |
| 747 | GLenum *stencilFormat ) |
no test coverage detected