package com.jukusoft.renderer2d.prototyp.gamestate;

import com.jukusoft.renderer2d.prototyp.engine.app.GameApp;
import com.jukusoft.renderer2d.prototyp.engine.gamestate.GameState;
import com.jukusoft.renderer2d.prototyp.engine.gamestate.GameStateManager;
import com.jukusoft.renderer2d.prototyp.engine.gamestate.impl.BasicGameState;
import com.jukusoft.renderer2d.prototyp.engine.opengl.buffer.FloatVertexBufferObject;
import com.jukusoft.renderer2d.prototyp.engine.shader.OpenGLShaderProgram;
import com.jukusoft.renderer2d.prototyp.engine.utils.FileUtils;
import org.apache.log4j.Logger;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
import static org.lwjgl.opengl.GL11.glDrawArrays;

/**
 * Created by Justin on 25.08.2016.
 */
public class GameState3 extends BasicGameState {

    @Override
    public <T extends GameState> void onInit(GameStateManager<T> gameStateManager, GameApp app) {
        Logger.getRootLogger().info("GameState3::onInit().");

        getWindow().setClearColor(0, 0, 0, 0);
    }

    @Override
    public void render (GameApp app) {
        getWindow().clear();

        if (getWindow().wasResized()) {
            getWindow().setViewPort(0, 0, getWindow().getWidth(), getWindow().getHeight());
            getWindow().setResizedFlag(false);
        }

        //TODO: render
    }

}

@@ -319,32 +319,231 @@
 BasicGameState;%0A
+import com.jukusoft.renderer2d.prototyp.engine.math.Vector3f;%0Aimport com.jukusoft.renderer2d.prototyp.engine.mesh.data.GPUTriangle;%0Aimport com.jukusoft.renderer2d.prototyp.engine.mesh.data.Triangle;%0A
 import com.jukus
@@ -1058,175 +1058,1259 @@
     
-@Override%0A    public %3CT extends GameState%3E void onInit(GameStateManager%3CT%3E gameStateManager, GameApp app) %7B%0A        Logger.getRootLogger().info(%22GameState3::onInit().%22
+/**%0A    * triangle on gpu%0A    */%0A    protected GPUTriangle gpuTriangle = null;%0A%0A    /**%0A     * instance of shader program%0A     */%0A    protected OpenGLShaderProgram shaderProgram = null;%0A%0A    @Override%0A    public %3CT extends GameState%3E void onInit(GameStateManager%3CT%3E gameStateManager, GameApp app) %7B%0A        Logger.getRootLogger().info(%22GameState3::onInit().%22);%0A%0A        //create new shader program%0A        this.shaderProgram = new OpenGLShaderProgram();%0A%0A        try %7B%0A            //add vertex shader%0A            this.shaderProgram.setVertexShader(FileUtils.readFile(%22./data/shader/vertex.vs%22, StandardCharsets.UTF_8));%0A%0A            //add fragment shader%0A            this.shaderProgram.setFragmentShader(FileUtils.readFile(%22./data/shader/fragment.fs%22, StandardCharsets.UTF_8));%0A%0A            //link shader program%0A            this.shaderProgram.link();%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A            System.exit(1);%0A        %7D%0A%0A        //create new triangle%0A        Triangle triangle = new Triangle(new Vector3f(0.0f, 0.5f, 0.0f), new Vector3f(-0.5f, -0.5f, 0.0f), new Vector3f(0.5f, -0.5f, 0.0f));%0A        this.gpuTriangle = new GPUTriangle(triangle);%0A%0A        //initialize triangle on gpu%0A        this.gpuTriangle.init(
 );%0A%0A
@@ -2650,20 +2650,194 @@
   //
-TODO: render
+bind shader program%0A        this.shaderProgram.bind();%0A%0A        //render triangle%0A        this.gpuTriangle.render();%0A%0A        //unbind shader program%0A        this.shaderProgram.unbind();
 %0A   

change GameState3, added support to easy draw an triangle.