Commits

John Marsden committed dd422b5

Adding Color to Shader

  • Participants
  • Parent commits 41589c3

Comments (0)

Files changed (7)

File src/main/java/cc/plural/ecs/engine/Engine.java

     }
 
     public void update(float delta) {
-        for (int i = 0; i < objects.size(); i++) {
-            GameObject object = objects.get(i);
+        for (GameObject object : objects) {
             if (!object.hasParent()) {
                 object.update(delta);
             }
 
     public void render(Renderer renderer) {
         renderer.startRender();
-        for (int i = 0; i < objects.size(); i++) {
-            GameObject object = objects.get(i);
+        for (GameObject object : objects) {
             object.render(renderer);
         }
         renderer.completeRender();

File src/main/java/cc/plural/ecs/provider/LWJGLRenderer.java

         projection.load(projectionMatrix);
     }
 
+    public Color getBackgroundColor() {
+        return backgroundColor;
+    }
+
+    public void setBackgroundColor(Color backgroundColor) {
+        this.backgroundColor = backgroundColor;
+    }
+
     public GLVersion getGLVersion() {
         if (display != null) {
             return display.glVersion;

File src/main/java/cc/plural/ecs/provider/LWJGLRendererGL15.java

 
 import cc.plural.ecs.engine.GameObject;
 import cc.plural.ecs.renderer.Shader;
+import java.net.URL;
 import org.apache.log4j.LogManager;
 import org.lwjgl.opengl.GL11;
 
         throw new UnsupportedOperationException("Not supported on 1.5");
     }
 
+    public Shader createShader(URL vertexURL, URL fragmentURL) {
+        throw new UnsupportedOperationException("Not supported on 1.5");
+    }
+
     @Override
     public void releaseShader(Shader shader) {
         throw new UnsupportedOperationException("Not supported on 1.5");
     public Shader createDefaultShader(String vertexSource, String fragmentSource) {
         throw new UnsupportedOperationException("Not supported on 1.5");
     }
+    
+    @Override
+    public Shader createDefaultShader(URL vertexURL, URL fragmentURL) {
+        throw new UnsupportedOperationException("Not supported on 1.5");
+    }
 
     @Override
     public Shader getDefaultShader() {
                     continue;
                 }
 
-
             }
         }
     }

File src/main/java/cc/plural/ecs/provider/LWJGLRendererGL2.java

 import cc.plural.ecs.renderer.Uniform;
 import cc.plural.math.Transformation;
 import cc.plural.utils.MatrixPrinter;
+import java.net.URL;
 import org.lwjgl.opengl.GL11;
 import org.lwjgl.opengl.GL13;
 import org.lwjgl.opengl.GL20;
         return new StringLWJGLShader(vertexSource, fragmentSource);
     }
 
+    public StringLWJGLShader createShader(URL vertexURL, URL fragmentURL) {
+        return new StringLWJGLShader(ClassLoader.class.getResource("/assets/shaders/vertexDefault130.glsl"),
+                ClassLoader.class.getResource("/assets/shaders/fragmentDefault130.glsl"));
+    }
+
     public void releaseShader(Shader shader) {
         shader.release();
     }
         defaultShader = createShader(vertexSource, fragmentSource);
         return defaultShader;
     }
+    
+    public StringLWJGLShader createDefaultShader(URL vertexURL, URL fragmentURL) {
+        if (defaultShader != null) {
+            defaultShader.release();
+        }
+        defaultShader = createShader(vertexURL, fragmentURL);
+        return defaultShader;
+    }
 
     public StringLWJGLShader getDefaultShader() {
         return defaultShader;

File src/main/java/cc/plural/ecs/renderer/Camera.java

         return mat4x4;
     }
 
-    public void get(Matrix4f matrix) {
+    public void load(Matrix4f matrix) {
         matrix.mat4x4[0] = 1;
         matrix.mat4x4[1] = 0;
         matrix.mat4x4[2] = 0;

File src/main/java/cc/plural/ecs/renderer/Renderer.java

 import cc.plural.ecs.component.spatial.SpatialComponent;
 import cc.plural.ecs.engine.GameObject;
 import cc.plural.graphics.Vertex;
+import java.net.URL;
 
 public interface Renderer {
     
      */
     public Shader createShader(String vertexSource, String fragmentSource);
     
+    public Shader createShader(URL vertexURL, URL fragmentURL);
+    
     public void releaseShader(Shader shader);
     
     public Shader createDefaultShader(String vertexSource, String fragmentSource);
     
+    public Shader createDefaultShader(URL vertexURL, URL fragmentURL);
+    
     public Shader getDefaultShader();
     
     public Texture createTexture(String path);
     
     public Mesh createStaticMesh(Vertex[] data, short[] indicies);
     
+    public Mesh createStaticMesh(Shader shader, Vertex[] vertices, short[] indicies);
+    
     public void releaseMesh(Mesh mesh);
     
     /**

File src/main/java/cc/plural/ecs/runtime/ApplicationConfiguration.java

         public boolean fullScreen;
         
         public GLVersion forceGLVersion;
+        
+        public int fpsTarget;
 	
 	public ApplicationConfiguration() {
 		title = "cc.plural.ecs!";
                 resizable = false;
                 fullScreen = false;
                 forceGLVersion = null;
+                fpsTarget = 60;
 	}
 }