English 中文(简体)
A. 开放式GL在 and中的需要援助
原标题:Need assistance in OpenGL in android

I ve创建了3个 Java班。

  1. one that has a glsurfaceview object and this calls the renderer class.
  2. this is the renderer class and this calls the cube class.
  3. this is the cube class.

如果我掌握了这张照片,则屏幕显示一种轮值的立方圆(在立方位进行坦率的轮换)是罚款的。 但是,我想控制ube子的轮用方向,而我为之建立了2个 but子。 这是我需要帮助的,因为我不知道让纽州控制河道的移动。 如果你能给我留下一些法典,那么我会看一看,那是很伟大的。

最佳回答

您的活动班(或您的活动班)应如此:

public class stackoverflowTest extends Activity {

GLSurfaceView glSurface;
MyRenderer myRenderer;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    myRenderer = new MyRenderer(this);        
    //Create an instance of the Renderer with this Activity

    glSurface = (GLSurfaceView) findViewById(R.id.graphics_glsurfaceview1);
    //Set our own Renderer and hand the renderer this Activity Context

    glSurface.setEGLConfigChooser(true);

    glSurface.setRenderer(myRenderer);
    //Set the GLSurface as View to this Activity


}

/** 
* this is the method the button click calls
*/
public void changeRotationDirection(View v){

    myRenderer.changeRotationDirection();


}

}

之后,在您的 render子里:

public class MyRenderer implements Renderer {

private float rotationDirection = 1.0f;


public MyRenderer(Context context){
    this.context = context;
}

public void setRotationDirection(){

    if(rotationDirection==1.0f){
        rotationDirection=-1.0f;
    } else {
        rotationDirection=1.0f;
    }

}

@Override
public void onDrawFrame(GL10 gl) {
        // GL calls

        gl.glRotatef(angle, rotateDirection, 0.0f, 0.0f);

        // draw cube
        gl.glDrawArrays( etc );

    }

}

基本上,你使用<条码>glRotatef,在你提用之前先轮用。 使用——对角参数(第一)或x,yz数值参数进行变换。 使用方法可打电话到<代码>Renderer,与密码通信并更新现场。 谨慎使用这一方法,因为放电器和主线/天线(从发出国呼的地方)可能会出现同步化问题。

在XML布局(任何观点)中添加<代码>android:onClick=“changeRotationDirection”。 t必须只是一个 but子。 在XML布局中宣布的任何纽扣式方法必须采用<代码>公开无效[方法名称]([名称]),并且必须从纽扣地起活动类别。

更先进的插线控制,按照Erik的建议进行检查,并检查。 On TouchListeners

(Note: if you re using openGL-ES 2.0 or above (android 2.2+) then use GLES20.glRotatef())

问题回答

你们也许要从墨水中查到“信通”的榜样。 如果我不误在样本/插塔形/红.的夹中。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签