<commit_before>/*
 * Copyright (c) 2004, jMonkeyEngine - Mojo Monkey Coding
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the
 * names of its contributors may be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
package com.jme.renderer;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;

import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.scene.Spatial;
import com.jme.util.LoggingSystem;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.Pbuffer;
import org.lwjgl.opengl.RenderTexture;
import org.lwjgl.opengl.Window;

/**
 * @author <NAME>
 * @version $Id: LWJGLTextureRenderer.java,v 1.9 2004-03-06 08:25:39 renanse Exp $
 */
public class LWJGLTextureRenderer implements TextureRenderer {

    private LWJGLCamera camera;
    private ColorRGBA backgroundColor = new ColorRGBA(1,1,1,1);

    private int PBUFFER_WIDTH = 256;
    private int PBUFFER_HEIGHT = 256;

    /** Pbuffer instance */
    private Pbuffer pbuffer;
    private int active = 0;
    private boolean useDirectRender = false;

    private LWJGLRenderer parentRenderer;
    private RenderTexture texture;

    public LWJGLTextureRenderer(LWJGLRenderer parentRenderer) {
        this(parentRenderer, null);
    }

    public LWJGLTextureRenderer(LWJGLRenderer parentRenderer, RenderTexture texture) {
        if (!isSupported()) {
            System.err.println("No Pbuffer support!");
            System.exit(1);  // Clean this up?
        }
        if (Pbuffer.RENDER_TEXTURE_SUPPORTED != 0) {
            System.err.println("Render to Texture Pbuffer supported!");
            if (texture == null)
                System.err.println("No RenderTexture used in init, falling back to Copy Texture PBuffer.");
            else useDirectRender = true;
        } else if (Pbuffer.PBUFFER_SUPPORTED != 0)
            System.err.println("Copy Texture Pbuffer supported!");

        this.parentRenderer = parentRenderer;
        this.texture = texture;
        initPbuffer();
    }

    public static boolean isSupported() { // Perhaps we should move this to Renderer?
        if ((Pbuffer.getPbufferCaps() & Pbuffer.PBUFFER_SUPPORTED) == 0)
            return false;

        return true;
    }

    /**
     * <code>getCamera</code> retrieves the camera this renderer is using.
     * @return the camera this renderer is using.
     */
    public Camera getCamera() {
        return camera;
    }

    /**
     * <code>setBackgroundColor</code> sets the OpenGL clear color to the
     * color specified.
     *
     * @see com.jme.renderer.TextureRenderer#setBackgroundColor(com.jme.renderer.ColorRGBA)
     * @param c
     *            the color to set the background color to.
     */
    public void setBackgroundColor(ColorRGBA c) {
        //if color is null set background to white.
        if (c == null) {<commit_msg>no message<commit_after>/*
 * Copyright (c) 2004, jMonkeyEngine - Mojo Monkey Coding
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the
 * names of its contributors may be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
package com.jme.renderer;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;

import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.scene.Spatial;
import com.jme.util.LoggingSystem;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.Pbuffer;
import org.lwjgl.opengl.RenderTexture;
import org.lwjgl.opengl.Window;

/**
 * @author <NAME>
 * @version $Id: LWJGLTextureRenderer.java,v 1.10 2004-03-08 16:59:04 renanse Exp $
 */
public class LWJGLTextureRenderer implements TextureRenderer {

    private LWJGLCamera camera;
    private ColorRGBA backgroundColor = new ColorRGBA(1,1,1,1);

    private int PBUFFER_WIDTH = 256;
    private int PBUFFER_HEIGHT = 256;

    /** Pbuffer instance */
    private Pbuffer pbuffer;
    private int active, caps;
    private boolean useDirectRender = false;

    private LWJGLRenderer parentRenderer;
    private RenderTexture texture;

    public LWJGLTextureRenderer(LWJGLRenderer parentRenderer) {
        this(parentRenderer, null);
    }

    public LWJGLTextureRenderer(LWJGLRenderer parentRenderer, RenderTexture texture) {
        caps = Pbuffer.getPbufferCaps();

        if (((caps & Pbuffer.PBUFFER_SUPPORTED) == 0)) {
            System.err.println("No Pbuffer support!");
            System.exit(1);  // Clean this up?
        }

        if ((caps & Pbuffer.RENDER_TEXTURE_SUPPORTED) != 0) {
            System.err.println("Render to Texture Pbuffer supported!");
            if (texture == null)
                System.err.println("No RenderTexture used in init, falling back to Copy Texture PBuffer.");
            else useDirectRender = true;
        } else {
            System.err.println("Copy Texture Pbuffer supported!");
            texture = null;
        }

        this.parentRenderer = parentRenderer;
        this.texture = texture;
        initPbuffer();
    }

    /**
     * <code>getCamera</code> retrieves the camera this renderer is using.
     * @return the camera this renderer is using.
     */
    public Camera getCamera() {
        return camera;
    }

    /**
     * <code>setBackgroundColor</code> sets the OpenGL clear color to the
     * color specified.
     *
     * @see com.jme.renderer.TextureRenderer#setBackgroundColor(com.jme.renderer.ColorRGBA)
     * @param c
     *            the color to set the background color to.
     */
    public void setBackgroundColor(ColorRGBA c) {
        //if color is null set background to white.
        if (c == null) {
{'fraction_non_alphanumeric': 0.07911354700345526, 'fraction_numerical': 0.008936018110330037, 'mean_word_length': 3.243680485338726, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5705823', 'n_tokens_mistral': 2429, 'n_tokens_neox': 2249, 'n_words': 856}