<commit_before>package com.jukusoft.rpg.graphic.opengl.mesh;

import com.jukusoft.rpg.core.logger.GameLogger;
import com.jukusoft.rpg.graphic.opengl.buffer.FloatVertexBufferObject;
import com.jukusoft.rpg.graphic.opengl.buffer.IntegerVertexBufferObject;
import com.jukusoft.rpg.graphic.opengl.buffer.VertexArrayObject;
import com.jukusoft.rpg.graphic.opengl.texture.OpenGL2DTexture;

import java.util.ArrayList;
import java.util.List;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
import static org.lwjgl.opengl.GL13.glActiveTexture;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.glDisableVertexAttribArray;
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
import static org.lwjgl.opengl.GL30.glBindVertexArray;

/**
 * Created by Justin on 30.11.2016.
 */
public class Mesh {

    /**
     * vertex buffer objects
     */
    protected FloatVertexBufferObject positionVBO = null;
    protected FloatVertexBufferObject textureCoordinatesVBO = null;
    protected FloatVertexBufferObject vertexNormalsVBO = null;
    protected IntegerVertexBufferObject indexVBO = null;

    protected Material material = null;

    /**
     * vertex array object
     */
    protected VertexArrayObject vao = new VertexArrayObject();

    protected int vertexCount = 0;

    public Mesh(float[] positions, float[] textCoords, float[] normals, int[] indices) {
        //get vertex count
        vertexCount = indices.length;

        //bind vertex array object
        vao.bind();

        //add position VBO
        this.setPositionVBO(positions);

        //add texture coordinates VBO
        this.setTextureCoordinatesVBO(textCoords);

        //add normals VBO
        this.setNormalesVBO(normals);

        //add indix VBO
        this.setIndexVBO(indices);

        //unbind vertex array object
        vao.unbind();
    }

    public void setPositionVBO (float[] positions) {
        if (this.positionVBO == null) {
            this.positionVBO = new FloatVertexBufferObject(GL_ARRAY_BUFFER);
        }

        //bind VBO
        this.positionVBO.bind();

        //put data
        this.positionVBO.putData(positions);

        //define structure for 3d object
        this.positionVBO.defineStructure(0, 3, false, 0, 0);

        //unbind VBO
        this.positionVBO.unbind();
    }

    public void setTextureCoordinatesVBO (float[] textCoords) {<commit_msg>changed Mesh, set GL_DYNAMIC_DRAW for positions VBO.<commit_after>package com.jukusoft.rpg.graphic.opengl.mesh;

import com.jukusoft.rpg.core.logger.GameLogger;
import com.jukusoft.rpg.graphic.opengl.buffer.FloatVertexBufferObject;
import com.jukusoft.rpg.graphic.opengl.buffer.IntegerVertexBufferObject;
import com.jukusoft.rpg.graphic.opengl.buffer.VertexArrayObject;
import com.jukusoft.rpg.graphic.opengl.texture.OpenGL2DTexture;

import java.util.ArrayList;
import java.util.List;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
import static org.lwjgl.opengl.GL13.glActiveTexture;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.glDisableVertexAttribArray;
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
import static org.lwjgl.opengl.GL30.glBindVertexArray;

/**
 * Created by Justin on 30.11.2016.
 */
public class Mesh {

    /**
     * vertex buffer objects
     */
    protected FloatVertexBufferObject positionVBO = null;
    protected FloatVertexBufferObject textureCoordinatesVBO = null;
    protected FloatVertexBufferObject vertexNormalsVBO = null;
    protected IntegerVertexBufferObject indexVBO = null;

    protected Material material = null;

    /**
     * vertex array object
     */
    protected VertexArrayObject vao = new VertexArrayObject();

    protected int vertexCount = 0;

    public Mesh(float[] positions, float[] textCoords, float[] normals, int[] indices) {
        //get vertex count
        vertexCount = indices.length;

        //bind vertex array object
        vao.bind();

        //add position VBO
        this.setPositionVBO(positions);

        //add texture coordinates VBO
        this.setTextureCoordinatesVBO(textCoords);

        //add normals VBO
        this.setNormalesVBO(normals);

        //add indix VBO
        this.setIndexVBO(indices);

        //unbind vertex array object
        vao.unbind();
    }

    public void setPositionVBO (float[] positions) {
        if (this.positionVBO == null) {
            this.positionVBO = new FloatVertexBufferObject(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW);
        }

        //bind VBO
        this.positionVBO.bind();

        //put data
        this.positionVBO.putData(positions);

        //define structure for 3d object
        this.positionVBO.defineStructure(0, 3, false, 0, 0);

        //unbind VBO
        this.positionVBO.unbind();
    }

    public void setTextureCoordinatesVBO (float[] textCoords) {
{'fraction_non_alphanumeric': 0.09587137753076617, 'fraction_numerical': 0.013100436681222707, 'mean_word_length': 3.126945126945127, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7663376', 'n_tokens_mistral': 1674, 'n_tokens_neox': 1595, 'n_words': 325}