The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
ShapedWindow MAC OSX issues
ebol


Joined: 31 Mar 2014
Posts: 2
Hello,

I'm currently porting my SDL based app from Windows to Mac. Sadly, neither my code nor the example provided in testshape.c works on my Mac (both cases are working on Windows).

The version from testshape.c just displays the whole window covered in black & white texture. My version, which uses png file with transparency, draws to the window only the non-transparent pixels (correct) but the rest of the window remains painted with "RenderDrawColor".

My working environment: SDL version 2.0.3, OSX 10.9.2, Xcode 5.1.

Any ideas what can cause this problem? Are ShapedWindows fully implemented on Windows, Mac and Linux or some of the platforms are still work-in-progress? Thanks in advance!
ShapedWindow MAC OSX issues
Jeffrey Carpenter
Guest

Hi,

The shaped window implementation is currently broken / incomplete under Mac OS X (dunno about other platforms!), see [Bug 2257 - Shaped Windows under Mac OS X](https://bugzilla.libsdl.org/show_bug.cgi?id=2257) for details on why & what.

Unfortunately, I do not know nearly enough about those low-level details ;-(

Cheers,
Jeffrey Carpenter


On 2014/03/ 31, at 9:58, ebol wrote:

Quote:
Hello,

I'm currently porting my SDL based app from Windows to Mac. Sadly, neither my code nor the example provided in testshape.c works on my Mac (both cases are working on Windows).

The version from testshape.c just displays the whole window covered in black & white texture. My version, which uses png file with transparency, draws to the window only the non-transparent pixels (correct) but the rest of the window remains painted with "RenderDrawColor".

My working environment: SDL version 2.0.3, OSX 10.9.2, Xcode 5.1.

Any ideas what can cause this problem? Are ShapedWindows fully implemented on Windows, Mac and Linux or some of the platforms are still work-in-progress? Thanks in advance!
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
ebol


Joined: 31 Mar 2014
Posts: 2
Thanks for the info! Fortunately I'm not depending on this feature for anything mayor, just a splash screen. So worst case scenario would be a rectangular splash image instead of fancy transparent one, I can live with that Wink But seriously, I'll take a look at how SDL implements this on MAC OS, but I'm a no cocoa wizard, so I'm not sure I'll be able to patch it up.
ShapedWindow MAC OSX issues
Eric Wing
Guest

On 4/3/14, ebol wrote:
Quote:
Thanks for the info! Fortunately I'm not depending on this feature for
anything mayor, just a splash screen. So worst case scenario would be a
rectangular splash image instead of fancy transparent one, I can live with
that Wink But seriously, I'll take a look at how SDL implements this on MAC
OS, but I'm a no cocoa wizard, so I'm not sure I'll be able to patch it up.

I haven't looked at the code, but based on what Sam said, it sounds
like the Mac compositing system is the problem and my instinct is that
the only way around it is to move to Core Animation CALayers for
everything. (Think of a CALayer as Apple's own GPU render-to-texture
system.) In Cocoa, everything that draws is an NSView, which includes
the thing you see as the window visuals in NSWindow. In Core
Animation, an NSView is separated from the drawing is is actually
comprised of one or more CALayers (think OpenGL textured quad). In
10.6, there was a subclass called CAShapeLayer which lets you make
fancy shapes which might be suitable for masking. But the reason this
might work around the problem is that CALayer fits the OpenGL/hardware
accelerated rendering model so it makes interplaying with OpenGL work
much better. If you want to put native UI (like a NSButton) on top of
an OpenGL view on Mac (or iOS), Core Animation is the one and only way
it is done.

However, Core Animation opens up a totally different can of worms.
There were lots of serious bugs in it early on and since SDL still
supports 10.5, this will probably be a headache. And there are subtle
behavior differences between the traditional system and CALayer system
(and also an intermediate system called Layer-Backed Views).

I think a Core Animation compatible version of SDL would be cool and
useful moving forward, but I also think it will be some work to
actually implement correctly.


-Eric
--
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
ShapedWindow MAC OSX issues
Andreas Schiffler
Guest

Shaped window support was added a few years back as a GSoC project to
SDL 1.2 and is probably the source of the current SDL2 code. The shape
support code was adapted from an official Apple shaped-window sample
pretty much 1:1. I recall that our student spend weeks trying to get the
OSX shaped window support working under SDL and we could never figure
out why it did not work while GSoC was still on.

It may be worthwhile to write some prototype code that shapes an
existing SDL window to verify that it can be done at all.

On 4/3/2014 4:03 AM, Eric Wing wrote:
Quote:
On 4/3/14, ebol wrote:
Quote:
Thanks for the info! Fortunately I'm not depending on this feature for
anything mayor, just a splash screen. So worst case scenario would be a
rectangular splash image instead of fancy transparent one, I can live with
that Wink But seriously, I'll take a look at how SDL implements this on MAC
OS, but I'm a no cocoa wizard, so I'm not sure I'll be able to patch it up.
I haven't looked at the code, but based on what Sam said, it sounds
like the Mac compositing system is the problem and my instinct is that
the only way around it is to move to Core Animation CALayers for
everything. (Think of a CALayer as Apple's own GPU render-to-texture
system.) In Cocoa, everything that draws is an NSView, which includes
the thing you see as the window visuals in NSWindow. In Core
Animation, an NSView is separated from the drawing is is actually
comprised of one or more CALayers (think OpenGL textured quad). In
10.6, there was a subclass called CAShapeLayer which lets you make
fancy shapes which might be suitable for masking. But the reason this
might work around the problem is that CALayer fits the OpenGL/hardware
accelerated rendering model so it makes interplaying with OpenGL work
much better. If you want to put native UI (like a NSButton) on top of
an OpenGL view on Mac (or iOS), Core Animation is the one and only way
it is done.

However, Core Animation opens up a totally different can of worms.
There were lots of serious bugs in it early on and since SDL still
supports 10.5, this will probably be a headache. And there are subtle
behavior differences between the traditional system and CALayer system
(and also an intermediate system called Layer-Backed Views).

I think a Core Animation compatible version of SDL would be cool and
useful moving forward, but I also think it will be some work to
actually implement correctly.


-Eric

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
ShapedWindow MAC OSX issues
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
The problem is that when the SDL OpenGL context is swapped, it replaces the full contents of the window view, clobbering the alpha channel set up by the shaping code.  I don't know of anyone who has mixed OpenGL and shaped windows on Mac OS X successfully. Please let us know if you discover how to do this!


On Thu, Apr 3, 2014 at 11:13 PM, Andreas Schiffler wrote:
Quote:
Shaped window support was added a few years back as a GSoC project to SDL 1.2 and is probably the source of the current SDL2 code. The shape support code was adapted from an official Apple shaped-window sample pretty much 1:1. I recall that our student spend weeks trying to get the OSX shaped window support working under SDL and we could never figure out why it did not work while GSoC was still on.

It may be worthwhile to write some prototype code that shapes an existing SDL window to verify that it can be done at all.

On 4/3/2014 4:03 AM, Eric Wing wrote:
Quote:
On 4/3/14, ebol wrote:
Quote:
Thanks for the info! Fortunately I'm not depending on this feature for
anything mayor, just a splash screen. So worst case scenario would be a
rectangular splash image instead of fancy transparent one, I can live with
that Wink But seriously, I'll take a look at how SDL implements this on MAC
OS, but I'm a no cocoa wizard, so I'm not sure I'll be able to patch it up.
I haven't looked at the code, but based on what Sam said, it sounds
like the Mac compositing system is the problem and my instinct is that
the only way around it is to move to Core Animation CALayers for
everything. (Think of a CALayer as Apple's own GPU render-to-texture
system.) In Cocoa, everything that draws is an NSView, which includes
the thing you see as the window visuals in NSWindow. In Core
Animation, an NSView is separated from the drawing is is actually
comprised of one or more CALayers (think OpenGL textured quad). In
10.6, there was a subclass called CAShapeLayer which lets you make
fancy shapes which might be suitable for masking. But the reason this
might work around the problem is that CALayer fits the OpenGL/hardware
accelerated rendering model so it makes interplaying with OpenGL work
much better. If you want to put native UI (like a NSButton) on top of
an OpenGL view on Mac (or iOS), Core Animation is the one and only way
it is done.

However, Core Animation opens up a totally different can of worms.
There were lots of serious bugs in it early on and since SDL still
supports 10.5, this will probably be a headache. And there are subtle
behavior differences between the traditional system and CALayer system
(and also an intermediate system called Layer-Backed Views).

I think a Core Animation compatible version of SDL would be cool and
useful moving forward, but I also think it will be some work to
actually implement correctly.


-Eric



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org