BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.23k stars 4.61k forks source link

Can you help me? some questions about VBO in this library. #2297

Open gpr321 opened 8 years ago

gpr321 commented 8 years ago
  1. Why this library do not use vbo?
  2. I am trying to use VBO in GPUImageView
       // the init
        [GPUImageContext setActiveShaderProgram:displayProgram];
        glEnableVertexAttribArray(displayPositionAttribute);
        glEnableVertexAttribArray(displayTextureCoordinateAttribute);

        GLfloat imageVerticess[] =
        {
            -1.0f, -1.0f,
            1.0f, -1.0f,
            -1.0f,  1.0f,
            1.0f,  1.0f,
        };

        GLfloat noRotationTextureCoordinates[] =
        {
            0.0f, 1.0f,
            1.0f, 1.0f,
            0.0f, 0.0f,
            1.0f, 0.0f,
        };

        glGenBuffers(1, &mPositionVBO);
        glGenBuffers(1, &mTexturePositionVBO);

        glBindBuffer(GL_ARRAY_BUFFER, mPositionVBO);
        glBufferData(GL_ARRAY_BUFFER, sizeof(imageVerticess), &imageVerticess[0], GL_STATIC_DRAW);

        glBindBuffer(GL_ARRAY_BUFFER, mTexturePositionVBO);
        glBufferData(GL_ARRAY_BUFFER, sizeof(noRotationTextureCoordinates), &noRotationTextureCoordinates[0], GL_STATIC_DRAW);

    // the render 
        glBindBuffer(GL_ARRAY_BUFFER, mPositionVBO);
        glVertexAttribPointer(displayPositionAttribute, 2, GL_FLOAT, 0, 0, NULL);

        glBindBuffer(GL_ARRAY_BUFFER, mTexturePositionVBO);
        glVertexAttribPointer(displayTextureCoordinateAttribute, 2, GL_FLOAT, 0, 0, NULL);

   // it crash at this line.
  [self.context presentRenderbuffer:GL_RENDERBUFFER];
  1. please give me some advice use vbo, my project wants to use vbo to get improve.
BradLarson commented 8 years ago

I don't use VBOs simply because I haven't taken the time to implement them. I will be doing this over on GPUImage 2, but I've pretty much ceased my development efforts on the Objective-C version of the framework.

It shouldn't make that much of a difference, because there is very little overhead imposed by the tiny amounts of geometry I'm uploading. Shaders are almost always the bottleneck, not geometry.