Note that there are some explanatory texts on larger screens.

plurals
  1. POGL_QUADS Rendering how I don't want it to
    primarykey
    data
    text
    <p>I'm using LWJGL/Open GL to draw a cube. Problem is that it doesn't draw faces in the correct order, and it doesn't render the cubes in the correct place! Here's the Block.java:</p> <pre><code> package src; import static org.lwjgl.opengl.GL11.GL_QUADS; import static org.lwjgl.opengl.GL11.glBegin; import static org.lwjgl.opengl.GL11.glColor3f; import static org.lwjgl.opengl.GL11.glTranslatef; import static org.lwjgl.opengl.GL11.glVertex3f; import static org.lwjgl.opengl.GL11.*; public class Block { private float x; private float y; private float z; private Chunk chunk; public Block(float arg1, float arg2, float arg3, Chunk arg4) { x = arg1; y = arg2; z = arg3; chunk = arg4; } public void renderBlock() { // glTranslatef(0, 0, 0); // Texture tx = chunk.getWorld().getGame().getTexture(0).bind(); glBegin(GL_QUADS); { // Top Face glTexCoord2f(0, 0); glVertex3f(x - 1, y + 1, z - 1); glTexCoord2f(0, 1); glVertex3f(x, y + 1, z - 1); glTexCoord2f(1, 1); glVertex3f(x, y + 1, z); glTexCoord2f(1, 0); glVertex3f(x - 1, y + 1, z); // Bottom Face glTexCoord2f(0, 0); glVertex3f(x - 1, y, z - 1); glTexCoord2f(0, 1); glVertex3f(x, y, z - 1); glTexCoord2f(1, 1); glVertex3f(x, y, z); glTexCoord2f(1, 0); glVertex3f(x - 1, y, z); // Front Face glTexCoord2f(0, 0); glVertex3f(x, y + 1, z - 1); glTexCoord2f(0, 1); glVertex3f(x, y, z - 1); glTexCoord2f(1, 1); glVertex3f(x, y, z); glTexCoord2f(1, 0); glVertex3f(x, y + 1, z); // Back Face glTexCoord2f(0, 0); glVertex3f(x - 1, y + 1, z - 1); glTexCoord2f(0, 1); glVertex3f(x - 1, y, z - 1); glTexCoord2f(1, 1); glVertex3f(x - 1, y, z); glTexCoord2f(1, 0); glVertex3f(x - 1, y + 1, z); // BackFace glTexCoord2f(0, 0); glVertex3f(x - 1, y + 1, z - 1); glTexCoord2f(0, 1); glVertex3f(x, y + 1, z - 1); glTexCoord2f(1, 1); glVertex3f(x, y, z - 1); glTexCoord2f(1, 0); glVertex3f(x - 1, y, z - 1); // FrontFace glTexCoord2f(0, 0); glVertex3f(x - 1, y + 1, z); glTexCoord2f(1, 0); glVertex3f(x, y + 1, z); glTexCoord2f(1, 1); glVertex3f(x, y, z); glTexCoord2f(0, 1); glVertex3f(x - 1, y, z); } glEnd(); } public float getX() { return x; } public float getY() { return y; } public float getZ() { return z; } } </code></pre> <p>And this is the Render.java:</p> <pre><code> package src; import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT; import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST; import static org.lwjgl.opengl.GL11.glClear; import static org.lwjgl.opengl.GL11.glEnable; import static org.lwjgl.opengl.GL11.glEnd; import static org.lwjgl.opengl.GL11.glLoadIdentity; import static org.lwjgl.opengl.GL11.glPopMatrix; import static org.lwjgl.opengl.GL11.glPushMatrix; import java.util.logging.Level; import java.util.logging.Logger; import org.lwjgl.LWJGLException; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; public class Render { Game game; public Render(Game arggame) { game = arggame; } public void initDisplay() { try { Display.setDisplayMode(new DisplayMode(1280, 720)); Display.create(); } catch (LWJGLException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } public void renderLoop() { glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); game.cam.useView(); glPushMatrix(); { renderBlocks(game.world); glEnd(); } glPopMatrix(); Display.update(); } public void renderBlocks(World arg1world) { for (int i = 0; i &lt; 125; i++) { if (arg1world.chunkIndex[i] != null) { for (int j = 0; j &lt; 32768; j++) { if (arg1world.chunkIndex[i].blockIndex[j] != null) { arg1world.chunkIndex[i].blockIndex[j].renderBlock(); } } } } } } </code></pre> <p>Blocks seem to render 2 blocks lower then the should be, I think it can be fixed by editing the glVertex3f, but why wont it render correctly because it is using the position variables. The glTranslate just makes everything worse (does some exponential shifting).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload