Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Jan 18, 2013, 04:42 AM   #1
macrumors newbie
Join Date: Aug 2010
CALayer approach in jre7

Hi all,

I have a java application which opens upa window calls functions in a native library to draw using OpenGL.
I have done this by getting the NSView of the window using:

JAWT_MacOSXDrawingSurfaceInfo* ads_macsfinfo = (JAWT_MacOSXDrawingSurfaceInfo*)ads_sfinfo->platformInfo;
//gets the object responsible for drawing associated with the view obtained from the Java AWT surface
parent_view = (ads_macsfinfo->cocoaViewRef);

Then a customized NSview is added as subview to this view using:
[parent_view addSubview: customview]
Drawing is done offscreen in an FBO and then drawing is displayed by copying the texture to onscreen in drawrect. (drawrect being forced using setNeedsDisplay]
This all was functioning perfectly until JRE 7, the NSView approach is no longer possible and instead the CALayer must be used.

I am thus trying to create the same customised NSView as before (now withouthout having parent view and window) and setting this as layer backed using:
[customview setWantsLayer:YES]
The layer which has now been added to the nsview (view.layer), is then set as the layer property of JAWT_SurfaceLayers using

id<JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)macosx_dsi->platformInfo;
if(surfaceLayers.layer == NULL) {
surfaceLayers.layer = viewlayer;

However the function drawrect is only called once eventhough I am calling [customview setNeedsDisplay:YES]
as well as no events are being received on the nsview.

Is this the proper way of setting the connection between the layer and view?

Thanks for any help
LeanneAttard is offline   0 Reply With Quote
Old May 28, 2013, 05:06 AM   #2
macrumors newbie
Join Date: May 2013

Did you manage to get this working??
If so, could you please share some advices?!
nonod is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
CALayer backed anchorPoint property is not .5, .5 by default? Duncan C Mac Programming 0 Jun 7, 2013 07:12 PM
I don't know how I should approach this.. Xexis MacBook Pro 2 May 31, 2013 05:01 PM
Difference between UIView's drawRect and CALayer? Apple souce iPhone/iPad Programming 2 Nov 2, 2012 03:05 PM

Forum Jump

All times are GMT -5. The time now is 01:08 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC