繁体   English   中英

想旋转我的立方体。 我该怎么办

[英]want to rotate my cube. how could i do that

我想旋转我的立方体并添加4个按钮以加快速度,然后上下移动。 你可以帮帮我吗? 颜色是黄色。 cube.cube下的4个按钮应绕y轴旋转。

public class MyGLRenderer implements Renderer {
Context context; 


Cube cube;

public MyGLRenderer(Context context) {

    this.context = context;


    cube = new Cube();
}

// Call back when the surface is first created or re-created
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    // clear-value for color and depth, enabling depth-test, etc.
    gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set color's clear-value to black
}

// Call back after onSurfaceCreated() or whenever the window's size changes
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
    if (height == 0)
        height = 1;
    float aspect = (float) width / height;

    // Set the viewport (display area) to cover the entire window
    gl.glViewport(0, 0, width, height);

    // Select projection matrix: projection matrix or model-view matrix
    gl.glMatrixMode(GL10.GL_PROJECTION);
    // Reset projection matrix
    gl.glLoadIdentity();

    GLU.gluPerspective(gl, 45, aspect, 0.1f, 100.f);

    // Select model-view matrix
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    // Reset
    gl.glLoadIdentity();

}

// Call back to draw the current frame.
@Override
public void onDrawFrame(GL10 gl) {
    // Clear color and depth buffers using clear-value set earlier
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    // Reset model-view matrix
    gl.glLoadIdentity();
    // Translate into the screen
    gl.glTranslatef(0.0f, 0.0f, -5.0f); 


    // Draw cube
    cube.draw(gl);
}

}

这就是您要查找的内容: https : //www.opengl.org/sdk/docs/man2/xhtml/glRotate.xml ,您必须将其放在glTranslatef前面

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM