Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Antialias and glAccum slowness (Just me?)  (Read 4695 times)
0 Members and 1 Guest are viewing this topic.
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Posted 2006-03-06 13:24:40 »

Hello,

Sorry for the terribly noob-esque inquiry, but I was just playing with glAccum in my jogl program, to implement an antialiasing solution, 'cause why not, and I noticed it's VERY slow indeed.  I am rendering simply 4 shaped cubes each frame, and using 4 to 8 passes with the accumulation buffer (using the example code from the red book, 3rd edition) slows me down to right about 6/8 FPS on my brand new intel iMac.

2.0 GHz Intel Core Duo
1 GB RAM
ATI Radeon X1600 256MB
PCI Express

The standard upgraded one.

I ran also Apple's OpenGL Profiler, and it's spending about 90+ percent of the OpenGL time in glAccum(...).  So, then is this an expectable drop for any situation, a slowdown due to the binding of native code to Java, an artifact of the build to Intel code, a known JOGL bug, or perhaps I'm just being stupid and trying for antialiasing the entirely wrong way...?

Anyhow, let me know what you think of, so's I can stop wandering around ignorant.

--Scott
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2006-03-06 14:29:00 »

Accumulation buffers are only supported in hardware on some really shiny new cards, I'm not sure if yours comes under that or not. If it's not supported in hardware you'll get the software fallback with is (unsurprisingly) very slow.

To get antialiasing you usually need to create a framebuffer with a specified number of samples (usually 2/4/6/8) and everything is pretty much automatic after that point. In LWJGL this just means setting the samples param at display creation, but I'm not sure how Jogl handles this (or even if it's supported yet).

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline GKW

Senior Member




Revenge is mine!


« Reply #2 - Posted 2006-03-06 18:07:39 »

JOGL does support FSAA.  Take a look at setSampleBuffers and setNumSamples in GLCapabilities.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #3 - Posted 2006-03-07 01:17:23 »

JOGL does support FSAA.  Take a look at setSampleBuffers and setNumSamples in GLCapabilities.

Cool.  FWIW, this was actually the first thing I tried, but I must've missed something on the way.  All I could figure out how to do was:

GLCapabilities caps = new GLCapabilities();
caps.setSampleBuffers( true );
caps.setNumSamples( 4 );

...and to then use this capabilities in GLCanvas canvas = new GLCanvas( caps );...  But it wasn't doing any antialiasing, so I went back to the Red Book... ^^;;

What should I be putting elsewhere in the code to either get FSAA turned on or to draw into a framebuffer to do it by hand?  I couldn't find anything on this online or here on the forum, though I'll look again.

--edit---  I saw some suggestions to do:
gl.glEnable( GL.GL_MULTISAMPLE_ARB );
...render
gl.glDisabe( GL.GL_MULTISAMPLE_ARB );

but I could not find a reference for that in the javadocs, and my compiler can't find it either...
--/edit---

--Scott
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #4 - Posted 2006-03-07 07:00:29 »

Did you check out the demos.multisample.Multisample demo in the jogl-demos workspace? Does it work on your machine?
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #5 - Posted 2006-03-07 08:56:57 »

Thanks for that tip.  Apparently, no, it doesn't work.  I checked the demo and the source, and the source is what I've been trying, and the demo doesn't run correctly, because there's no AA in the one that's supposed to have it.  Has anyone seen this on MacOS X before?  Seems like someone ought to address this, either at Apple or elsewhere...  Now I guess I'd better write a Cocoa app to check whether or not my mac will do it at all...  I checked the OpenGL Driver Monitor, and it says that Multisample is available, Max Sample Buffers = 1, and Max Samples = 6...

That seems like it should be able to do it, yes?  Also, I know that WoW can do some kind of AA that they call MSAA...?  Any idea how that's done, perhaps?  Or why Blizzard doesn't use FSAA?

--Scott
Offline bytor39

Junior Newbie





« Reply #6 - Posted 2006-03-07 19:11:32 »

Well, if nothing works you can always do Wu's algorithm. Wink

There's a link to one of Micheal Abrash's articles on that page that explains it exquisitly.

This is, of course, all in jest.  But it's kind of fun if you enjoy doing that kind of stuff.
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #7 - Posted 2006-03-07 23:31:26 »

Thanks for that tip.  Apparently, no, it doesn't work.  I checked the demo and the source, and the source is what I've been trying, and the demo doesn't run correctly, because there's no AA in the one that's supposed to have it.  Has anyone seen this on MacOS X before?  Seems like someone ought to address this, either at Apple or elsewhere...  Now I guess I'd better write a Cocoa app to check whether or not my mac will do it at all...  I checked the OpenGL Driver Monitor, and it says that Multisample is available, Max Sample Buffers = 1, and Max Samples = 6...

I just tried the JOGL multisample demo on my office Mac (G5, NVidia GeForce 6800) and it works fine. What JOGL are you running on your Intel-based Mac? Have you set things up to build JOGL out of the CVS repository? I don't know how up-to-date gziemski's Universal JOGL binaries are and we aren't yet set up to provide Universal binaries in JOGL's nightly builds.
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #8 - Posted 2006-03-07 23:40:40 »

I think the build of his (I didn't make it myself, though will try when I get home) was from a couple of weeks ago.  There's a new one I might try, but I'll look into grabbing the CVS source and building it myself.

I know FSAA works, though, as I recently downloaded the (PPC) build of GLQuake which newly supports FSAA, and it runs beautifully, barring rosetta input slowdowns.

I'll let you know.

--Scott
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #9 - Posted 2006-03-08 02:59:10 »

Okay, I went and compiled everything by hand, and the demos RUN, but the multisample demos still does not do any antialiasing. >.<

*sigh*  Any more suggestions...?  Maybe it's an Apple or ATI problem?

--Scott
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CommanderKeith
« Reply #10 - Posted 2006-03-08 03:21:55 »

Hi,
I'm embarking on learning JOGL too and just to confuse things I've got some questions.  After seeing these problems with simple anti-aliasing I'm worried.  

I am moving away from Java2D in games because its only good when its accelerated and its acceleration is incredibly moody (scaling and too much anti-aliasing destroys acceleration).  I only want to use JOGL for 2D graphics (ortho mode).

I've got 2 questions:
Q1    Is JOGL finished & reliable and is it possible for a beginner to do things like anti-aliasing, scaling & texture painting without spending months learning the API?

Q2   What proportion of computers have OpenGL and can interface with JOGL?  (I'm suspicious because on some computers that I've run my Java2D game using the OGL pipeline there was no hardware acceleration).  If OpenGL isn't supported, is my JOGL-coded game stuffed?

Thanks,
Keith

Offline Ken Russell

JGO Coder




Java games rock!


« Reply #11 - Posted 2006-03-08 05:12:46 »

Okay, I went and compiled everything by hand, and the demos RUN, but the multisample demos still does not do any antialiasing.

Are you 100% sure about this based on the visual output, or from some message being printed to stdout? The GLCapabilitiesChooser functionality isn't all there on OS X so any messages printed by the demo to stdout aren't likely to be correct.

What JDK version are you running? If the current 5.0 developer preview, have you tried 1.4.2?

Quote
*sigh*  Any more suggestions...?  Maybe it's an Apple or ATI problem?

Do you have another Mac to test on? Things work fine on my PPC based Mac with NVidia hardware, but there are obviously two major differences between this configuration and yours.
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #12 - Posted 2006-03-08 07:09:50 »

I just tried Java 1.4.2, and I get the same result.  Also, I am 100% sure (visually) that there is no AA going on in the multisample demo on my machine.  All pixels are only WHITE or BLACK.  There is no gray along the edges of the lines whatsoever.  This is using JVM 1.4.2, also.

Should I go into something to print out capabilities?  I know that GL_ARB_multisample is available, as I've checked for that one on my machine already.  (using gl.isExtensionAvailable( "GL_ARB_multisample" )Wink

--Scott
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #13 - Posted 2006-03-08 08:33:24 »

Hmm. I wonder whether there's a stupid bug in the Multisample demo. Could you try calling gl.glEnable(GL.GL_MULTISAMPLE) in Listener.init() in Multisample.java? It looks like it assumes GL_MULTISAMPLE is enabled by default which probably isn't guaranteed. (Ideally Listener's constructor would take a boolean indicating whether to enable GL_MULTISAMPLE, but this should at least test whether FSAA is working through JOGL on your machine.)
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #14 - Posted 2006-03-09 10:13:19 »

Hmm. I wonder whether there's a stupid bug in the Multisample demo. Could you try calling gl.glEnable(GL.GL_MULTISAMPLE) in Listener.init() in Multisample.java?
Just tried that, (sorry it took so long) and it doesn't seem to work still.  Also, I tried my same code (same build and everything) on another Mac (12" PoerBook from a year ago), and I got the antialiasing just fine.

--Scott
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #15 - Posted 2006-03-09 23:57:44 »

Since you have the ability to build the source tree could you try modifying MacOSWindowSystemInterface.m (in jogl/src/native/jogl/)? In the arm reading "if (sampleBuffers != 0)", try adding some code setting the NSOpenGLPFAMultisample attribute to YES, rebuild and see whether that changes the Multisample demo's results.
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #16 - Posted 2006-03-11 02:21:13 »

I tried adding that as you said, but I get a compile-time error, and ant doesn't seem to want to give me more detailed info on gcc's compile-error. >.<

Here's the code arm you're talking about:
1  
2  
3  
4  
5  
6  
if (sampleBuffers != 0)
{
   NSOpenGLPFAMultisample = YES;
   attribs[idx++] =   NSOpenGLPFASampleBuffers; attribs[idx++] = sampleBuffers;
   attribs[idx++] =   NSOpenGLPFASamples;       attribs[idx++] = numSamples;
}


I noticed in XCode that there's no auto-complete option for NSOpenGLPFAMultisample, though there is for several other things, so it looks like it's seeing connections.  I also tried adding
1  
#import <AppKit/NSOpenGL.h>
to the top, as that's where it seems to be refferenced, but that didn't work either.  I'm sure it's just a simple thing I've missed.

--Scott
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #17 - Posted 2006-03-12 00:26:03 »

No, it should look like
1  
2  
3  
4  
5  
6  
7  
if (sampleBuffers != 0)
{
   attribs[idx++] =   NSOpenGLPFASampleBuffers; attribs[idx++] = sampleBuffers;
   attribs[idx++] =   NSOpenGLPFASamples;       attribs[idx++] = numSamples;
   attribs[idx++] =   NSOpenGLPFAMultisample ;
   attribs[idx++] =   YES;
}

Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #18 - Posted 2006-03-12 08:08:16 »

Okay, sorry 'bout the mustake.  I made the change and still nothing changes in the multisample demo...

--Scott

PS:  Sorry for being so difficult... T_T
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #19 - Posted 2006-03-13 00:27:02 »

OK, thanks for trying this. I really don't know what's going on; I would think that if you are getting full-screen antialiasing with other OpenGL programs then JOGL's support for this should just work. If you have a small example of a Cocoa app which achieves antialiasing on your machine then please post it and we can try to diagnose further what's going on. Unfortunately I don't have the time at the moment to go to Apple's Compatibility Lab in Cupertino to try to work on the same kind of machine you're on. You may also want to post on the mac-opengl mailing list since this appears to be an issue specific to the Intel-based Macs.
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #20 - Posted 2006-03-13 10:21:04 »

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. >.>

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
#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
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #21 - Posted 2006-03-15 09:18:56 »

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
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #22 - Posted 2006-03-15 20:37:29 »

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.

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.
Offline Lareon

Senior Newbie




I program for fun... Isn't that weird?!?


« Reply #23 - Posted 2006-03-16 09:56:33 »

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
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #24 - Posted 2006-03-16 20:17:14 »

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.
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #25 - Posted 2006-03-29 04:26:59 »

FYI, the problems with multisampling with JOGL on some OS X machines have been tracked down and fixed; see this thread.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (12 views)
2014-07-24 01:59:36

Riven (10 views)
2014-07-23 21:16:32

Riven (11 views)
2014-07-23 21:07:15

Riven (12 views)
2014-07-23 20:56:16

ctomni231 (42 views)
2014-07-18 06:55:21

Zero Volt (38 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (34 views)
2014-07-16 23:30:00

Cero (50 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!