以下是給我三角形不是正方形,任何人都知道爲什麼?渲染一個正方形
//Defining as...
addcube(2,-2, 1, -1, 10);
addcube(float lx, float hx, float ly, float hy, floathz){
final float array1[] = new float[] {
//Front face
lx, ly, hz,
lx, hy, hz,
hx, hy, hz,
hx, ly, hz
};
}
//Drawing as...
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
我試圖加入gl.glDisable(GL10.GL_CULL_FACE);
但這只是把剩下的正方形放在前臺。我已經包括了繪畫方法...
public void onDrawFrame(GL10 gl) {
onDrawFrameCounter++;
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
bindCameraTexture(gl);
System.out.println(Global.bearing);
float bear = Global.bearing;
gl.glLoadIdentity();
gl.glNormal3f(0,0,1);
System.out.println("ARRAY!: " + GLCamTest.array.length);
p = 0;
gl.glRotatef(bear, 1, 0, 0);
int e = 0;
for(int q=0; q < Global.cubes;q++){
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4);
e = e+4;
}
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
float ratio = (float) width/height;
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glFrustumf(-ratio, ratio, -1, 1, 1, 20);
gl.glMatrixMode(GL10.GL_MODELVIEW);
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
gl.glClearColor(0, 0, 0, 0);
gl.glDisable(GL10.GL_CULL_FACE);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glEnable(GL10.GL_DEPTH_TEST);
cubeBuff = makeFloatBuffer(GLCamTest.array);
texBuff = makeFloatBuffer(camTexCoords);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, cubeBuff);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texBuff);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
}
沒有這樣的東西'在它出現的OpenGL-ES GL_QUAD_STRIP'。 – Skizit 2010-07-27 13:03:30
試試GL_QUADS。如果這不起作用GL_POLYGON應該是因爲你告訴它計算4個頂點。此刻你告訴它嘗試繪製三角形。 – AaronM 2010-07-27 13:10:40
既不是那些工作。沒有表現 – Skizit 2010-07-27 13:14:56