Hey guys,
The following is giving me triangles not squares, anyone know why??
//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;
I've attempted adding gl.glDisable(GL10.GL_CULL_FACE);
but that just puts the remaining square in the foreground. I've included the draw methods...
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);
}