应用程序工作得很慢

时间:2010-07-06 15:17:38

标签: iphone performance

我的iPhone上的应用程序存在很大问题。 这是极其缓慢的。 (我在模拟器上运行它,但在设备上它甚至更慢) 我正在使用最新的Xcode并在4.0模拟器上运行它。

当我渲染10个四边形时,我有60个FPS。 当我渲染30个四边形时,我有30个FPS

发生了什么事?

这是我的渲染功能

(void)render
{
    // Replace the implementation of this method to do your own custom drawing

    // This application only creates a single context which is already set current at this point.
    // This call is redundant, but needed if dealing with multiple contexts.
    [EAGLContext setCurrentContext:context];

    // This application only creates a single default framebuffer which is already bound at this point.
    // This call is redundant, but needed if dealing with multiple framebuffers.
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);

    static int obieg = 0;
    NSLog(@"wartosc: %i", obieg);
    obieg++;

    glViewport(0, 0, backingWidth, backingHeight);  


    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();


    glRotatef(-90, 0, 0, 1);

    glOrthof(0.0, 800, 0.0, 500, -1.0, 1.0);


    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();






    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glTranslatef(0.0, 0.0, -1.0f);

    glDisable(GL_TEXTURE_2D);


    for(int i=0; i<10; i++)
    {


    GLfloat squareVertices[] = {
        100.0f, 400.0f,
        500.5f, 400.0f,
        500.5f, 50.33f,
        100.0f,  50.33f
    };

    glVertexPointer(2, GL_FLOAT, 0, squareVertices);
    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
    }



    // This application only creates a single color renderbuffer which is already bound at this point.
    // This call is redundant, but needed if dealing with multiple renderbuffers.
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
    [context presentRenderbuffer:GL_RENDERBUFFER_OES];

那有什么不对呢? 也许我在项目设置上做了一些改变?

我猜iPhone可以重新制作出几千个三角形,而不仅仅是几个......

0 个答案:

没有答案