1. Attempting to compile an OpenGL program from the (renderer's) constructor
This happened to me A LOT. What I was doing was to set up my program and handles in the constructor. The right place to do that is in onSurfaceCreated. Make sure you keep that in mind, because, if I remember well, the errors you get are rather cryptic or misleading for the beginner.2. Forgetting to call glUseProgram()
This one was really annoying, especially when I was convinced that my code was right. Obviously nothing would be drawn on the screen. In order to avoid this, I call glUseProgram() right after my program compiled successfully or, if I use multiple shaders, right at the top of each shader-dedicated draw method.3. Implicit casting of int operands to float.
One of the "milder" ones, but still annoying. However, it's now second nature to type, for example, 1.0 instead of 1 when I work with floats.And now probably the most serious and time wasting of them:
4. Poor error identification
Yep. When something crashed or went wrong, I wasted a lot of time trying to find the bug using only at times very cryptic messages from logcat rather than learn how to find and print the error that occurred. Luckily, GLU.gluErrorString() and GLES20.glGetShaderInfoLog() are available.Lastly, a recommendation. It may seem ironic, but I learned A LOT about OpenGL and graphics in general from the OpenGL ES Programming Guide for iOS. It's a lot more comprehensive than Android's guide.
No comments:
Post a Comment