iPad,render to texture, low framerate

Nibbie
Posts: 1
Joined: 2010.11
Post: #1
Hi everyone, this is my first posting here.

I've modified the OpenGL es 2.0 template in Xcode to render that little box to an offscreen texture (50*50), then reset the view port and render the texture to the screen using a fullscreen quad. But the FPS dropped down so much that obvious lags were seen (about 10).

I know iPad has problems concerning fillrate, but this just doesn't seem right. I used only one FBO and changed its color attachment between texture and renderBuffer in the loop. Does this have any influence?

Besides, I was writing an audio visualizer (like the one in Windows Media Player) editing pixel values in OpenGL. Any suggestions?

Thanx in advance.Smile


here goes the code:
Code:
//implement the texture in -(id)init        
    glGenTextures(1, &ScreenTex);  
    glBindTexture(GL_TEXTURE_2D, ScreenTex);  
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texSize, texSize, 0, GL_RGB, GL_UNSIGNED_BYTE, nil);
    
    //And in the render loop  
    //draw to the texture  
    glViewport(0, 0, texSize, texSize);  
    glBindTexture(GL_TEXTURE_2D, ScreenTex);  
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ScreenTex, 0);  
    glClear(GL_COLOR_BUFFER_BIT);
        
    glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, squareVertices);  
    glUniform1i(Htunnel, 0);  
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);  
    
    //switch to render to render buffer here  
    glViewport(0, 0, backingWidth, backingHeight);
        
    glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);  
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,colorRenderbuffer);  
    glClear(GL_COLOR_BUFFER_BIT);  
    
    glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, texVertices);  
    glUniform1i(Htunnel, 1);  
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);  
    
    //vertex shader  
    void main()  
    {  
        if (tunnel==0) {  
            gl_Position = position;  
            gl_Position.y += sin(translate) / 2.0;  
            colorVarying = color;  
        }else {  
            f_texCoord = v_texCoord;  
            gl_Position = position;  
        }  
    }  
    
    //frag shader
    void main()  
    {  
        if (tunnel==0) {  
            gl_FragColor = colorVarying;  
        }  else {  
            gl_FragColor = texture2D(s_texture, f_texCoord);    
        }  
    }
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Render to texture failing headkaze 7 7,594 Sep 1, 2010 09:47 PM
Last Post: headkaze
  Performance problems with render to texture method mbw234 6 5,224 Jun 25, 2010 01:47 AM
Last Post: Jamie W
  Help optimizing an inconsistent framerate Duddd 6 4,735 Apr 4, 2010 09:27 PM
Last Post: Duddd
  Trying to save draw-calls for framerate (iphone app) player___1 0 2,646 Jul 6, 2009 12:39 PM
Last Post: player___1
  Render to texture performance iPhoneGG 2 3,748 May 18, 2009 03:31 PM
Last Post: ShiftZ