-2

渲染到 FBO 然后渲染到屏幕缓冲区似乎会使纹理更暗。如此处所示-> http://imgur.com/QZNyY8U

RenderTarget target = new RenderTarget(Display.getWidth(), Display.getHeight());

RenderTarget 类可以在这里找到:http: //pastebin.com/anpBPsgv

GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);  

// set the color of the quad (R,G,B,A)
GL11.glColor4f(5/255f, 35/255f,70/255f, 1f);

//Bind Render Target
target.bind();

// draw quad on FBO
GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(0,0);
    GL11.glVertex2f(0+200,0);
    GL11.glVertex2f(0+200,0+200);
    GL11.glVertex2f(0,0+200);
GL11.glEnd();

target.unBind();

glEnable(GL_TEXTURE_2D); // enable texturing
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);// switch to rendering on the framebuffer
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear Screen And Depth Buffer on the framebuffer to black
glBindTexture(GL_TEXTURE_2D, target.colorTextureID);    // bind our FBO texture

//Draw FBO on screen buffer
glBegin(GL_QUADS);
   glTexCoord2f(0.0f, 0.0f); glVertex2i(0,   0);  
   glTexCoord2f(1.0f, 0.0f); glVertex2i(Display.getWidth(),  0); 
   glTexCoord2f(1.0f, 1.0f); glVertex2i(Display.getWidth(), Display.getHeight()); 
   glTexCoord2f(0.0f, 1.0f); glVertex2i(0, Display.getHeight());
glEnd();

glDisable(GL_TEXTURE_2D);

//Draw same colour image without gonig through FBO
GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(200,0);
    GL11.glVertex2f(200+200,0);
    GL11.glVertex2f(200+200,0+200);
    GL11.glVertex2f(200,0+200);
GL11.glEnd();

glFlush ();

可以在此处找到使用的类pastebin.com/YRChp5vB和此处pastebin.com/anpBPsgv

4

1 回答 1

2

渲染到纹理不会更暗。您只需将纹理绘制得更暗:

GL11.glColor4f(5/255f, 35/255f,70/255f, 1f);

您永远不会将其重置为白色,因此颜色保持原样。默认情况下,GL 使用 GL_MODULATE 纹理环境模式,因此纹理颜色与您设置的颜色相乘。有关任何详细信息,请参阅此问题

于 2013-05-19T13:15:36.813 回答