<commit_before>package org.anddev.andengine.opengl;

import java.nio.FloatBuffer;

import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;

import org.anddev.andengine.opengl.buffer.BufferObject;
import org.anddev.andengine.util.Debug;

import android.os.Build;

/**
 * @author <NAME>
 * @since 18:00:43 - 08.03.2010
 */
public class GLHelper {
	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Fields
	// ===========================================================

	private static int mCurrentHardwareBufferID = -1;
	private static int mCurrentHardwareTextureID = -1;
	private static int mCurrentMatrix = -1;

	private static int mCurrentSourceBlendMode = -1;
	private static int mCurrentDestionationBlendMode = -1;

	private static FloatBuffer mCurrentTextureFloatBuffer = null;
	private static FloatBuffer mCurrentVertexFloatBuffer = null;

	private static boolean mEnableDither = true;
	private static boolean mEnableLightning = true;
	private static boolean mEnableDepthTest = true;
	private static boolean mEnableMultisample = true;

	private static boolean mEnableBlend = false;
	private static boolean mEnableTextures = false;
	private static boolean mEnableTexCoordArray = false;
	private static boolean mEnableVertexArray = false;

	public static boolean EXTENSIONS_VERTEXBUFFEROBJECTS = false;
	public static boolean EXTENSIONS_DRAWTEXTURE = false;

	// ===========================================================
	// Methods
	// ===========================================================

	public static void reset(final GL10 pGL) {
		GLHelper.mCurrentHardwareBufferID = -1;
		GLHelper.mCurrentHardwareTextureID = -1;
		GLHelper.mCurrentMatrix = -1;

		GLHelper.mCurrentSourceBlendMode = -1;
		GLHelper.mCurrentDestionationBlendMode = -1;

		GLHelper.mCurrentTextureFloatBuffer = null;
		GLHelper.mCurrentVertexFloatBuffer = null;

		GLHelper.enableDither(pGL);
		GLHelper.enableLightning(pGL);
		GLHelper.enableDepthTest(pGL);
		GLHelper.enableMultisample(pGL);

		GLHelper.disableBlend(pGL);
		GLHelper.disableTextures(pGL);
		GLHelper.disableTexCoordArray(pGL);
		GLHelper.disableVertexArray(pGL);

		GLHelper.EXTENSIONS_VERTEXBUFFEROBJECTS = false;
		GLHelper.EXTENSIONS_DRAWTEXTURE = false;
	}

	public static void enableExtensions(final GL10 pGL) {
		final String version = pGL.glGetString(GL10.GL_VERSION);
		final String renderer = pGL.glGetString(GL10.GL_RENDERER);
		final String extensions = pGL.glGetString(GL10.GL_EXTENSIONS);

		Debug.d("RENDERER: " + renderer);
		Debug.d("VERSION: " + version);
		Debug.d("EXTENSIONS: " + extensions);

		final boolean isOpenGL10 = version.endsWith("1.0");
		final boolean isSoftwareRenderer = renderer.contains("PixelFlinger");
		final boolean isVBOCapable = extensions.contains("_vertex_buffer_object");
		final boolean isDrawTextureCapable = extensions.contains("draw_texture");

		GLHelper.EXTENSIONS_VERTEXBUFFEROBJECTS = !isSoftwareRenderer && (isVBOCapable || !isOpenGL10);
		GLHelper.EXTENSIONS_DRAWTEXTURE  = isDrawTextureCapable;

		GLHelper.hackBrokenDevices();
		Debug.d("EXTENSIONS_VERXTEXBUFFEROBJECTS = " + EXTENSIONS_VERTEXBUFFEROBJECTS);
		Debug.d("EXTENSIONS_DRAWTEXTURE = " + EXTENSIONS_DRAWTEXTURE);
	}

	private static void hackBrokenDevices() {
		if (Build.PRODUCT.contains("morrison")) {
			// This is the Motorola Cliq. This device LIES and says it supports
			// VBOs, which it actually does not (or, more likely, the extensions string
			// is correct and the GL JNI glue is broken).
			GLHelper.EXTENSIONS_VERTEXBUFFEROBJECTS = false;
			// TODO: if Motorola fixes this, I should switch to using the fingerprint
			// (blur/morrison/morrison/morrison:1.5/CUPCAKE/091007:user/ota-rel-keys,release-keys)
			// instead of the product name so that newer versions use VBOs.
		}
	}

	public static void setColor(final GL10 pGL, final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
		pGL.glColor4f(pRed, pGreen, pBlue, pAlpha);
	}

	public static void enableVertexArray(final GL10 pGL) {<commit_msg>Just acommit on the default-branch to check if merging is working,<commit_after>package org.anddev.andengine.opengl;

import java.nio.FloatBuffer;

import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;

import org.anddev.andengine.opengl.buffer.BufferObject;
import org.anddev.andengine.util.Debug;

import android.os.Build;

/**
 * @author <NAME>
 * @since 18:00:43 - 08.03.2010
 */
public class GLHelper {
	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Fields
	// ===========================================================

	private static int mCurrentHardwareBufferID = -1;
	private static int mCurrentHardwareTextureID = -1;
	private static int mCurrentMatrix = -1;

	private static int mCurrentSourceBlendMode = -1;
	private static int mCurrentDestionationBlendMode = -1;

	private static FloatBuffer mCurrentTextureFloatBuffer = null;
	private static FloatBuffer mCurrentVertexFloatBuffer = null;

	private static boolean mEnableDither = true;
	private static boolean mEnableLightning = true;
	private static boolean mEnableDepthTest = true;
	private static boolean mEnableMultisample = true;

	private static boolean mEnableBlend = false;
	private static boolean mEnableTextures = false;
	private static boolean mEnableTexCoordArray = false;
	private static boolean mEnableVertexArray = false;

	public static boolean EXTENSIONS_VERTEXBUFFEROBJECTS = false;
	public static boolean EXTENSIONS_DRAWTEXTURE = false;

	// ===========================================================
	// Methods
	// ===========================================================

	public static void reset(final GL10 pGL) {
		GLHelper.mCurrentHardwareBufferID = -1;
		GLHelper.mCurrentHardwareTextureID = -1;
		GLHelper.mCurrentMatrix = -1;

		GLHelper.mCurrentSourceBlendMode = -1;
		GLHelper.mCurrentDestionationBlendMode = -1;

		GLHelper.mCurrentTextureFloatBuffer = null;
		GLHelper.mCurrentVertexFloatBuffer = null;

		GLHelper.enableDither(pGL);
		GLHelper.enableLightning(pGL);
		GLHelper.enableDepthTest(pGL);
		GLHelper.enableMultisample(pGL);

		GLHelper.disableBlend(pGL);
		GLHelper.disableTextures(pGL);
		GLHelper.disableTexCoordArray(pGL);
		GLHelper.disableVertexArray(pGL);

		GLHelper.EXTENSIONS_VERTEXBUFFEROBJECTS = false;
		GLHelper.EXTENSIONS_DRAWTEXTURE = false;
	}

	public static void enableExtensions(final GL10 pGL) {
		final String version = pGL.glGetString(GL10.GL_VERSION);
		final String renderer = pGL.glGetString(GL10.GL_RENDERER);
		final String extensions = pGL.glGetString(GL10.GL_EXTENSIONS);

		Debug.d("RENDERER: " + renderer);
		Debug.d("VERSION: " + version);
		Debug.d("EXTENSIONS: " + extensions);

		final boolean isOpenGL10 = version.endsWith("1.0");
		final boolean isSoftwareRenderer = renderer.contains("PixelFlinger");
		final boolean isVBOCapable = extensions.contains("_vertex_buffer_object");
		final boolean isDrawTextureCapable = extensions.contains("draw_texture");

		GLHelper.EXTENSIONS_VERTEXBUFFEROBJECTS = !isSoftwareRenderer && (isVBOCapable || !isOpenGL10);
		GLHelper.EXTENSIONS_DRAWTEXTURE  = isDrawTextureCapable;

		GLHelper.hackBrokenDevices();
		Debug.d("EXTENSIONS_VERXTEXBUFFEROBJECTS = " + EXTENSIONS_VERTEXBUFFEROBJECTS);
		Debug.d("EXTENSIONS_DRAWTEXTURE = " + EXTENSIONS_DRAWTEXTURE);
	}

	private static void hackBrokenDevices() {
		if (Build.PRODUCT.contains("morrison")) {
			// This is the Motorola Cliq. This device LIES and says it supports
			// VBOs, which it actually does not (or, more likely, the extensions string
			// is correct and the GL JNI glue is broken).
			GLHelper.EXTENSIONS_VERTEXBUFFEROBJECTS = false;
			// TODO: if Motorola fixes this, I should switch to using the fingerprint
			// (blur/morrison/morrison/morrison:1.5/CUPCAKE/091007:user/ota-rel-keys,release-keys)
			// instead of the product name so that newer versions use VBOs
		}
	}

	public static void setColor(final GL10 pGL, final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
		pGL.glColor4f(pRed, pGreen, pBlue, pAlpha);
	}

	public static void enableVertexArray(final GL10 pGL) {
{'fraction_non_alphanumeric': 0.16792541892848714, 'fraction_numerical': 0.013452914798206279, 'mean_word_length': 5.444866920152092, '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': '4503149', 'n_tokens_mistral': 2805, 'n_tokens_neox': 2533, 'n_words': 582}