Hi Darrin,
Sorry about not being able to post my code since I am new to this there is a lot of comments, so I had to clean it up but here is what my code is:
This is when I create a new fbo, I was following a tutorial that's why its named as such.
This is called on every render thats why I encapsulated it in an if statement
if(fboTutorial == 0){
glGenFramebuffers(1, &fboTutorial);
glBindFramebuffer(GL_FRAMEBUFFER, fboTutorial);
glGenTextures(1, &rtTutorial);
glBindTexture(GL_TEXTURE_2D, rtTutorial);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1920, 1080, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glGenRenderbuffers(1, &dbTutorial);
glBindRenderbuffer(GL_RENDERBUFFER, dbTutorial);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, 1920, 1080);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, dbTutorial);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rtTutorial, 0);
drawTutorial[0] = GL_COLOR_ATTACHMENT0;
drawTutorial[1] = GL_DEPTH_ATTACHMENT;
glDrawBuffers(2, drawTutorial);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
NSLog(@"incomplete frame buffer");
}else{
NSLog(@"complete framebuffer");
}
}
glBindFramebuffer(GL_FRAMEBUFFER,currentFBO);
Then when im going to draw to the fbo:
GLint motionFB;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &motionFB);
glBindFramebuffer(GL_FRAMEBUFFER, fboTutorial);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE){
NSLog(@"first time binding GOOD");
}else{
NSLog(@"first time binding bad");
NSLog(@"fbo error %u",glCheckFramebufferStatus(GL_FRAMEBUFFER));
}
////drawing codes here for fbo
glFlush();
//Return to motion's fbo
glBindFramebuffer(GL_FRAMEBUFFER, motionFB);
//First attempt at implementing the pseudo code,
glActiveTexture(rtTutorial);
glActiveTexture(GL_TEXTURE_2D);
//Then I tried this in place of the above code but only showed what I drew for motion
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE0, rtTutorial);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, 1920, 1080);
//////drawing codes for motion
glFlush();
This is pretty much the code I have related to the fbo and drawing to either motion and fbo. Thanks
Peter,
I didnt set anything about the depth range yet, but ill try and play around with it too. Thanks