Re: [osg-users] Stencil buffer and FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT

2010-10-15 Thread J.P. Delport

Hi Fred,

we've also encountered cases (float formats) where we need to call:

void setInternalTextureFormat(GLint internalFormat);

after allocateImage in the case of using Images to read back data. If 
you look at allocateImage code, you'll see why.


Can you check if this works for you without modification to Texture2D.cpp?

rgds
jp

On 14/10/10 17:55, Fred Smith wrote:

This looks like an OSG bug to me. The code is in osg\Texture2D.cpp,
in Texture2D::apply.

With PACKED_DEPTH_STENCIL_BUFFER, internalFormat should be
GL_DEPTH24_STENCIL8_EXT, format should be GL_DEPTH_STENCIL_EXT and
type GL_UNSIGNED_INT_24_8_EXT.

The current OSG 2.8 code makes this GL_DEPTH_STENCIL_EXT,
GL_DEPTH_STENCIL_EXT and GL_UNSIGNED_BYTE. This is incorrect, hence
the driver returns GL_INVALID_ENUM.

To make the osgpackeddepthstencil sample work as desired, with the
code modification mentionned at the beginning of this thread,
Texture2D.cpp can be modified this way:


Code: if (_internalFormat == 6408) // GL_RGBA glTexImage2D(
GL_TEXTURE_2D, 0, _internalFormat, _textureWidth, _textureHeight,
_borderWidth, _sourceFormat ? _sourceFormat : _internalFormat,
_sourceType ? _sourceType : GL_UNSIGNED_BYTE, 0); else glTexImage2D(
GL_TEXTURE_2D, 0, 0x88F0, // GL_DEPTH24_STENCIL8_EXT, _textureWidth,
_textureHeight, _borderWidth, 0x84F9, // GL_DEPTH_STENCIL_EXT,
0x84FA, // GL_UNSIGNED_INT_24_8_EXT, 0);


Of course the code above is just a dirty modification just for
testing purposes, but it does work.

-- Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32762#32762





___ osg-users mailing
list osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Stencil buffer and FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT

2010-10-15 Thread Fred Smith
Hi JP,

As soon as I attach an image, OSG crashes on me. The problem arises in 
FrameBufferObject::Pimpl::Pimpl.


Code:
// This code crashes
osg::Texture2D *texture = new osg::Texture2D();
texture-setTextureSize(1024, 1024);
texture-setInternalFormat(GL_DEPTH24_STENCIL8_EXT);
osg::Image *image = new osg::Image();
image-allocateImage(1024, 1024, 1, GL_DEPTH_STENCIL_EXT, 
GL_UNSIGNED_INT_24_8_EXT, 1);
texture-setImage(image);
rttCamera-attach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, image);


The following code works, but only if I modify Texture2D.cpp


Code:
osg::Texture2D *texture = new osg::Texture2D();
texture-setTextureSize(1024, 1024);
texture-setInternalFormat(GL_DEPTH24_STENCIL8_EXT);
rttCamera-attach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, texture);


Fred

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32787#32787





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Stencil buffer and FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT

2010-10-14 Thread Fred Smith

Frederic Bouvier wrote:
 Maybe :
 
 textureDepthStencil-setInternalFormat( GL_DEPTH_STENCIL_EXT );
 ...
 camera-attach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, textureDepthStencil);
 
 Could work. As the depth and stencil buffer are packed, so should the texture.
 (re)read http://www.opengl.org/registry/specs/EXT/packed_depth_stencil.txt
 
 there is a paragraph that starts with :
 In addition, a new base internal format, GL_DEPTH_STENCIL_EXT, can
 be used by both texture images and renderbuffer storage.  When an
 image with a DEPTH_STENCIL_EXT internal format is attached to both
 the depth and stencil attachment points of a framebuffer object (see
 EXT_framebuffer_object), then it becomes both the depth and stencil
 buffers of the framebuffer...

I modified the osgpackeddepthstencil sample the following way and it just 
doesn't work.


Code:
if(usePDS)
{
osg::Texture2D *textureDS = new osg::Texture2D;
textureDS-setTextureSize(1024, 1024);
textureDS-setInternalFormat(GL_DEPTH_STENCIL_EXT);
rttCamera-attach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, textureDS);
}



I'm using the latest nVidia drivers on Windows 7 x64 and OSG 2.8.

When looking things up with an OpenGL tracer (I used glslDevil here) the error 
is generated upon the following call made by OSG:


Code:
glTexImage2D(GL_TEXTURE_2D, 0, 34041, 1024, 1024, 0, GL_DEPTH_STENCIL_NV, 
GL_UNSIGNED_BYTE, )

OpenGL error GL_INVALID_ENUM detected


34041 = 0x84F9 = GL_DEPTH_STENCIL_NV according to GLew.h

Is this a bug, or am I doing something wrong?

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32735#32735





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Stencil buffer and FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT

2010-10-14 Thread Fred Smith
I've also tried with an image:


Code:
Image *pdsImage = new Image();
pdsImage-allocateImage(256, 256, 1, GL_DEPTH24_STENCIL8_EXT, 
GL_UNSIGNED_INT_24_8_EXT, 1);
camera-attach(PACKED_DEPTH_STENCIL_BUFFER, pdsImage);


This code results in the following error and then the application crashes.

error type = 34042
Error: FrameBufferAttachment::FrameBufferAttachment(Camera::Attachment) passed 
an empty osg::Image, image must be allocated first.


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32737#32737





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Stencil buffer and FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT

2010-10-14 Thread Fred Smith
This looks like an OSG bug to me. The code is in osg\Texture2D.cpp, in 
Texture2D::apply.

With PACKED_DEPTH_STENCIL_BUFFER, internalFormat should be 
GL_DEPTH24_STENCIL8_EXT, format should be GL_DEPTH_STENCIL_EXT and type 
GL_UNSIGNED_INT_24_8_EXT.

The current OSG 2.8 code makes this GL_DEPTH_STENCIL_EXT, GL_DEPTH_STENCIL_EXT 
and GL_UNSIGNED_BYTE. This is incorrect, hence the driver returns 
GL_INVALID_ENUM.

To make the osgpackeddepthstencil sample work as desired, with the code 
modification mentionned at the beginning of this thread, Texture2D.cpp can be 
modified this way:


Code:
if (_internalFormat == 6408) // GL_RGBA
glTexImage2D( GL_TEXTURE_2D, 0, _internalFormat,
 _textureWidth, _textureHeight, 
_borderWidth,
 _sourceFormat ? _sourceFormat 
: _internalFormat,
 _sourceType ? _sourceType : 
GL_UNSIGNED_BYTE,
 0);
else
glTexImage2D( GL_TEXTURE_2D, 0, 0x88F0, // 
GL_DEPTH24_STENCIL8_EXT,
 _textureWidth, _textureHeight, 
_borderWidth,
 0x84F9, // 
GL_DEPTH_STENCIL_EXT,
 0x84FA, // 
GL_UNSIGNED_INT_24_8_EXT,
 0);


Of course the code above is just a dirty modification just for testing 
purposes, but it does work.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32762#32762





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Stencil buffer and FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT

2010-10-12 Thread Fred Smith
The following works fine:

camera-attach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, GL_DEPTH_STENCIL_EXT);

Why doesn't it work if I create a texture? I need to create a texture and an 
image, as I want to retrieve stencil buffer data after frame() has been called.

Cheers,
Fred

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32649#32649





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Stencil buffer and FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT

2010-10-12 Thread Frederic Bouvier
Hi Fred,

- Fred Smith a écrit :

 The following works fine:
 
 camera-attach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER,
 GL_DEPTH_STENCIL_EXT);
 
 Why doesn't it work if I create a texture? I need to create a texture
 and an image, as I want to retrieve stencil buffer data after frame()
 has been called.

I doubt it is possible to read back the stencil buffer, and attach it to a 
texture.

Regards,
-Fred
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Stencil buffer and FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT

2010-10-12 Thread Fred Smith
Hi Fred,


Frederic Bouvier wrote:
 
 I doubt it is possible to read back the stencil buffer, and attach it to a 
 texture.
 


Then how can I read back stencil buffer data?

Thanks,
Fred

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32659#32659





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Stencil buffer and FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT

2010-10-12 Thread Frederic Bouvier
Maybe :

textureDepthStencil-setInternalFormat( GL_DEPTH_STENCIL_EXT );
...
camera-attach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, textureDepthStencil);
 
Could work. As the depth and stencil buffer are packed, so should the texture.
(re)read http://www.opengl.org/registry/specs/EXT/packed_depth_stencil.txt

there is a paragraph that starts with :
In addition, a new base internal format, GL_DEPTH_STENCIL_EXT, can
be used by both texture images and renderbuffer storage.  When an
image with a DEPTH_STENCIL_EXT internal format is attached to both
the depth and stencil attachment points of a framebuffer object (see
EXT_framebuffer_object), then it becomes both the depth and stencil
buffers of the framebuffer...

-Fred
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org