Posted by
dz3 on
Nov 22, 2010; 1:45am
URL: https://forum.jogamp.org/Depth-buffer-not-working-on-Win7-64b-tp1737435p1943034.html
On 11/18/2010 4:28 PM, markm [via jogamp] wrote:
> ...for those whose only option is an Intel graphics chip, the
> following might be useful:
> After having this exact problem on my rather old laptop, it turned out
> that the GLCapabilities object I was using to create my GLCanvas was
> asking for a 24-bit depth buffer:
>
> GLProfile profile = GLProfile.get(GLProfile.GL2);
> GLCapabilities capabilities = new GLCapabilities(profile);
> System.out.println("caps: " + capabilities.getDepthBits()); //
> Returns 24
>
> Now I'm assuming that my graphics chip can't fulfil this request,
> because later when I come to query the actual depth buffer size, it's
> zero...
>
> public void init(GLAutoDrawable drawable) {
> ...
> GL2 gl2 = drawable.getGL().getGL2();
> IntBuffer buff = IntBuffer.allocate(1);
> gl2.glGetIntegerv(GL2.GL_DEPTH_BITS,buff);
> System.out.println("Depth buffer: " + buff.get(0)); // Prints 0;
> oops, our depth buffer looks a little shallow...
> ...
> }
>
> I was able to work around this on my system by changing the depth
> requested by the GLCapabilities:
>
> capabilities.setDepthBits(16); // Gears now render correctly!
>
> I'm not yet sure as to the ideal way to incorporate this workaround in
> my code; it'd be nice if I could find out in advance the best non-zero
> depth buffer value to ask for. But for the moment this seems to work.
> Hope it's useful to someone.
>
Thanks for the excellent suggestion. That fixed the rendering on a
program I'm working on (using JOGL version 1.1.1). I did a little
experimenting and here are the results:
I ran the following code several times with different values for
depthBits (values of 8, 16, 24 and 32):
GLCapabilities capabilities = new GLCapabilities();
if (System.getProperty("os.name").contains("Windows")) {
int depthBits = 16; // tried values of 8, 16, 24 and 32
capabilities.setDepthBits(depthBits);
}
glCanvas = new GLCanvas(capabilities);
glCanvas.addGLEventListener(glEvtListener);
...
Then in the GLEventListener's init method:......display the value...
IntBuffer ibuff = IntBuffer.allocate(1);
gl.glGetIntegerv(GL.GL_DEPTH_BITS, ibuff);
System.out.println("depth bits="+ibuff.get(0));
and the results were:
with depthBits set to either 8, 16 or 32 it would end up as 16 and the
graphics would display properly;
setting depthBits to 24 (which was also the default without setting it)
then the printout would show 24 (different than your result showing 0)
and the graphics were all goofed up as far as hidden surface removal.
Here is information about my system:
using Jogl version 1.1.1
Op sys info:
Windows Vista Home Premium
64 bit operating system
OpenGL info: via gl.glGetString(GL.GL_...) with GL.GL_VENDOR,
GL.GL_RENDERER, GL.GL_VERSION, and GL.GL_EXTENSIONS respectively
Vendor: Intel
Renderer: Intel(R) G45/G43 Express Chipset
Version: 2.1.0 - Build 8.15.10.2189
Extensions: GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_blend_color
GL_EXT_abgr GL_EXT_texture3D GL_EXT_clip_volume_hint
GL_EXT_compiled_vertex_array GL_SGIS_texture_edge_clamp
GL_SGIS_generate_mipmap GL_EXT_draw_range_elements GL_SGIS_texture_lod
GL_EXT_rescale_normal GL_EXT_packed_pixels GL_EXT_texture_edge_clamp
GL_EXT_separate_specular_color GL_ARB_multitexture
GL_EXT_texture_env_combine GL_EXT_bgra GL_EXT_blend_func_separate
GL_EXT_secondary_color GL_EXT_fog_coord GL_EXT_texture_env_add
GL_ARB_texture_cube_map GL_ARB_transpose_matrix GL_ARB_texture_env_add
GL_IBM_texture_mirrored_repeat GL_EXT_multi_draw_arrays
GL_NV_blend_square GL_ARB_texture_compression
GL_3DFX_texture_compression_FXT1 GL_EXT_texture_filter_anisotropic
GL_ARB_texture_border_clamp GL_ARB_point_parameters
GL_ARB_texture_env_combine GL_ARB_texture_env_dot3
GL_ARB_texture_env_crossbar GL_EXT_texture_compression_s3tc
GL_ARB_shadow GL_ARB_window_pos GL_EXT_shadow_funcs GL_EXT_stencil_wrap
GL_ARB_vertex_program GL_EXT_texture_rectangle GL_ARB_fragment_program
GL_EXT_stencil_two_side GL_ATI_separate_stencil
GL_ARB_vertex_buffer_object GL_EXT_texture_lod_bias
GL_ARB_occlusion_query GL_ARB_fragment_shader GL_ARB_shader_objects
GL_ARB_shading_language_100 GL_ARB_texture_non_power_of_two
GL_ARB_vertex_shader GL_NV_texgen_reflection GL_ARB_point_sprite
GL_EXT_blend_equation_separate GL_ARB_depth_texture
GL_ARB_texture_rectangle GL_ARB_draw_buffers GL_ARB_color_buffer_float
GL_ARB_half_float_pixel GL_ARB_texture_float GL_ARB_pixel_buffer_object
GL_EXT_framebuffer_object GL_ARB_draw_instanced GL_ARB_half_float_vertex
GL_EXT_draw_buffers2 GL_WIN_swap_hint GL_EXT_texture_sRGB
GL_EXT_packed_float GL_EXT_texture_shared_exponent GL_ARB_texture_rg
GL_ARB_texture_compression_rgtc GL_NV_conditional_render
GL_EXT_texture_swizzle GL_ARB_framebuffer_sRGB
GL_EXT_packed_depth_stencil GL_ARB_depth_buffer_float
GL_EXT_transform_feedback GL_EXT_framebuffer_blit
GL_ARB_vertex_array_object
So I guess that means that in JOGL 1.1.1 the GL object sets the depth
bit buffer to a legitimate value close to what you ask it for (which
seems to be either 16 or 24 on my graphics card) but that in the case of
24 it (the Intel driver) is buggy.