Note that there are some explanatory texts on larger screens.

plurals
  1. POMoving to OpenGL 2.0, getting a black screen
    primarykey
    data
    text
    <p>I'm trying to modernize my OpenGL code a little bit by bringing it to OpenGL 2.0 time, but all I get is a black screen... perhaps someone spots a mistake in my code (not that much of code).</p> <p>Here is a snip of the relevant bits of my old, fully working code.</p> <pre><code>// Send color data into GPU memory glEnableClientState(GL_COLOR_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, colorsHandle); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, colors, GL15.GL_DYNAMIC_DRAW); glColorPointer(4, GL_FLOAT, 0, 0); // Send vertex data into GPU memory glEnableClientState(GL_VERTEX_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, verticesHandle); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, GL15.GL_DYNAMIC_DRAW); glVertexPointer(3, GL_FLOAT, 0, 0); // Send texcoords data into GPU memory GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, texcoordsHandle); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, GL15.GL_DYNAMIC_DRAW); glTexCoordPointer(2, GL_FLOAT, 0, 0); for (Batch batch : batches) batch.render(); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); </code></pre> <p>... batch calls glDrawArrays (amongst doing some opengl state changes) ...</p> <pre><code>glDrawArrays(GL_QUADS, spriteOffset * 4, spriteCount * 4); </code></pre> <p>And here is the new code:</p> <pre><code>// Send color data into GPU memory GL20.glEnableVertexAttribArray(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, colorsHandle); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, colors, GL15.GL_DYNAMIC_DRAW); GL20.glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0); // Send vertex data into GPU memory GL20.glEnableVertexAttribArray(1); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, verticesHandle); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertices, GL15.GL_DYNAMIC_DRAW); GL20.glVertexAttribPointer(1, 3, GL_FLOAT, false, 0, 0); // Send texcoords data into GPU memory GL20.glEnableVertexAttribArray(2); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, texcoordsHandle); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, texcoords,GL15.GL_DYNAMIC_DRAW); GL20.glVertexAttribPointer(2, 2, GL_FLOAT, false, 0, 0); for (Batch batch : batches) batch.render(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); </code></pre> <p>Like I said the first bit of code works perfectly, but the second does not draw anything at all. Those are the only lines of code I changed in my renderer, and they look correct to me. But obviously there is a problem somewhere... What could possibly cause the absence of rendering?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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