Opengl Es 2.0 Only Draws The Object Once
First, let me say I'm sorry for asking so many questions today. So, I have a class for a circle. And I have an arraylist with 3 circle instance, each with a different x coordinate
Solution 1:
public void drawCircle() { glDrawArrays(GL_TRIANGLE_FAN, 0, 6); }
The above code draws one fan. Where is the code that draws the rest ?
If you are calling this in a loop, where is the translation happening in setPos()
- as x,y do not seem to be used anywhere, and translateM(modelMatrix, 0, 0f, 0.01f, 0f)
always translates the same offset.
Solution 2:
Probably a bit late, but ...
To me it seems that all the circles are being drawn, but they are drawn on top of each other because translateM is not being applied.
You are calling translateCircle from onSurfaceChanged.
But then in OnDrawFrame you are reverting your model matrix by calling setIdentityM.
setIdentityM(modelMatrix, 0);
translateM(modelMatrix, 0, 0f, 0.01f, 0f);
finalfloat[] temp = newfloat[16];
multiplyMM(temp, 0, projectionMatrix, 0, modelMatrix, 0);
...
Removing translateCircle and modify
translateM(modelMatrix, 0, 0f, 0.01f, 0f);
to
translateM(modelMatrix, 0, x, 0.01f, 0f);
should work.
Post a Comment for "Opengl Es 2.0 Only Draws The Object Once"