Antialias and glAccum slowness (Just me?)

Here’s a program I modified from the green triangle tutorial to get antialiasing working. Oddly, though, I have to turn it up pretty high to get anything that looks like it might be good results (the quality I’m used to from my NVidia card on my PC using 2x FSAA)… Possibly an ATI issue? WoW looks better than this, I recall, with fewer samples, but maybe I’m just becoming paranoid/delusional. >.>

#import "MyOpenGLView.h"

#include <OpenGL/gl.h>

@implementation MyOpenGLView

- (id) initWithCoder:( NSCoder * ) coder {
	self = [super initWithCoder:coder];
	
	NSOpenGLPixelFormatAttribute attrs[] = {
		NSOpenGLPFADoubleBuffer, YES,
		NSOpenGLPFASampleBuffers, 1,
		NSOpenGLPFASamples, 6,
		nil };
	
	[self setPixelFormat:[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]];
	
	return self;
}

- (void) drawRect:( NSRect ) bounds {
	glEnable( GL_MULTISAMPLE_ARB );
	
	glClearColor( 0, 0, 0, 0 );
	glClear( GL_COLOR_BUFFER_BIT );
	
	glColor3f( 1.0f, 1.0f, 1.0f );
	
	glBegin( GL_TRIANGLES ); {
		glVertex3f( -1.0f, 1.0f, 0.0f );
		glVertex3f( 1.0f, 1.0f, 0.0f );
		glVertex3f( -1.0f, 0.5f, 0.0f );
	} glEnd();
	
	[[self openGLContext] flushBuffer];
}
@end

Hopefully there’s SOMETHING in this to help… As far as I can tell, it’s the same (essientially) as the JOGL native code. T.T

–Scott

Update: I looked at the GLQuake code which supports FSAA, and aside from using what I THINK are Carbon-based GLContext modifier functions, it looks like there’s some issue with ATI hardware that requires byte shifting the number of samples >> 1. (Doesn’t this just multiply the value by two?) That’s the only thing I can see through the code thus far.

–Scott

Shifting 1 bit with the >> operator divides by two. Shifting 1 bit with the << operator multiplies by two. You should be able to test all of this with JOGL and see what configurations work given that the values set up in the GLCapabilities are passed through directly to the native code as you’ve already seen.

Poking around more: I’ve found that “GL_MULTISAMPLE” is not available on my system. gl.isExtensionAvailable( “GL_MULTISAMPLE” ) – and “GL_MULTISAMPLE_ARB” – returns false. However, gl.isExtensionAvailable( “GL_ARB_multisample” ); returns true. I cannot, however, use GL.GL_ARB_multisample, as it doesn’t seem to exist from within jogl.jar as I’ve built it from the source code.

I’ve also put several checks into the code to verify that it is, in fact, getting to the various points along the way of creating antialiasing context, which it appears to be doing correctly…

Here is the list of may available extensions, retrieved from gl.glGetString( GL.GL_EXTENSIONS ) :

GL_ARB_transpose_matrix GL_ARB_vertex_program GL_ARB_vertex_blend GL_ARB_window_pos GL_ARB_shader_objects GL_ARB_vertex_shader GL_EXT_multi_draw_arrays GL_EXT_clip_volume_hint GL_EXT_rescale_normal GL_EXT_draw_range_elements GL_EXT_fog_coord GL_APPLE_client_storage GL_APPLE_specular_vector GL_APPLE_transform_hint GL_APPLE_packed_pixels GL_APPLE_fence GL_APPLE_vertex_array_object GL_APPLE_vertex_program_evaluators GL_APPLE_element_array GL_APPLE_flush_render GL_NV_texgen_reflection GL_NV_light_max_exponent GL_IBM_rasterpos_clip GL_SGIS_generate_mipmap GL_ARB_shading_language_100 GL_ARB_imaging GL_ARB_point_parameters GL_ARB_texture_env_crossbar GL_ARB_texture_border_clamp GL_ARB_multitexture GL_ARB_texture_env_add GL_ARB_texture_cube_map GL_ARB_texture_env_dot3 GL_ARB_multisample GL_ARB_texture_env_combine GL_ARB_texture_compression GL_ARB_texture_mirrored_repeat GL_ARB_shadow GL_ARB_depth_texture GL_ARB_shadow_ambient GL_ARB_fragment_program GL_ARB_fragment_shader GL_ARB_occlusion_query GL_ARB_point_sprite GL_ARB_vertex_buffer_object GL_ARB_pixel_buffer_object GL_EXT_compiled_vertex_array GL_EXT_framebuffer_object GL_EXT_texture_rectangle GL_ARB_texture_rectangle GL_EXT_texture_env_add GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_texture_lod_bias GL_EXT_abgr GL_EXT_bgra GL_EXT_stencil_wrap GL_EXT_texture_filter_anisotropic GL_EXT_separate_specular_color GL_EXT_secondary_color GL_EXT_blend_func_separate GL_EXT_shadow_funcs GL_EXT_texture_compression_s3tc GL_EXT_texture_compression_dxt1 GL_EXT_blend_equation_separate GL_EXT_texture_mirror_clamp GL_APPLE_ycbcr_422 GL_APPLE_vertex_array_range GL_APPLE_texture_range GL_APPLE_float_pixels GL_ATI_texture_float GL_APPLE_pixel_buffer GL_NV_blend_square GL_NV_fog_distance GL_ATI_texture_mirror_once GL_ATI_text_fragment_shader GL_ATI_blend_equation_separate GL_ATI_blend_weighted_minmax GL_ATI_texture_env_combine3 GL_ATI_separate_stencil GL_ATI_texture_compression_3dc GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod GL_SGI_color_matrix

It appears none of the all-caps values are available… I don’t know enough, obviously, but my guess is that the al-caps ones ,ay not be considered “extensions”? This would also explain how GL_MULTISAMPLE and GL_MULTISAMPLE_ARB both turn up as false. Sorry I am not more knowledgable and thus better able to figure this all out on my own. I know it must be frustrating trying to work with me on this, but I really do appreciate that I’m getting any sort of responses.

Also, in my playing around, I changed gl-common.cfg to comment out the line that says “IgnoreExtension GL_ARB_multisample”, and then recompiled, but that alone doeasn’t seem to be making the extension available to me.

Thanks again for spending the time to work with me on this. If you want, send me a PM, and we can take this off the board, however.
–Scott

GL_ARB_multisample was folded into core OpenGL 1.3, and JOGL doesn’t expose extensions that were folded into 1.3 and earlier releases. If you want to do a dynamic test of whether multisampling is available, call gl.isExtensionAvailable(“GL_VERSION_1_3”). The naming convention for arguments to GL.isExtensionAvailable is the name of the extension or the name of the GL version as specified in glext.h or returned by glGetString(GL_EXTENSIONS).

The all-caps enumerated values are state bits, not extension names.

FYI, the problems with multisampling with JOGL on some OS X machines have been tracked down and fixed; see this thread.