Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've only ever used OpenGL on PC, Mac and iOS, but from what I can tell, the code looks fine. Then again, mine always does, too, but I still get the empty screen for a while, pretty much any time I start on anything 3D from scratch (regardless of API)... so here are some things to try, pretty much in the order in which to try them. Hopefully at least one of them will be something you haven't tried yet!</p> <ul> <li>Add in a <code>glFlush</code> at the end, because you're not actually drawing all that much. You'd think the driver would do this for you when you do the buffer swap, but it seems that there's no guarantees of that -- Mac OS X doesn't always seem to, for example.</li> <li>Set background to non-black. If something is drawing in black, you want to see it.</li> <li>Disable <code>GL_LIGHTING</code>. If this is enabled (which I think it is by default?) but you're not supplying normals, everything will come out black. (See above.)</li> <li>Disable <code>GL_CULL_FACE</code>. It doesn't matter how carefully you think about the winding order, there's still a possibility you might have got it wrong. But if <code>GL_CULL_FACE</code> is off, that becomes impossible.</li> <li>Disable <code>GL_DEPTH_TEST</code>. This has saved me a couple of times, when I've typed <code>glClearDepth(0)</code> by accident. Looks like you're OK in that respect, but it's still worth a go.</li> <li>Check <code>glGetError</code> religiously, after EVERY API call, just in case. (<code>assert(glGetError()==GL_NO_ERROR</code>) will do for starters, but you really want to have a little loop that also prints the result of <code>gluErrorString</code> so that it's easier to see at a glance what might be wrong.)</li> <li>Make sure you do a <code>glBindBuffer</code> to set your <code>ARRAY_BUFFER</code> and <code>ARRAY_ELEMENT_BUFFER</code> bindings to 0. To initialize a VBO, you have to bind it, so if you've got something somewhere that sets one up it might just leave it bound. This will stuff up your <code>glVertexPointer</code>.</li> <li>Along the lines of the last few - set up more state explicitly. In this case, for example, you might want to <code>glDisableClientState</code> the other array types, just in case. GL starts up with vertex arrays disabled, according to the docs, but it's a possibility worth eliminating. </li> </ul>
 

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