<commit_before>/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 <NAME> 
 *
 * This library is open source and may be redistributed and/or modified under  
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * OpenSceneGraph Public License for more details.
*/

// initial FBO support written by <NAME>, June 2005.

#include <osg/FrameBufferObject>
#include <osg/State>
#include <osg/GLExtensions>
#include <osg/Texture1D>
#include <osg/Texture2D>
#include <osg/Texture3D>
#include <osg/Texture2DArray>
#include <osg/TextureCubeMap>
#include <osg/TextureRectangle>
#include <osg/Notify>
#include <osg/Timer>

using namespace osg;

static buffered_object< ref_ptr<FBOExtensions> > s_extensions;

FBOExtensions* FBOExtensions::instance(unsigned contextID, bool createIfNotInitalized)
{
    if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new FBOExtensions(contextID);
    return s_extensions[contextID].get();
}

/**************************************************************************
 * FBOExtensions
 **************************************************************************/
#define LOAD_FBO_EXT(name)    setGLExtensionFuncPtr(name, (#name))

FBOExtensions::FBOExtensions(unsigned int contextID)
:   glBindRenderbufferEXT(0),
    glGenRenderbuffersEXT(0),
    glDeleteRenderbuffersEXT(0),
    glRenderbufferStorageEXT(0),
    glRenderbufferStorageMultisampleEXT(0),
    glRenderbufferStorageMultisampleCoverageNV(0),
    glBindFramebufferEXT(0),
    glDeleteFramebuffersEXT(0),
    glGenFramebuffersEXT(0),
    glCheckFramebufferStatusEXT(0),
    glFramebufferTexture1DEXT(0),
    glFramebufferTexture2DEXT(0),
    glFramebufferTexture3DEXT(0),
    glFramebufferTextureLayerEXT(0),
    glFramebufferRenderbufferEXT(0),
    glGenerateMipmapEXT(0),
    glBlitFramebufferEXT(0),
    _supported(false),
    _packed_depth_stencil_supported(false)
{
    if (!isGLExtensionSupported(contextID, "GL_EXT_framebuffer_object"))
        return;
    
    LOAD_FBO_EXT(glBindRenderbufferEXT);
    LOAD_FBO_EXT(glGenRenderbuffersEXT);
    LOAD_FBO_EXT(glDeleteRenderbuffersEXT);
    LOAD_FBO_EXT(glRenderbufferStorageEXT);
    LOAD_FBO_EXT(glBindFramebufferEXT);
    LOAD_FBO_EXT(glDeleteFramebuffersEXT);
    LOAD_FBO_EXT(glGenFramebuffersEXT);
    LOAD_FBO_EXT(glCheckFramebufferStatusEXT);
    LOAD_FBO_EXT(glFramebufferTexture1DEXT);
    LOAD_FBO_EXT(glFramebufferTexture2DEXT);
    LOAD_FBO_EXT(glFramebufferTexture3DEXT);
    LOAD_FBO_EXT(glFramebufferTextureLayerEXT);
    LOAD_FBO_EXT(glFramebufferRenderbufferEXT);
    LOAD_FBO_EXT(glGenerateMipmapEXT);

    _supported = 
        glBindRenderbufferEXT != 0 &&
        glDeleteRenderbuffersEXT != 0 &&
        glGenRenderbuffersEXT != 0 &&
        glRenderbufferStorageEXT != 0 &&
        glBindFramebufferEXT != 0 &&
        glDeleteFramebuffersEXT != 0 &&
        glGenFramebuffersEXT != 0 &&
        glCheckFramebufferStatusEXT != 0 &&
        glFramebufferTexture1DEXT != 0 &&
        glFramebufferTexture2DEXT != 0 &&
        glFramebufferTexture3DEXT != 0 &&
        glFramebufferRenderbufferEXT != 0 &&
        glGenerateMipmapEXT != 0;

    if (!isGLExtensionSupported(contextID, "GL_EXT_framebuffer_blit"))
        return;

    LOAD_FBO_EXT(glBlitFramebufferEXT);

    if (isGLExtensionSupported(contextID, "GL_EXT_framebuffer_multisample"))
    {
        LOAD_FBO_EXT(glRenderbufferStorageMultisampleEXT);
    }

    if (isGLExtensionSupported(contextID, "GL_NV_framebuffer_multisample_coverage"))
    {
        LOAD_FBO_EXT(glRenderbufferStorageMultisampleCoverageNV);
    }

    if (isGLExtensionSupported(contextID, "GL_EXT_packed_depth_stencil"))
    {
        _packed_depth_stencil_supported = true;
    }
}


/**************************************************************************
 * RenderBuffer
 **************************************************************************/
<commit_msg>From <NAME>, "Without this change packed depth stencil attachments are only supported if the GL_EXT_framebuffer_blit extension is available. This is due to the early return from the constructor if this is missing. As far as I read the standard extension documents, this blit call is not required to have packed depth stencil fbos. The change fixes this and allows packed stencil attachments on machines without the multisample blit command."<commit_after>/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 <NAME> 
 *
 * This library is open source and may be redistributed and/or modified under  
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * OpenSceneGraph Public License for more details.
*/

// initial FBO support written by <NAME>, June 2005.

#include <osg/FrameBufferObject>
#include <osg/State>
#include <osg/GLExtensions>
#include <osg/Texture1D>
#include <osg/Texture2D>
#include <osg/Texture3D>
#include <osg/Texture2DArray>
#include <osg/TextureCubeMap>
#include <osg/TextureRectangle>
#include <osg/Notify>
#include <osg/Timer>

using namespace osg;

static buffered_object< ref_ptr<FBOExtensions> > s_extensions;

FBOExtensions* FBOExtensions::instance(unsigned contextID, bool createIfNotInitalized)
{
    if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new FBOExtensions(contextID);
    return s_extensions[contextID].get();
}

/**************************************************************************
 * FBOExtensions
 **************************************************************************/
#define LOAD_FBO_EXT(name)    setGLExtensionFuncPtr(name, (#name))

FBOExtensions::FBOExtensions(unsigned int contextID)
:   glBindRenderbufferEXT(0),
    glGenRenderbuffersEXT(0),
    glDeleteRenderbuffersEXT(0),
    glRenderbufferStorageEXT(0),
    glRenderbufferStorageMultisampleEXT(0),
    glRenderbufferStorageMultisampleCoverageNV(0),
    glBindFramebufferEXT(0),
    glDeleteFramebuffersEXT(0),
    glGenFramebuffersEXT(0),
    glCheckFramebufferStatusEXT(0),
    glFramebufferTexture1DEXT(0),
    glFramebufferTexture2DEXT(0),
    glFramebufferTexture3DEXT(0),
    glFramebufferTextureLayerEXT(0),
    glFramebufferRenderbufferEXT(0),
    glGenerateMipmapEXT(0),
    glBlitFramebufferEXT(0),
    _supported(false),
    _packed_depth_stencil_supported(false)
{
    if (!isGLExtensionSupported(contextID, "GL_EXT_framebuffer_object"))
        return;
    
    LOAD_FBO_EXT(glBindRenderbufferEXT);
    LOAD_FBO_EXT(glGenRenderbuffersEXT);
    LOAD_FBO_EXT(glDeleteRenderbuffersEXT);
    LOAD_FBO_EXT(glRenderbufferStorageEXT);
    LOAD_FBO_EXT(glBindFramebufferEXT);
    LOAD_FBO_EXT(glDeleteFramebuffersEXT);
    LOAD_FBO_EXT(glGenFramebuffersEXT);
    LOAD_FBO_EXT(glCheckFramebufferStatusEXT);
    LOAD_FBO_EXT(glFramebufferTexture1DEXT);
    LOAD_FBO_EXT(glFramebufferTexture2DEXT);
    LOAD_FBO_EXT(glFramebufferTexture3DEXT);
    LOAD_FBO_EXT(glFramebufferTextureLayerEXT);
    LOAD_FBO_EXT(glFramebufferRenderbufferEXT);
    LOAD_FBO_EXT(glGenerateMipmapEXT);

    _supported = 
        glBindRenderbufferEXT != 0 &&
        glDeleteRenderbuffersEXT != 0 &&
        glGenRenderbuffersEXT != 0 &&
        glRenderbufferStorageEXT != 0 &&
        glBindFramebufferEXT != 0 &&
        glDeleteFramebuffersEXT != 0 &&
        glGenFramebuffersEXT != 0 &&
        glCheckFramebufferStatusEXT != 0 &&
        glFramebufferTexture1DEXT != 0 &&
        glFramebufferTexture2DEXT != 0 &&
        glFramebufferTexture3DEXT != 0 &&
        glFramebufferRenderbufferEXT != 0 &&
        glGenerateMipmapEXT != 0;

    if (isGLExtensionSupported(contextID, "GL_EXT_framebuffer_blit"))
    {
        LOAD_FBO_EXT(glBlitFramebufferEXT);

        if (isGLExtensionSupported(contextID, "GL_EXT_framebuffer_multisample"))
        {
            LOAD_FBO_EXT(glRenderbufferStorageMultisampleEXT);
        }
        
        if (isGLExtensionSupported(contextID, "GL_NV_framebuffer_multisample_coverage"))
        {
            LOAD_FBO_EXT(glRenderbufferStorageMultisampleCoverageNV);
        }
    }

    if (isGLExtensionSupported(contextID, "GL_EXT_packed_depth_stencil"))
    {
        _packed_depth_stencil_supported = true;
    }
}


/**************************************************************************
 * RenderBuffer
 **************************************************************************/

{'fraction_non_alphanumeric': 0.1459027315123251, 'fraction_numerical': 0.012658227848101266, 'mean_word_length': 4.906229508196721, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6118035', 'n_tokens_mistral': 2815, 'n_tokens_neox': 2656, 'n_words': 527}