<commit_before>/**
 * projectM -- Milkdrop-esque visualisation SDK
 * Copyright (C)2003-2004 projectM Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * 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 GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * See 'LICENSE.txt' included within this release
 *
 */
/**
 * $Id: pbuffer.c,v 1.1.1.1 2005/12/23 18:05:00 psperl Exp $
 *
 * Render target methods
 */

#include <stdio.h>
//#include <GL/gl.h>

#include "common.h"
#include "pbuffer.h"

#ifdef MACOS
#include <agl.h>
#endif /** MACOS */

/** Creates new pbuffers */
void createPBuffers( int width, int height, RenderTarget *target ) {

    int mindim = 0;
    int origtexsize = 0;

#ifdef USE_FBO
    DWRITE( "FBO init: usePbuffers: %d\n", target->usePbuffers );
    if(target->usePbuffers) {
	    glewInit();
	
	    GLuint   fb, color_rb, depth_rb, rgba_tex, depth_tex, i, other_tex;
	    glGenFramebuffersEXT(1, &fb);
	    glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fb );
	
	    glGenRenderbuffersEXT(1, &depth_rb);
	    glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depth_rb );
	    glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, target->texsize,target->texsize  );
	    glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb );         
	    target->fbuffer[0] = depth_rb;
    	
	    glGenTextures(1, &other_tex);
	    glBindTexture(GL_TEXTURE_2D,other_tex);
 	    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, target->texsize, target->texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
	    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	    //glGenerateMipmapEXT(GL_TEXTURE_2D);
	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    
    
    	
	    glGenTextures(1, &rgba_tex);
	    glBindTexture(GL_TEXTURE_2D, rgba_tex); 
	    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, target->texsize, target->texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	    //glGenerateMipmapEXT(GL_TEXTURE_2D);
	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    
    
    	
	    glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, rgba_tex, 0 );         
	    target->textureID[0] = rgba_tex;
	    target->textureID[1] = other_tex; 
    
	    GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
	    if (status == GL_FRAMEBUFFER_COMPLETE_EXT) {
	        return;
	      } 
      }
#endif

fallback:
    DWRITE( "using teximage hack fallback\n" );
<commit_msg>Added runtime check for presence of FBO in OpenGL drivers<commit_after>/**
 * projectM -- Milkdrop-esque visualisation SDK
 * Copyright (C)2003-2004 projectM Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * 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 GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * See 'LICENSE.txt' included within this release
 *
 */
/**
 * $Id: pbuffer.c,v 1.1.1.1 2005/12/23 18:05:00 psperl Exp $
 *
 * Render target methods
 */

#include <stdio.h>
//#include <GL/gl.h>

#include "common.h"
#include "pbuffer.h"

#ifdef MACOS
#include <agl.h>
#endif /** MACOS */

/** Creates new pbuffers */
void createPBuffers( int width, int height, RenderTarget *target ) {

    int mindim = 0;
    int origtexsize = 0;

#ifdef USE_FBO
    DWRITE( "FBO init: usePbuffers: %d\n", target->usePbuffers );
    if(target->usePbuffers) {
	    if ( glewInit() == GLEW_OK ) {
    	    DWRITE( "FBO: glewInit() OK\n" );

            /** Check for the extensions we need */
            if ( GLEW_EXT_framebuffer_object ) {
        	    DWRITE( "FBO: locate EXT_framebuffer_object\n" );
        	    GLuint   fb, color_rb, depth_rb, rgba_tex, depth_tex, i, other_tex;
	            glGenFramebuffersEXT(1, &fb);
	            glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fb );
	
        	    glGenRenderbuffersEXT(1, &depth_rb);
        	    glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depth_rb );
        	    glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, target->texsize,target->texsize  );
        	    glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb );         
        	    target->fbuffer[0] = depth_rb;
            	
        	    glGenTextures(1, &other_tex);
        	    glBindTexture(GL_TEXTURE_2D,other_tex);
         	    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, target->texsize, target->texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
        	    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        	    //glGenerateMipmapEXT(GL_TEXTURE_2D);
        	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
        	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
            
            
            	
        	    glGenTextures(1, &rgba_tex);
        	    glBindTexture(GL_TEXTURE_2D, rgba_tex); 
        	    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        	    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, target->texsize, target->texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
        	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        	    //glGenerateMipmapEXT(GL_TEXTURE_2D);
        	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
        	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
            
        	    glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, rgba_tex, 0 );         
        	    target->textureID[0] = rgba_tex;
        	    target->textureID[1] = other_tex; 
            
        	    GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
        	    if (status == GL_FRAMEBUFFER_COMPLETE_EXT) {
        	        return;
        	      } 
              } else {
                DWRITE( "FBO: Cannot locate EXT_framebuffer_object\n" );
              }
          }
      }
#endif

    DWRITE( "using teximage hack fallback\n" );

{'fraction_non_alphanumeric': 0.09124570219518646, 'fraction_numerical': 0.02089394340121661, 'mean_word_length': 3.169239250275634, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6178524', 'n_tokens_mistral': 2758, 'n_tokens_neox': 2562, 'n_words': 609}