opengl - Can't render to texture (anymore) -


i implemented volume rendering demo application few months ago. worked fine in windows xp-32bits. used opengl -glew , sfml2.0-rc windowing&input library. now. moved windows 7-64bits recently.

the program did not work out of box, sfml seemed crash. changed windowing library glfw, still using glew. going through code realized basic render texture technique did not work anymore. broke down minimal case present you. (i made port qt5.0.2 cross-check assumptions : same diagnosis).

so here problem :

the program supposed render simple unit cube front-face culling texture in pass 1. in pass 2 switch back-face culling , render same cube again. in fragment shader (pass 2) have option read texture (from pass 1) , write output : big black screen when should see front-face culled cube ...

initialization code :

glgenframebuffers(1, &raycastingframebuffer); glbindframebuffer(gl_framebuffer, raycastingframebuffer);     glgentextures(1, &cuberendertexture); glbindtexture(gl_texture_2d, cuberendertexture); glteximage2d(gl_texture_2d, 0, gl_rgba32f, viewwidth, viewheight, 0, gl_rgba, gl_float, 0); gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_nearest); gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_nearest); gltexparameteri(gl_texture_2d, gl_texture_wrap_s, gl_clamp_to_edge); gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_clamp_to_edge); glframebuffertexture2d(gl_framebuffer, gl_color_attachment0, gl_texture_2d, cuberendertexture, 0);  glenum drawbuffers[1] = {gl_color_attachment0}; gldrawbuffers(1, drawbuffers); if(glcheckframebufferstatus(gl_framebuffer) != gl_framebuffer_complete)     return false; glbindframebuffer(gl_framebuffer, 0); 

render passes :

    // pass 1 :     //              render unit cube (with front face culling) texture     //              end texture colors represent outgoing rays locations on box     //     glbindframebuffer(gl_framebuffer, raycastingframebuffer);     glenable(gl_cull_face);     gldisable(gl_depth_test);     glviewport(0, 0, viewwidth, viewheight);     glcullface(gl_front);     glclearcolor(0.0, 0.0, 0.0, 0.0);     glclear(gl_color_buffer_bit);     gluseprogram(shaderraycasting1.getprogramid());          glbindbuffer(gl_array_buffer, cube_vbo_id);         glvertexattribpointer(0, 3, gl_float, gl_false, 0, (char*)null + 0);         glenablevertexattribarray(0);         glvertexattribpointer(1, 3, gl_float, gl_false, 0, (char*)null + 108*sizeof(float));         glenablevertexattribarray(1);         glbindbuffer(gl_array_buffer, 0);          gluniformmatrix4fv(glgetuniformlocation(shaderraycasting1.getprogramid(), "modelview"), 1, gl_true, modelview.getdata());         gluniformmatrix4fv(glgetuniformlocation(shaderraycasting1.getprogramid(), "projection"), 1, gl_true, projection.getdata());          gldrawarrays(gl_triangles, 0, 36);          gldisablevertexattribarray(1);         gldisablevertexattribarray(0);      gluseprogram(0);     glbindframebuffer(gl_framebuffer, 0);     glenable(gl_depth_test);      // pass 2 :     //              render unit cube (with face culling time)     //              colors representing ray entrance locations on box     //     glviewport(0, 0, viewwidth, viewheight);     glcullface(gl_back);     glclearcolor(0.0, 0.0, 0.0, 0.0);     glcleardepth(1.0);     glclear(gl_color_buffer_bit | gl_depth_buffer_bit);     gluseprogram(shaderraycasting2.getprogramid());          glactivetexture(gl_texture0);         glbindtexture(gl_texture_2d, cuberendertexture);         gluniform1i(cuberendertextureid, 0);          gluniform1i(glgetuniformlocation(shaderraycasting2.getprogramid(), "displaywidth"), (glint) viewwidth);         gluniform1i(glgetuniformlocation(shaderraycasting2.getprogramid(), "displayheight"), (glint) viewheight);          glbindbuffer(gl_array_buffer, cube_vbo_id);         glvertexattribpointer(0, 3, gl_float, gl_false, 0, (char*)null + 0);         glenablevertexattribarray(0);         glvertexattribpointer(1, 3, gl_float, gl_false, 0, (char*)null + 108*sizeof(float));         glenablevertexattribarray(1);         glbindbuffer(gl_array_buffer, 0);          gluniformmatrix4fv(glgetuniformlocation(shaderraycasting1.getprogramid(), "modelview"), 1, gl_true, modelview.getdata());         gluniformmatrix4fv(glgetuniformlocation(shaderraycasting1.getprogramid(), "projection"), 1, gl_true, projection.getdata());          gldrawarrays(gl_triangles, 0, 36);          gldisablevertexattribarray(1);         gldisablevertexattribarray(0);         glactivetexture(0);      gluseprogram(0); 

... , minimal fragment shader :

#version 330  in vec3 color; uniform int displaywidth; uniform int displayheight; uniform sampler2d cubetex; layout (location = 0) out vec4 outcolor;  void main() {     float viewwidth = displaywidth;     float viewheight = displayheight;      vec3 boxin  = color;     vec2 cubecoord = vec2( (gl_fragcoord.x - 0.5) / viewwidth,   (gl_fragcoord.y - 0.5) / viewheight);     vec3 boxout = texture(cubetex, cubecoord).rgb;     vec3 raycolor = boxout;             outcolor = vec4(raycolor, 1); // black screen here ... } 

some last words : - compiles no warnings, no errors (same qt 5.0.2 port of demo) - tried every possible little "tweaking" glenable(...), changing opengl version, using texelfetch, , not ... can't find what's wrong code. - original code more complex , did run, on xp , not on win7. - etc.

did install original vendor drivers gpu downloaded vendor's driver support website, or still have installed crippled versions shipped windows 7?

the drivers shipping windows 7 not offer modern opengl support. microsoft strips them of opengl , default opengl implementation of windows-7 opengl-1.4 emulation on top of direct3d.

if didn't already, download original drivers gpu's vendor , install those, report if changed outcome.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -