little performance gain in world render

v5stable
ondra 11 years ago
parent f8f49b81ff
commit 0619f83bfb
  1. 11
      src/mightypork/gamecore/render/Render.java
  2. 12
      src/mightypork/rogue/world/map/Level.java
  3. 4
      src/mightypork/rogue/world/map/MapAccess.java
  4. 2
      src/mightypork/rogue/world/map/TileRenderContext.java

@ -339,9 +339,9 @@ public class Render {
*/ */
private static void unbindTexture() private static void unbindTexture()
{ {
//if (TextureImpl.getLastBind() != null) { if (TextureImpl.getLastBind() != null) {
TextureImpl.bindNone(); TextureImpl.bindNone();
//} }
} }
@ -368,7 +368,8 @@ public class Render {
final RectDigest q = quad.digest(); final RectDigest q = quad.digest();
// draw with color // draw with color
unbindTexture();
glDisable(GL_TEXTURE_2D);
// quad // quad
glBegin(GL_QUADS); glBegin(GL_QUADS);
@ -454,7 +455,8 @@ public class Render {
final RectDigest r = quad.digest(); final RectDigest r = quad.digest();
// draw with color // draw with color
unbindTexture();
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
setColor(colorHMinVMax); setColor(colorHMinVMax);
@ -495,6 +497,7 @@ public class Render {
*/ */
public static void quadTextured(Rect quad, Rect uvs, GLTexture texture, Color tint) public static void quadTextured(Rect quad, Rect uvs, GLTexture texture, Color tint)
{ {
glEnable(GL_TEXTURE_2D);
bindTexture(texture); bindTexture(texture);
setColor(tint); setColor(tint);
quadUV(quad, uvs); quadUV(quad, uvs);

@ -13,6 +13,7 @@ import mightypork.rogue.world.tile.Tiles;
import mightypork.util.files.ion.Ion; import mightypork.util.files.ion.Ion;
import mightypork.util.files.ion.IonConstructor; import mightypork.util.files.ion.IonConstructor;
import mightypork.util.files.ion.Ionizable; import mightypork.util.files.ion.Ionizable;
import mightypork.util.math.noise.NoiseGen;
/** /**
@ -32,6 +33,8 @@ public class Level implements MapAccess, Ionizable {
/** Level seed (used for generation and tile variation) */ /** Level seed (used for generation and tile variation) */
public long seed; public long seed;
private NoiseGen noiseGen;
@IonConstructor @IonConstructor
public Level() public Level()
@ -190,4 +193,13 @@ public class Level implements MapAccess, Ionizable {
} }
} }
@Override
public NoiseGen getNoiseGen()
{
if (noiseGen == null) {
noiseGen = new NoiseGen(0.2, 0, 0.5, 1, seed);
}
return noiseGen;
}
} }

@ -2,6 +2,7 @@ package mightypork.rogue.world.map;
import mightypork.rogue.world.tile.Tile; import mightypork.rogue.world.tile.Tile;
import mightypork.util.math.noise.NoiseGen;
/** /**
@ -37,4 +38,7 @@ public interface MapAccess {
* @return map seed * @return map seed
*/ */
long getSeed(); long getSeed();
NoiseGen getNoiseGen();
} }

@ -27,7 +27,7 @@ public final class TileRenderContext implements RectBound {
{ {
this.map = map; this.map = map;
this.tiler = drawArea.tiles(map.getWidth(), map.getHeight()); this.tiler = drawArea.tiles(map.getWidth(), map.getHeight());
this.noise = new NoiseGen(0.2, 0, 0.5, 1, map.getSeed()); this.noise = map.getNoiseGen();
} }

Loading…
Cancel
Save