Opened 12 years ago

Closed 11 years ago

#10545 closed defect (fixed)

Error with MacOSX glcanvas and FSAA

Reported by: g00fy Owned by:
Priority: normal Milestone:
Component: old wxOSX/Carbon port Version: stable-latest
Keywords: glcanvas opengl Cc:
Blocked By: Blocking:
Patch: yes



I am trying to create a GLCanvas with FSAA enabled (on MacOSX).

Step 1
I started with the cube sample. This showed a dice as it should be.

Step 2
Following the documentation, you should do for FSAA (4x multisampling):


I modified the cube sample to have this attribs [see patch at the bottom].

What do I see: nothing... Just a white/gray screen the size of the cube sample. But no dice.

Step 3
What did I do next... I reverted all the changes I did and went into glcanvas.cpp (carbon), modified the "defaultAttribs" to have additionaly:


This worked, I had supersampling (same result with AGL_MULTISAMPLE). I could see the dice again.

Step 4
I added some debug statements into the cube-sample. This resulted into the following:
When I used "NULL" as the attribList in the "wxGLCanvas" constructor, I got a list of glExtensions in "DrawRotatedCube". When I used my own attribList, I got an empty list.

Step 5
Investigating further, I added several debug statements into the "WXGLChoosePixelFormat" function. Somehow I got this result:

[WXGLChoosePixelFormat] 0: AGL_MINIMUM_POLICY (51) [arg=-2]
[WXGLChoosePixelFormat] attribList[arg]: 4
[WXGLChoosePixelFormat] 1: AGL_DOUBLEBUFFER (5) [arg=0]
[WXGLChoosePixelFormat] attribList[arg]: 1
[WXGLChoosePixelFormat] 2: AGL_RGBA (4) [arg=1]
[WXGLChoosePixelFormat] attribList[arg]: 3
[WXGLChoosePixelFormat] 3: AGL_LEVEL (3) [arg=2]
[WXGLChoosePixelFormat] 4: attribList[arg-1] (0) [arg=3]
[WXGLChoosePixelFormat] attribList[arg]: 17
[WXGLChoosePixelFormat] Using default policies
[WXGLChoosePixelFormat] @aglChoosePixelFormat
[IsAGLMultiSampleAvailable] s_isMultiSampleAvailable = 0
wxGLCanvas::IsAGLMultiSampleAvailable [WX_GL_SAMPLE_BUFFERS]: ok?
wxGLCanvas::IsAGLMultiSampleAvailable: failed

As you can see, the "IsExtensionSupported" returned an empty string... I think this is the base of the whole problem. Because in the cube sample I got a full extension list...

I think GL is somehow not 'started' at the moment where I pass my own attributes into the wxGLCanvas.

Thanks a lot,

Attachments (4)

glcanvas.patch download (9.5 KB) - added by g00fy 12 years ago.
Patch to reproduce the problem
IsExtensionSupported.patch download (2.0 KB) - added by g00fy 11 years ago.
fix-multi-sampling.diff download (4.9 KB) - added by g00fy 11 years ago.
glcanvas_osx.patch download (691 bytes) - added by g00fy 11 years ago.

Download all attachments as: .zip

Change History (10)

Changed 12 years ago by g00fy

Patch to reproduce the problem

comment:1 Changed 11 years ago by g00fy

  • Patch set

Hi, Roy Ratcliffe made a patch for this (attached "fix-multi-sampling.diff"). With this patch everything works ok for me.

At the same time I also made one to fix the "IsExtensionSupported" function ("IsExtensionSupported.patch"). The negative point here is that it only checks the main display.

Changed 11 years ago by g00fy

Changed 11 years ago by g00fy

comment:2 Changed 11 years ago by vadz

  • Status changed from new to infoneeded_new

AFAICS the first patch uses CG functions instead of agl ones. Does this mean that agl ones don't work any longer in OS X? I find it a bit hard to believe but I don't know anything about this stuff. In any case, WXGLCreateContext() should really be fixed itself IMO instead of adding workarounds here.

I'm also uncomfortable with the second patch: we really ought to fix IsAGLMultiSampleAvailable() instead of suppressing calls to it. And it seems that if the previous patch is applied this one wouldn't be needed at all, would it?

comment:3 Changed 11 years ago by g00fy

Hi Vadim,

You are right. Those patches are mutual exclusive with the "IsExtensionSupported.patch" a better patch as it isn't a workaround. I will check if I can achieve the same goal with agl calls and I'll let you know something.


Changed 11 years ago by g00fy

comment:4 Changed 11 years ago by g00fy

  • Status changed from infoneeded_new to new

Hi Vadim,

I attached a new patch. It looks like setting the created context (and of course returning to the previous setted context) solves the issue.

Could you have a look?


comment:5 Changed 11 years ago by VZ

(In [61273]) set the context we create in IsExtensionSupported() (see #10545)

comment:6 Changed 11 years ago by vadz

  • Resolution set to fixed
  • Status changed from new to closed

Thanks, the latest patch makes a lot of sense, applied now. If this is all we need to fix this bug, I'm happy.


Note: See TracTickets for help on using tickets.