I tried to render to a texture and render it later as a full-screen quad. However the screen remains black. I checked the fbo, no errors it is complete, I checked the shaders, they're working, I checked the render texture on another object, and it contains the scene data, and I could display it. I checked the full-screen quad that I draw the texture onto, and I can draw it too, but to be sure I disabled backface culling while drawing the fs quad. I get no opengl error, I can pass all the stuff to the shaders, I get no error while loading them too. I tried immediate mode drawing too, but it didn't help. The scene is drawn properly when not using RTTs.
Here's the loading code:
//load in the shaders
objs::get()->shader_loader.load_shader_control_file ( "../shaders/deferred/fs_quad.sc", &the_render.fs_quad );
//load in the full-screen quad from an obj file
objs::get()->obj.load_obj_file ( "../resources/fs_quad.obj", &the_render.quad, &the_render.fs_quad );
//create the render buffer that contains the depth data
the_render.rbuf_depth.create();
the_render.rbuf_depth.bind();
the_render.rbuf_depth.set_storage_format ( GL_DEPTH_COMPONENT32, objs::get()->conf.SCREEN_WIDTH, objs::get()->conf.SCREEN_HEIGHT );
//create fbo that will contain the color data
the_render.fbo.create();
the_render.fbo.bind();
the_render.fbo.set_as_draw_buffer ( GL_COLOR_ATTACHMENT0 );
//attach render buffer to the frame buffer
the_render.rbuf_depth.attach_to_frame_buffer ( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, &the_render.fbo );
//attach the texture to the frame buffer
the_render.fbo_tex.attach_to_frame_buffer ( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, &the_render.fbo );
and the obj file:
v 1.000000 -1.000000 0.000000
v 1.000000 1.000000 0.000000
v -1.000000 1.000000 0.000000
v -1.000000 -1.000000 0.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
f 3/3/ 4/2/ 1/1/
f 2/4/ 3/3/ 1/1/
I tried to render to a texture and render it later as a full-screen quad. However the screen remains black. I checked the fbo, no errors it is complete, I checked the shaders, they're working, I checked the render texture on another object, and it contains the scene data, and I could display it. I checked the full-screen quad that I draw the texture onto, and I can draw it too, but to be sure I disabled backface culling while drawing the fs quad. I get no opengl error, I can pass all the stuff to the shaders, I get no error while loading them too. I tried immediate mode drawing too, but it didn't help. The scene is drawn properly when not using RTTs.
Here's the loading code:
//load in the shaders
objs::get()->shader_loader.load_shader_control_file ( "../shaders/deferred/fs_quad.sc", &the_render.fs_quad );
//load in the full-screen quad from an obj file
objs::get()->obj.load_obj_file ( "../resources/fs_quad.obj", &the_render.quad, &the_render.fs_quad );
//create the render buffer that contains the depth data
the_render.rbuf_depth.create();
the_render.rbuf_depth.bind();
the_render.rbuf_depth.set_storage_format ( GL_DEPTH_COMPONENT32, objs::get()->conf.SCREEN_WIDTH, objs::get()->conf.SCREEN_HEIGHT );
//create fbo that will contain the color data
the_render.fbo.create();
the_render.fbo.bind();
the_render.fbo.set_as_draw_buffer ( GL_COLOR_ATTACHMENT0 );
//attach render buffer to the frame buffer
the_render.rbuf_depth.attach_to_frame_buffer ( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, &the_render.fbo );
//attach the texture to the frame buffer
the_render.fbo_tex.attach_to_frame_buffer ( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, &the_render.fbo );
and the obj file:
v 1.000000 -1.000000 0.000000
v 1.000000 1.000000 0.000000
v -1.000000 1.000000 0.000000
v -1.000000 -1.000000 0.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
f 3/3/ 4/2/ 1/1/
f 2/4/ 3/3/ 1/1/
as far as I know if you bind a texture, then there is no need to pass anything but a zero as the variable to the shader (to the sampler2D).
Nope. Binding a texture is only required for those stages of fixed pipeline that operate on it (setting image, filters, etc.). sampler2D should contain actual texture ID. You pass a 'default' textureID (0) to shader, that's why all you see is a black quad
[quote name='Yours3!f' timestamp='1313068976' post='4847666']
as far as I know if you bind a texture, then there is no need to pass anything but a zero as the variable to the shader (to the sampler2D).
Nope. Binding a texture is only required for those stages of fixed pipeline that operate on it (setting image, filters, etc.). sampler2D should contain actual texture ID. You pass a 'default' textureID (0) to shader, that's why all you see is a black quad
[/quote]
but I do it everywhere else, and it works... anyways I tried it:
fs_quad.pass_int ( *fbo_tex.get_id(), "texture0" ); //the returned id is the GLuint of the texture
//draw full-screen quad
quad.render();
but at the quad.render() function it crashes. this is the last call from my application, and there are some from the gpu driver (fglrx_dri.so)
[quote name='Yours3!f' timestamp='1313068976' post='4847666']
as far as I know if you bind a texture, then there is no need to pass anything but a zero as the variable to the shader (to the sampler2D).
Nope. Binding a texture is only required for those stages of fixed pipeline that operate on it (setting image, filters, etc.). sampler2D should contain actual texture ID. You pass a 'default' textureID (0) to shader, that's why all you see is a black quad
[/quote]
Nope, sampler2D should contain the texture unit unit number. It starts from 0 and goes to GL_MAX_whatever (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS or GL_MAX_TEXTURE_IMAGE_UNITS)
http://www.opengl.org/wiki/GLSL_:_common_mistakes#Binding_A_Texture
Sig: http://glhlib.sourceforge.net an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
[quote name='capricorn' timestamp='1313069182' post='4847668']
[quote name='Yours3!f' timestamp='1313068976' post='4847666']
as far as I know if you bind a texture, then there is no need to pass anything but a zero as the variable to the shader (to the sampler2D).
Nope. Binding a texture is only required for those stages of fixed pipeline that operate on it (setting image, filters, etc.). sampler2D should contain actual texture ID. You pass a 'default' textureID (0) to shader, that's why all you see is a black quad
[/quote]
Nope, sampler2D should contain the texture unit unit number. It starts from 0 and goes to GL_MAX_whatever (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS or GL_MAX_TEXTURE_IMAGE_UNITS) http://www.opengl.or...nding_A_Texture
[/quote]
ok but that is for multi-texturing right? and since there is only one texture and I don't use multi-texturing anywhere else it should work, shouldn't it?
anyways the driver should've given me an opengl error, not crashing
[quote name='V-man' timestamp='1313070921' post='4847678']
Nope, sampler2D should contain the texture unit unit number.
Ugh, what I was smoking? Should go slap myself in the head a couple times. Apologies, Yours3!f.
[/quote]
no problem you've just discovered a bug in the linux ATI drivers as it's not giving an error when using a GLint > max
actually the texture id was 707, so I tried to use my video card excessively lol