<commit_before>/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package playn.java;

import java.io.UnsupportedEncodingException;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

import org.lwjgl.BufferUtils;
import org.lwjgl.MemoryUtil;
import org.lwjgl.opengl.EXTFramebufferObject;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
import org.lwjgl.opengl.GL41;

/**
 * An implementation of the {@link GL20} interface based on Jogl. Note that Jogl
 * shaders and OpenGL ES shaders will not be 100% compatible. Some glGetXXX
 * methods are not implemented.
 *
 * Based on LIBGDX code by mzechner. Some code from LWJGL's GLES20.java
 *
 * @author mzechner
 */
final class JavaGL20 implements playn.core.gl.GL20 {

  // Sizes based on LWJGL's APIUtil
  private IntBuffer intBuffer = BufferUtils.createIntBuffer(32);
  private FloatBuffer floatBuffer = BufferUtils.createFloatBuffer(32);
  private ByteBuffer byteBuffer = BufferUtils.createByteBuffer(256);

  private void setIntBuffer(final int[] source, final int offset, final int length) {
    resizeByteBuffer(length);
    intBuffer.put(source, offset, length);
    intBuffer.rewind();
  }

  private void setFloatBuffer(final float[] source, final int offset, final int length) {
    resizeFloatBuffer(length);
    floatBuffer.put(source, offset, length);
    floatBuffer.rewind();
  }

  private void setByteBuffer(final byte[] source, final int offset, final int length) {
    resizeByteBuffer(length);
    byteBuffer.put(source, offset, length);
    byteBuffer.rewind();
  }

  private void resizeByteBuffer(final int length) {<commit_msg>Resize using the right data type.<commit_after>/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package playn.java;

import java.io.UnsupportedEncodingException;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

import org.lwjgl.BufferUtils;
import org.lwjgl.MemoryUtil;
import org.lwjgl.opengl.EXTFramebufferObject;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
import org.lwjgl.opengl.GL41;

/**
 * An implementation of the {@link GL20} interface based on Jogl. Note that Jogl
 * shaders and OpenGL ES shaders will not be 100% compatible. Some glGetXXX
 * methods are not implemented.
 *
 * Based on LIBGDX code by mzechner. Some code from LWJGL's GLES20.java
 *
 * @author mzechner
 */
final class JavaGL20 implements playn.core.gl.GL20 {

  // Sizes based on LWJGL's APIUtil
  private IntBuffer intBuffer = BufferUtils.createIntBuffer(32);
  private FloatBuffer floatBuffer = BufferUtils.createFloatBuffer(32);
  private ByteBuffer byteBuffer = BufferUtils.createByteBuffer(256);

  private void setIntBuffer(final int[] source, final int offset, final int length) {
    resizeIntBuffer(length);
    intBuffer.put(source, offset, length);
    intBuffer.rewind();
  }

  private void setFloatBuffer(final float[] source, final int offset, final int length) {
    resizeFloatBuffer(length);
    floatBuffer.put(source, offset, length);
    floatBuffer.rewind();
  }

  private void setByteBuffer(final byte[] source, final int offset, final int length) {
    resizeByteBuffer(length);
    byteBuffer.put(source, offset, length);
    byteBuffer.rewind();
  }

  private void resizeByteBuffer(final int length) {
{'fraction_non_alphanumeric': 0.14498567335243553, 'fraction_numerical': 0.016045845272206302, 'mean_word_length': 4.772877618522602, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7129082', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1516, 'n_words': 487}