0
我想旋轉其中心周圍的紋理,我已經實現了這段代碼,但它正在旋轉的圖像也顯示了一些角度(所以圖像不能正確看到某些角度),如圖附圖片可以幫我解決這個問題問題圍繞其中心旋轉紋理OpenGL
這裏是我的代碼平方米的
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
gl.glOrthof(0, 320, 0, 480, 0, 1);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glEnable(GL10.GL_TEXTURE_2D);
}
頂點
float vertices[] = {
-.25f,.25f,0,
-.25f,-.25f,0,
.25f,.25f,0,
.25f,-.25f,0
};
,這是我畫甲基OD
public void draw(GL10 gl) {
gl.glPushMatrix();
gl.glTranslatef(-.125f, -.125f, 0f);
gl.glRotatef(r,0, 0,-1);
gl.glTranslatef(.125f, .125f, 0);
// Point to our buffers
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
// Set the face rotation
gl.glFrontFace(GL10.GL_CW);
// Point to our vertex buffer
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexbuffer);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texturebuffer);
// Draw the vertices as triangle strip
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
//Disable the client state before leaving
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
r = r+1;
gl.glPopMatrix();
}