Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL Display Error - Incorrect display
    primarykey
    data
    text
    <p>I'm learning OpenGL and I've got a problem with incorrect rendering. This is the problem I'm having, there are gaps between sides of pyramids.</p> <p><img src="https://i.stack.imgur.com/4cVq1.png" alt="enter image description here"></p> <p>Here are the vertices I'm using to construct.</p> <pre><code>// Create Pyramid Vertex Buffer FloatBuffer vertexBuffer = BufferUtils.createFloatBuffer(3 * 12); vertexBuffer.put(new float[] { // Side one 0f, 0.8f, 0f, -0.8f, -0.8f, 0.8f, 0.8f, -0.8f, 0.8f, // Side two 0f, 0.8f, 0f, 0.8f, -0.8f, 0.8f, 0.8f, -0.8f, -0.8f, // Side three 0f, 0.8f, 0f, 0.8f, -0.8f, -0.8f, -0.8f, -0.8f, -0.8f, // Side four 0f, 0.8f, 0f, -0.8f, -0.8f, -0.8f, -0.8f, -0.8f, 0.8f }); vertexBuffer.rewind(); </code></pre> <p>I thought that this was because the model comes out of screen. So I thought translating on the z-axis should be fine and I added this line before calling <code>glDrawArrays</code></p> <pre><code>glTranslatef(0f, 0f, -1f); </code></pre> <p>This came up with this strange behaviour, having more sides being drawn.</p> <p><img src="https://i.stack.imgur.com/IaS6x.png" alt="enter image description here"></p> <p>The three sides are rendered but it is only supposed to view only two! How can I solve this problem? I have also enabled the depth test.</p> <p>Here's how I initialize OpenGL</p> <pre><code>// Initialize OpenGL glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1, 1, -1, 1, 1, -1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glViewport(0, 0, Display.getWidth(), Display.getHeight()); </code></pre>
    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.
 

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