java - Why does rendering to a FBO cause the texture to be darker? -
rendering fbo screen buffer appears make texture darker. seen here -> http://imgur.com/qznyy8u
rendertarget target = new rendertarget(display.getwidth(), display.getheight());
rendertarget class can found here : http://pastebin.com/anpbpsgv
gl11.glclear(gl11.gl_color_buffer_bit | gl11.gl_depth_buffer_bit); // set color of 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 rendering on framebuffer glclearcolor (0.0f, 0.0f, 0.0f, 1.0f); glclear (gl_color_buffer_bit | gl_depth_buffer_bit);// clear screen , depth buffer on framebuffer 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 ();
classes used can found here pastebin.com/yrchp5vb , here pastebin.com/anpbpsgv
rendering texture not darker. draw texture darker:
gl11.glcolor4f(5/255f, 35/255f,70/255f, 1f);
you never reset white, color stays is. default, gl uses gl_modulate texture environment mode, texture color gets multiplied color have set. see this question details.
Comments
Post a Comment