<commit_before>package net.drewke.tdme.engine.subsystems.renderer;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

import net.drewke.tdme.engine.Engine;
import net.drewke.tdme.engine.fileio.textures.Texture;
import net.drewke.tdme.math.Matrix4x4;

import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLES2;

/**
 * OpenGL ES2 renderer
 * @author <NAME>
 * @version $Id$
 */
public abstract class GLES2Renderer extends GLRenderer {

	private GLES2 gl;

	/**
	 * final public constructor
	 */
	public GLES2Renderer() {
		// setup GLES2 consts
		ID_NONE = 0;

		CLEAR_DEPTH_BUFFER_BIT = GLES2.GL_DEPTH_BUFFER_BIT;
		CLEAR_COLOR_BUFFER_BIT = GLES2.GL_COLOR_BUFFER_BIT;
		CULLFACE_FRONT = GLES2.GL_FRONT;

		CULLFACE_BACK = GLES2.GL_BACK;

		CLIENTSTATE_TEXTURECOORD_ARRAY = 2;
		CLIENTSTATE_VERTEX_ARRAY = 0;
		CLIENTSTATE_NORMAL_ARRAY = 1;
		CLIENTSTATE_COLOR_ARRAY = 3;

		SHADER_FRAGMENT_SHADER = GLES2.GL_FRAGMENT_SHADER;
		SHADER_VERTEX_SHADER = GLES2.GL_VERTEX_SHADER;

		DEPTHFUNCTION_LESSEQUAL = GLES2.GL_LEQUAL;
		DEPTHFUNCTION_EQUAL = GLES2.GL_EQUAL;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#setGL(javax.media.opengl.GLES2)
	 */
	final public void setGL(GL gl) {
		this.gl = (GLES2)gl;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#getGLVersion()
	 */
	final public String getGLVersion() {
		return "gles2";
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#init()
	 */
	final public void init() {
		gl.glGetError();
		// get default framebuffer
		FRAMEBUFFER_DEFAULT = gl.getContext().getDefaultDrawFramebuffer();
		// setup open gl
		gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);						// Black Background
		gl.glClearDepthf(1.0f); 											// Depth Buffer Setup
		gl.glEnable(GLES2.GL_DEPTH_TEST); 								// Enables Depth Testing
		gl.glFrontFace(GLES2.GL_CCW);										// Triangles are in counter clockwise order
		gl.glEnable(GLES2.GL_CULL_FACE);									// The Type Of Depth Testing To Do
		gl.glDepthFunc(GLES2.GL_LEQUAL);
		gl.glEnable(GLES2.GL_TEXTURE_2D);									// enable texture 2d
		gl.glBlendFunc(GLES2.GL_SRC_ALPHA, GLES2.GL_ONE_MINUS_SRC_ALPHA);  // enable alpha transparency
		gl.glBlendEquation(GLES2.GL_FUNC_ADD);
		gl.glDisable(GLES2.GL_BLEND);
		// TODO: gl.glPointSize(5f);
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#initFrame()
	 */
	final public void initFrame() {
		if (gl.getContext().isCurrent() == false) gl.getContext().makeCurrent();
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#isBufferObjectsAvailable()
	 */
	final public boolean isBufferObjectsAvailable() {
		return true;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.subsystems.renderer.GLRenderer#isUsingProgramAttributeLocation()
	 */
	final public boolean isUsingProgramAttributeLocation() {
		return true;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.subsystems.renderer.GLRenderer#isSpecularMappingAvailable()
	 */
	final public boolean isSpecularMappingAvailable() {
		return false;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.subsystems.renderer.GLRenderer#isNormalMappingAvailable()
	 */
	final public boolean isNormalMappingAvailable() {
		return true;
	}

	/**
	 * @return if displacement mapping is supported
	 */
	final public boolean isDisplacementMappingAvailable() {
		return true;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.subsystems.renderer.GLRenderer#isSkinningAvailable()
	 */
	final public boolean isSkinningAvailable() {
		return true;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#getTextureUnits()
	 */
	final public int getTextureUnits() {
		// check for number of texture units
		return -1;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#loadShader(int, java.lang.String, java.lang.String)
	 */
	final public int loadShader(int type, String pathName, String fileName) {
		// create shader
		int handle = gl.glCreateShader(type);

		// exit if no handle returned
		if (handle == 0) return 0;
<commit_msg>renderer::GLES2 renderer does not support normal mapping, displacement mapping<commit_after>package net.drewke.tdme.engine.subsystems.renderer;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

import net.drewke.tdme.engine.Engine;
import net.drewke.tdme.engine.fileio.textures.Texture;
import net.drewke.tdme.math.Matrix4x4;

import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLES2;

/**
 * OpenGL ES2 renderer
 * @author <NAME>
 * @version $Id$
 */
public abstract class GLES2Renderer extends GLRenderer {

	private GLES2 gl;

	/**
	 * final public constructor
	 */
	public GLES2Renderer() {
		// setup GLES2 consts
		ID_NONE = 0;

		CLEAR_DEPTH_BUFFER_BIT = GLES2.GL_DEPTH_BUFFER_BIT;
		CLEAR_COLOR_BUFFER_BIT = GLES2.GL_COLOR_BUFFER_BIT;
		CULLFACE_FRONT = GLES2.GL_FRONT;

		CULLFACE_BACK = GLES2.GL_BACK;

		CLIENTSTATE_TEXTURECOORD_ARRAY = 2;
		CLIENTSTATE_VERTEX_ARRAY = 0;
		CLIENTSTATE_NORMAL_ARRAY = 1;
		CLIENTSTATE_COLOR_ARRAY = 3;

		SHADER_FRAGMENT_SHADER = GLES2.GL_FRAGMENT_SHADER;
		SHADER_VERTEX_SHADER = GLES2.GL_VERTEX_SHADER;

		DEPTHFUNCTION_LESSEQUAL = GLES2.GL_LEQUAL;
		DEPTHFUNCTION_EQUAL = GLES2.GL_EQUAL;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#setGL(javax.media.opengl.GLES2)
	 */
	final public void setGL(GL gl) {
		this.gl = (GLES2)gl;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#getGLVersion()
	 */
	final public String getGLVersion() {
		return "gles2";
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#init()
	 */
	final public void init() {
		gl.glGetError();
		// get default framebuffer
		FRAMEBUFFER_DEFAULT = gl.getContext().getDefaultDrawFramebuffer();
		// setup open gl
		gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);						// Black Background
		gl.glClearDepthf(1.0f); 											// Depth Buffer Setup
		gl.glEnable(GLES2.GL_DEPTH_TEST); 								// Enables Depth Testing
		gl.glFrontFace(GLES2.GL_CCW);										// Triangles are in counter clockwise order
		gl.glEnable(GLES2.GL_CULL_FACE);									// The Type Of Depth Testing To Do
		gl.glDepthFunc(GLES2.GL_LEQUAL);
		gl.glEnable(GLES2.GL_TEXTURE_2D);									// enable texture 2d
		gl.glBlendFunc(GLES2.GL_SRC_ALPHA, GLES2.GL_ONE_MINUS_SRC_ALPHA);  // enable alpha transparency
		gl.glBlendEquation(GLES2.GL_FUNC_ADD);
		gl.glDisable(GLES2.GL_BLEND);
		// TODO: gl.glPointSize(5f);
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#initFrame()
	 */
	final public void initFrame() {
		if (gl.getContext().isCurrent() == false) gl.getContext().makeCurrent();
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#isBufferObjectsAvailable()
	 */
	final public boolean isBufferObjectsAvailable() {
		return true;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.subsystems.renderer.GLRenderer#isUsingProgramAttributeLocation()
	 */
	final public boolean isUsingProgramAttributeLocation() {
		return true;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.subsystems.renderer.GLRenderer#isSpecularMappingAvailable()
	 */
	final public boolean isSpecularMappingAvailable() {
		return false;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.subsystems.renderer.GLRenderer#isNormalMappingAvailable()
	 */
	final public boolean isNormalMappingAvailable() {
		return false;
	}

	/**
	 * @return if displacement mapping is supported
	 */
	final public boolean isDisplacementMappingAvailable() {
		return false;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.subsystems.renderer.GLRenderer#isSkinningAvailable()
	 */
	final public boolean isSkinningAvailable() {
		return true;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#getTextureUnits()
	 */
	final public int getTextureUnits() {
		// check for number of texture units
		return -1;
	}

	/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.engine.GLRenderer#loadShader(int, java.lang.String, java.lang.String)
	 */
	final public int loadShader(int type, String pathName, String fileName) {
		// create shader
		int handle = gl.glCreateShader(type);

		// exit if no handle returned
		if (handle == 0) return 0;

{'fraction_non_alphanumeric': 0.12313906520484709, 'fraction_numerical': 0.011425274091171379, 'mean_word_length': 3.8988128886376483, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4153834', 'n_tokens_mistral': 3524, 'n_tokens_neox': 3179, 'n_words': 552}