我将一些透明贴花渲染到单独的帧缓冲区中。现在我正在尝试将此缓冲区与后台缓冲区(活动目标)混合。
我假设我必须将 fbo 的颜色缓冲区作为纹理加载到片段着色器中,并将纹理颜色输出到活动目标。如何告诉显卡为每个像素执行此操作?
绘制一个覆盖整个屏幕的四边形或两个三角形。
my code for the fullscreen rectangle/quad this is old method - from OpenGL 1.1, but works :) For new OpenGL 3.* you have to use VBO/Arrays
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glBegin(GL_QUADS);
glTexCoord2f( 0,0 );
glVertex3d( -1.0,-1.0, 0 );
glTexCoord2f( 1,0 );
glVertex3d( 1.0,-1.0, 0 );
glTexCoord2f( 1,1 );
glVertex3d( 1.0, 1.0, 0 );
glTexCoord2f( 0,1 );
glVertex3d( -1.0, 1.0, 0 );
glEnd();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
of course you have to setup textures before