0

I have two UIViews, each with their own separate renderBuffers and frameBuffers. They belong to different ViewControllers. I already have them connected via NSNotificationCenter, so that is all set.

I just need to basically render the texture in ClassAView's frameBuffer into ClassBView's frameBuffer. This seems like it should be pretty easy... I tried passing in the texture I have bound in ClassAView:

glBindTexture(GL_TEXTURE_2D, myClassATexture);

then after say, tapping the screen, I try passing the texture over to ClassBView:


// in ClassA:
[classBView addTexture:myClassATexture];

// In ClassB's addTexture method:
myClassBTexture = newTexture
glClear, glBindTexture, etc...
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
[self presentFramebuffer];

But it's resulting in a black screen. I tried to NSLog myClassATexture but it's printing out "0."

Anyway, how would I go about effectively passing along the already rendered texture in ClassA to ClassB?

I'm targeting iOS 5.0 so if there's an easy way to do it that requires iOS 5 I'm all ears. :)

Thanks a bunch!

taber
  • 3,166
  • 4
  • 46
  • 72
  • What you're trying should work. The problem is that the texture ID is 0. That essentially means no texture. – user1118321 May 08 '12 at 01:33
  • ah ha, so maybe it's being invalidated after it's rendered? i'm new to opengl obviously. :) – taber May 08 '12 at 01:44
  • Haha, I was unintentionally invalidating it later on in the code, effectively setting it to 0. Oops! I took that out and it works! Awesome. – taber May 08 '12 at 01:51

1 Answers1

0

A texture ID of 0 indicates no texture, so you need to make sure you're properly copying the texture ID to use later.

user1118321
  • 25,567
  • 4
  • 55
  • 86