Hello Mike,

There is the issue 8005668 security control panel got greyed out when access Mac machine remotely using VNC
     http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8005668

After a little investigation we have found that an animation does not work for the NSOpenGLLayer if a user uses VNC connection
  and the MAC OS X does not have connected monitors.

    Here are steps to reproduce which use only Cocoa application:
  - Connect to an Mac OS X with VNC
  - Detach all monitors from the Mac OS X (I used a Mac mini)
  - Run the code below
   The animation does not work

The output shows that the drawInCGLContext method has been invoked only once or twice:
  ------------------------------------------------------------------
2013-02-01 19:21:27.488 OpenGLLayerSample[1731:707] invalid drawable
2013-02-01 19:21:27.489 OpenGLLayerSample[1731:707] drawInCGLContext
2013-02-01 19:21:27.513 OpenGLLayerSample[1731:707] drawInCGLContext
  ------------------------------------------------------------------

 Connection a monitor to the Mac OS X makes the animation work.

It seems that it can have a relation to the issue 8005668 so the first time there is nothing to draw and next time nothing is drawn on a Java app.
 Is it a known issue and could it have a workaround?

 Thanks,
 Alexandr.

  ------------------------------------------------------------------
    NSRect rect = NSMakeRect (200, 200, 300, 300);
    unsigned int styleMask = NSTitledWindowMask
    | NSMiniaturizableWindowMask;


    NSWindow *myWindow = [NSWindow alloc];
    myWindow = [myWindow initWithContentRect: rect
                                   styleMask: styleMask
                                     backing: NSBackingStoreBuffered
                                       defer: NO];

    NSView *view  = [[NSView alloc] initWithFrame:rect];

    view.layer = [CALayer layer];
    view.wantsLayer = YES;
    CALayer *newLayer = [CALayer layer];
    newLayer.backgroundColor = CGColorGetConstantColor(kCGColorBlack);
    newLayer.position  = CGPointMake(150,150);
    newLayer.frame = NSMakeRect(100,100,100,100);
    [view.layer addSublayer:newLayer];

    // do some custom GL drawing
    RotatingSquareGLLayer *caGLLayer = [RotatingSquareGLLayer layer];
    caGLLayer.asynchronous = YES;
    //[caGLLayer drawsAsynchronously: YES];
    caGLLayer.position  = CGPointMake(150,150);
    caGLLayer.frame = NSMakeRect(100,100,100,100);
    caGLLayer.asynchronous = YES;
    [view.layer addSublayer:caGLLayer];

    [myWindow setContentView: view];

    [myWindow setTitle: @"Main Window"];
    [myWindow makeKeyAndOrderFront: nil];




@interface RotatingSquareGLLayer : NSOpenGLLayer { }

@end

#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>
#import <QTKit/QTKit.h>

@implementation RotatingSquareGLLayer

// override to draw custom GL content
-(void)drawInCGLContext:(CGLContextObj)glContext
            pixelFormat:(CGLPixelFormatObj)pixelFormat
           forLayerTime:(CFTimeInterval)timeInterval
            displayTime:(const CVTimeStamp *)timeStamp {

    NSLog(@"drawInCGLContext");
    //*
    // set the current context
    CGLSetCurrentContext(glContext);

    // draw a single red quad spinning around based on the current time
    GLfloat rotate = timeInterval * 60.0; // 60 degrees per second
    glClear(GL_COLOR_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glRotatef(rotate, 0.0, 0.0, 1.0);
    glBegin(GL_QUADS);
    glColor3f(1.0, 0.0, 0.0);
    glVertex2f(-0.5, -0.5);
    glVertex2f(-0.5,  0.5);
    glVertex2f( 0.5,  0.5);
    glVertex2f( 0.5, -0.5);
    glEnd();
    glPopMatrix();
    //*/
// call super to finalize the drawing - by default all it does is call glFlush() [super drawInCGLContext:glContext pixelFormat:pixelFormat forLayerTime:timeInterval displayTime:timeStamp];
}

@end
 ------------------------------------------------------------------

Reply via email to