From 261db64a9e014f339042e21b7e1575b9693164fe Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 24 Jun 2013 09:51:30 +0000 Subject: [PATCH] From Farshid Lashkari, "I've attached a small patch that extends the Image::readImageFromCurrentTexture method to support more depth texture pixel formats (16, 24, 32, 32F). In order to compile, I moved some depth pixel format definitions from FrameBufferObject to Image. " --- include/osg/FrameBufferObject | 18 ------------------ include/osg/Image | 18 ++++++++++++++++++ src/osg/Image.cpp | 12 ++++++++++++ 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/include/osg/FrameBufferObject b/include/osg/FrameBufferObject index f5a95080e..6c5e3ceb6 100644 --- a/include/osg/FrameBufferObject +++ b/include/osg/FrameBufferObject @@ -108,24 +108,6 @@ #define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 #endif -#ifndef GL_DEPTH_COMPONENT -#define GL_DEPTH_COMPONENT 0x1902 -#endif - -#ifndef GL_VERSION_1_4 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#endif - -#ifndef GL_DEPTH_COMPONENT32F -#define GL_DEPTH_COMPONENT32F 0x8CAC -#endif - -#ifndef GL_DEPTH_COMPONENT32F_NV -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#endif - #ifndef GL_EXT_packed_depth_stencil #define GL_EXT_packed_depth_stencil 1 #define GL_DEPTH_STENCIL_EXT 0x84F9 diff --git a/include/osg/Image b/include/osg/Image index 7edec777c..d96a655a8 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -97,6 +97,24 @@ #define GL_ETC1_RGB8_OES 0x8D64 #endif +#ifndef GL_DEPTH_COMPONENT +#define GL_DEPTH_COMPONENT 0x1902 +#endif + +#ifndef GL_VERSION_1_4 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#endif + +#ifndef GL_DEPTH_COMPONENT32F +#define GL_DEPTH_COMPONENT32F 0x8CAC +#endif + +#ifndef GL_DEPTH_COMPONENT32F_NV +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#endif + namespace osg { // forward declare diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 885338edf..6363ea442 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -408,6 +408,13 @@ GLenum Image::computePixelFormat(GLenum format) case(GL_RGBA8UI_EXT): return GL_RGBA_INTEGER_EXT; + case(GL_DEPTH_COMPONENT16): + case(GL_DEPTH_COMPONENT24): + case(GL_DEPTH_COMPONENT32): + case(GL_DEPTH_COMPONENT32F): + case(GL_DEPTH_COMPONENT32F_NV): + return GL_DEPTH_COMPONENT; + default: return format; } @@ -490,6 +497,11 @@ unsigned int Image::computeNumComponents(GLenum pixelFormat) case(GL_COLOR_INDEX): return 1; case(GL_STENCIL_INDEX): return 1; case(GL_DEPTH_COMPONENT): return 1; + case(GL_DEPTH_COMPONENT16): return 1; + case(GL_DEPTH_COMPONENT24): return 1; + case(GL_DEPTH_COMPONENT32): return 1; + case(GL_DEPTH_COMPONENT32F): return 1; + case(GL_DEPTH_COMPONENT32F_NV): return 1; case(GL_RED): return 1; case(GL_GREEN): return 1; case(GL_BLUE): return 1;