PDA

View Full Version : GL_ARB_multisample



roadkillguy
04-11-2012, 10:30 PM
So I'm trying to use multisampling to hopefully help some of the jaggedness my application currently has. Unfortunately, glEnable(GL_ARB_multisample) appears to make no difference on my final image. Is this the correct way to use it?

Using glxinfo it appears my system supports GL_ARB_multisample, so I'm not sure what's wrong here.

Aleksandar
04-12-2012, 12:36 AM
You need to create a "multisampled" rendering target. Choose pixel format that supports multi-sampling (with appropriate MS factor), or a FBO.

Ilian Dinev
04-12-2012, 01:45 AM
Also note that glEnable(GL_MULTISAMPLE) will change nothing, as it's enabled by default.

glEnable(GL_ARB_multisample); // is something invalid

Dark Photon
04-12-2012, 07:44 AM
Also note that glEnable(GL_MULTISAMPLE) will change nothing, as it's enabled by default.

Right. Just to clarify the above, you need both of the above to do proper multisample rasterization and downsample filtering:

Create a multisampled render target glEnable( GL_MULTISAMPLE ) (or just leave it enabled)

And I have no idea what you're talking about with glEnable( GL_ARB_multisample ). GL_ARB_multisample is the name of an OpenGL extension and not a GL state enable. In glext.h, it is a preprocessor symbol used to prevent multiple includes and is defined to 1 like all other similar preprocessor lock symbols. Your glEnable would translate to glEnable(1) which probably isn't even valid. It's not what you want anyway.

trinitrotoluene
04-12-2012, 07:49 AM
Also note that glEnable(GL_MULTISAMPLE) will change nothing, as it's enabled by default.

glEnable(GL_ARB_multisample); // is something invalid

I have an AMD Radeon HD 5870 under Ubuntu and multisampling is not enabled by default with a multisample renderbuffer attached to a FBO. I must call glEnable(GL_MULTISAMPLE) explicitly. On the default framebuffer too I need to explicitly enable multisampling. But unfortunately, since catalyst 11.7 multisampling on the default framebuffer is not working for me.

roadkillguy
04-12-2012, 09:53 AM
I see. I didn't know it was an include safety. Either way, given that I have this opengl extension, shouldn't I be able to enable multisampling?

After a bit more research, I'm finding SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2); fails with "Couldn't find matching GLX visual" when SDL_SetVideoMode() is called. Maybe it's in my x settings?

trinitrotoluene
04-12-2012, 11:27 AM
Did you set also this:


SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1);


To get the number of samples available call
glGetIntegerv(GL_SAMPLES,&samples);

On my old computer with nvidia TNT2 with the mesa OpenGL software driver, the extension GL_ARB_multisample was supported but with only one sample per pixel. So check the visual available with glxinfo.In the last column (ms), there is the (ns = number of samples) and (b=number of multisample buffer) listed.

roadkillguy
04-12-2012, 11:58 AM
As it turns out, both MULTISAMPLEBUFFERS and MULTISAMPLESAMPLES throw that error. GL_SAMPLES appears to be zero. Maybe my system doesn't support it?

EDIT: It has zero in both ns and b throughout the entire list. I guess I misinterpreted GL_ARB_MULTISAMPLE being listed as an extension under server, client, GLX, and OpenGL, extensions as supporting it. I do have an integrated graphics card, but it was worth trying. :D

Ilian Dinev
04-12-2012, 03:22 PM
I have an AMD Radeon HD 5870 under Ubuntu and multisampling is not enabled by default with a multisample renderbuffer attached to a FBO. I must call glEnable(GL_MULTISAMPLE) explicitly. On the default framebuffer too I need to explicitly enable multisampling.
That's a driver bug then. The spec clearly states that GL_DITHER and GL_MULTISAMPLE are GL_TRUE by default.

roadkillguy
04-12-2012, 05:07 PM
Is GL_ARB_multisample unrelated to number of samples and buffer support then?

Alfonse Reinheart
04-12-2012, 05:47 PM
Multisampling is a function of the framebuffer. However, OpenGL does not define the contents of the default framebuffer; the stuff that initializes an OpenGL context does. So you need to use those APIs to make multisampling possible, and then use what's in GL_ARB_multisample to activate multisampled rendering.

trinitrotoluene
04-12-2012, 06:28 PM
I have an AMD Radeon HD 5870 under Ubuntu and multisampling is not enabled by default with a multisample renderbuffer attached to a FBO. I must call glEnable(GL_MULTISAMPLE) explicitly. On the default framebuffer too I need to explicitly enable multisampling.
That's a driver bug then. The spec clearly states that GL_DITHER and GL_MULTISAMPLE are GL_TRUE by default.

So I have at least two driver bugs (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=302230#Post3022 30). I decided to send my problem to the AMD linux driver crew last week. At least, I have another (easy) way to remove jagged edge with FBO.

roadkillguy
04-16-2012, 12:35 AM
In essence, I have an opengl extension I can't use?

Alfonse Reinheart
04-16-2012, 01:03 AM
Define "can't use".

What you can and cannot use is based on what you're doing. You don't have to create a multisampled default framebuffer to do multisampled rendering, but you do have to have some framebuffer (whether an FBO or the default) that has multisampled images in it to render with multisampling.

If SDL isn't able to give you a multisampled framebuffer, then it sounds like you either need to use something else to create your context or build multisampled images manually and use FBOs. You can blit to the non-multisampled default framebuffer.