English 中文(简体)
sp后roid露天减速
原标题:android opengl slowdown after sprites are drawn

担任这一职务的非描述性头衔,但我只是说话(如果你认为是的话,请提出更好的标题)。

我目前的发动机的一部分呼吁,为了充满活力的灯光......,它似乎在工作上很出色,但在某些灯光产生后,出于某些令人厌恶的原因,游戏仍然很缓慢,如果仍在打上,就会如此。 我不禁要问,我的诗歌职能是否留下了记忆。

这里的职能是:

    public void lightBlock(GL10 gl, int _x, int _y, float shade)
    {   

        if (map[_x][_y].Type()==1)
        {
        gl.glPushMatrix();
        gl.glTranslatef(_x*2,getFH(_x,_y)+.01f,_y*2);
        gl.glRotatef(90,1, 0, 0);
        gl.glScalef(2, 2, 0);
        gl.glColor4f(shade,shade,shade, 1f);
        drawSprite(gl,0);

        gl.glPopMatrix();

        gl.glPushMatrix();
        gl.glTranslatef(_x*2,getRH(_x,_y)-.01f,_y*2);
        gl.glRotatef(-90,1, 0, 0);
        gl.glScalef(2, 2, 0);
        gl.glColor4f(shade,shade,shade, 1f);
        //Draw the vertices
        drawSprite(gl,0);

        gl.glPopMatrix();
        }

    }

    public void drawSprite(GL10 gl, int tex)
    {
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);      
        //defines the vertices we want to draw
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, SvertexBuffer);
        gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, StexBuffer);

        //Draw the vertices
        gl.glDrawElements(GL10.GL_TRIANGLES,  6, GL10.GL_UNSIGNED_SHORT,  SindexBuffer);
        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    }

If the lights are not in use, these functions are not called... but oddly enough once they have been called many times, the game runs as slow as it would be if they were all running at once... And it runs normally as soon as I comment out the "drawSprite()" calls...

这些灯在“onDrawFrame”功能内。

任何帮助都是巨大的。

问题回答

你们是否检查了太多的物体?

我有一个问题,即它逐渐放缓,而我却不清我的“ToScene”名单。 这意味着我在我的游戏中增加了一组其他实体。

如果你以间谍形式这样做的话,如果你说需要时间的话,你就会发现速度放慢。





相关问题
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 ...

热门标签