diff --git a/src/main/java/io/github/hydos/ginger/engine/renderEngine/renderers/ParticleRenderer.java b/src/main/java/io/github/hydos/ginger/engine/renderEngine/renderers/ParticleRenderer.java index 6012cef..af92c80 100644 --- a/src/main/java/io/github/hydos/ginger/engine/renderEngine/renderers/ParticleRenderer.java +++ b/src/main/java/io/github/hydos/ginger/engine/renderEngine/renderers/ParticleRenderer.java @@ -37,9 +37,7 @@ public class ParticleRenderer { Matrix4f viewMatrix = Maths.createViewMatrix(camera); prepare(); for(ParticleTexture texture : particles.keySet()) { - GL13.glActiveTexture(GL13.GL_TEXTURE0); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID()); - shader.loadNumberOfRows(texture.getNumberOfRows()); + bindTexture(texture); for(Particle particle : particles.get(texture)) { updateModelViewMatrix(particle.getPosition(), particle.getRotation(), particle.getScale().x, viewMatrix); } @@ -53,6 +51,12 @@ public class ParticleRenderer { shader.cleanUp(); } + private void bindTexture(ParticleTexture texture) { + GL13.glActiveTexture(GL13.GL_TEXTURE0); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID()); + shader.loadNumberOfRows(texture.getNumberOfRows()); + } + private void updateModelViewMatrix(Vector3f position, float rotation, float scale, Matrix4f viewMatrix) { Matrix4f modelMatrix = new Matrix4f(); Matrix4f.translate(position, modelMatrix, modelMatrix); @@ -68,7 +72,6 @@ public class ParticleRenderer { Matrix4f.rotate((float)Math.toRadians(rotation), new Vector3f(0,0,1), modelMatrix, modelMatrix); Matrix4f.scale(new Vector3f(scale,scale,scale), modelMatrix, modelMatrix); Matrix4f modelViewMatrix = Matrix4f.mul(viewMatrix, modelMatrix, null); - shader.loadModelViewMatrix(modelViewMatrix); } private void prepare(){ diff --git a/target/classes/io/github/hydos/ginger/engine/renderEngine/renderers/ParticleRenderer.class b/target/classes/io/github/hydos/ginger/engine/renderEngine/renderers/ParticleRenderer.class index d00a046..a363348 100644 Binary files a/target/classes/io/github/hydos/ginger/engine/renderEngine/renderers/ParticleRenderer.class and b/target/classes/io/github/hydos/ginger/engine/renderEngine/renderers/ParticleRenderer.class differ