peced
May 10, 2012, 8:14pm
#1
Hi I’ve been trying to map an Fbo texture onto a quad.
So far I just get a blank screen.
Here’s what I’m currently dong:
fbo.getTextureReference().bind();
glBegin(GL_QUADS);
glNormal3f(0.0f,0.0f,1.0f);
glTexCoord2f(0, 0);
glVertex3f(sliceCoordinates[0].x, sliceCoordinates[0].y, sliceCoordinates[0].z);
glTexCoord2f(fbo.getWidth(), 0);
glVertex3f(sliceCoordinates[1].x, sliceCoordinates[1].y, sliceCoordinates[1].z );
glTexCoord2f(fbo.getWidth(), fbo.getHeight());
glVertex3f(sliceCoordinates[2].x,sliceCoordinates[2].y, sliceCoordinates[2].z );
glTexCoord2f(0, fbo.getHeight());
glVertex3f(sliceCoordinates[3].x, sliceCoordinates[3].y, sliceCoordinates[3].z );
glEnd();
fbo.getTextureReference().unbind();
I’m not sure what I’m doing wrong :s
Looks about right. Are you drawing the fbo?
peced
May 11, 2012, 10:07am
#3
I solved my problem; I calling cam.begin() before drawing to the fbo. Turns out this messes things up. It should only be called after the fbo is drawn and you start mapping the fbo texture
Here’s the code in case anyone runs into a similar problem:
//Draw simple shapes on the fbo
fbo.begin();
ofSetColor(200,200,200, 255);
float rectSize = volWidth * 0.3;
ofNoFill();
ofRect((volWidth / 2) - rectSize / 2, (volHeight / 2) - rectSize /2, rectSize, rectSize);
rectSize = volWidth * 0.9;
ofRect((volWidth / 2) - rectSize / 2, (volHeight / 2) - rectSize /2, rectSize, rectSize);
fbo.end();
//begin the cam now
cam->begin(ofRectangle(0,0, ofGetWidth(), ofGetHeight()));
//Bnd the fbo texutre reference
fbo.getTextureReference().bind();
glBegin(GL_QUADS);
glNormal3f(0.0f,0.0f,1.0f);
glTexCoord2f(0, 0);
glVertex3f(sliceCoordinates[0].x, sliceCoordinates[0].y, sliceCoordinates[0].z);
glTexCoord2f(fbo.getWidth(), 0);
glVertex3f(sliceCoordinates[1].x, sliceCoordinates[1].y, sliceCoordinates[1].z );
glTexCoord2f(fbo.getWidth(), fbo.getHeight());
glVertex3f(sliceCoordinates[2].x,sliceCoordinates[2].y, sliceCoordinates[2].z );
glTexCoord2f(0, fbo.getHeight());
glVertex3f(sliceCoordinates[3].x, sliceCoordinates[3].y, sliceCoordinates[3].z );
glEnd();
//Unbind the texture and end the cam
getTextureReference().unbind();
cam->end();