iOS GLKView Call multiple glUseProgram in a single draw

120 views Asked by At

Say I use GLKit in iOS for OpenGL rendering. And I want to draw two different objects.

So I created two shader programs. And when I draw each object separated, it works well. But if I combine these two program in a single frame draw. The first object doesn`t show.

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect {

    // draw first object
    glUseProgram(firstProgram);
    drawArrays(...);

    // draw second object
    glUseProgram(secondProgram);
    drawArrays(...);
}

And no matter how I change the drawing order, the first drawn object does not show at screen.

Can anybody help me?

0

There are 0 answers