aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m')
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m62
1 files changed, 44 insertions, 18 deletions
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
index 7ce8c58cf..fb6fd18e9 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
@@ -194,7 +194,9 @@ extern GLboolean glIsVertexArray (GLuint array);
texIDArg: (GLuint) texID
opaque: (Bool) opaque
texWidth: (int) texWidth
- texHeight: (int) texHeight;
+ texHeight: (int) texHeight
+ winWidth: (int)winWidth
+ winHeight: (int)winHeight;
- (void)releaseLayer;
- (void)deallocPBuffer;
@@ -206,7 +208,7 @@ extern GLboolean glIsVertexArray (GLuint array);
- (Bool)isGLSourceValid;
- (void) setGLEnabled: (Bool) enable;
-- (Bool) validateTexSize: (CGRect) lRect;
+- (Bool) validateTexSize: (int)newTexWidth height:(int)newTexHeight;
- (void) setTextureID: (int) _texID;
- (Bool) isSamePBuffer: (NSOpenGLPixelBuffer*) p;
@@ -274,7 +276,9 @@ static const GLfloat gl_verts[] = {
texIDArg: (GLuint) texID
opaque: (Bool) opaque
texWidth: (int) _texWidth
- texHeight: (int) _texHeight;
+ texHeight: (int) _texHeight
+ winWidth: (int) _winWidth
+ winHeight: (int) _winHeight
{
pthread_mutexattr_t renderLockAttr;
pthread_mutexattr_init(&renderLockAttr);
@@ -288,6 +292,13 @@ static const GLfloat gl_verts[] = {
gl_texCoords[i] = 0.0f;
}
}
+ if( _texWidth != _winWidth ) {
+NS_DURING
+ // Available >= 10.7
+ [self setContentsScale: (CGFloat)_texWidth/(CGFloat)_winWidth];
+NS_HANDLER
+NS_ENDHANDLER
+ }
parentPixelFmt = [_parentPixelFmt retain]; // until destruction
glContext = [[MyNSOpenGLContext alloc] initWithFormat:parentPixelFmt shareContext:parentCtx];
gl3ShaderProgramName = _gl3ShaderProgramName;
@@ -301,8 +312,8 @@ static const GLfloat gl_verts[] = {
shallDraw = NO;
isGLEnabled = YES;
dedicatedFrameSet = NO;
- dedicatedFrame = CGRectMake(0, 0, _texWidth, _texHeight);
- [self validateTexSize: dedicatedFrame];
+ dedicatedFrame = CGRectMake(0, 0, _winWidth, _winHeight);
+ [self validateTexSize: _texWidth height:_texHeight];
[self setTextureID: texID];
newPBuffer = NULL;
@@ -383,15 +394,17 @@ static const GLfloat gl_verts[] = {
isGLEnabled = enable;
}
-- (Bool) validateTexSize: (CGRect) lRect
+- (Bool) validateTexSize: (int)newTexWidth height:(int)newTexHeight
{
- const int lRectW = (int) (lRect.size.width + 0.5f);
- const int lRectH = (int) (lRect.size.height + 0.5f);
Bool changed;
- if( lRectH != texHeight || lRectW != texWidth ) {
- texWidth = lRectW;
- texHeight = lRectH;
+ if( newTexHeight != texHeight || newTexWidth != texWidth ) {
+ #ifdef VERBOSE_ON
+ const int oldTexWidth = texWidth;
+ const int oldTexHeight = texHeight;
+ #endif
+ texWidth = newTexWidth;
+ texHeight = newTexHeight;
changed = YES;
GLfloat texCoordWidth, texCoordHeight;
@@ -415,10 +428,14 @@ static const GLfloat gl_verts[] = {
gl_texCoords[4] = texCoordWidth;
gl_texCoords[6] = texCoordWidth;
#ifdef VERBOSE_ON
- DBG_PRINT("MyNSOpenGLLayer::validateTexSize %p -> tex %dx%d, bounds: %lf/%lf %lfx%lf (%dx%d), dedicatedFrame set:%d %lf/%lf %lfx%lf\n",
- self, texWidth, texHeight,
- lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, lRectW, lRectH,
- dedicatedFrameSet, dedicatedFrame.origin.x, dedicatedFrame.origin.y, dedicatedFrame.size.width, dedicatedFrame.size.height);
+NS_DURING
+ // Available >= 10.7
+ DBG_PRINT("MyNSOpenGLLayer::validateTexSize %p: tex %dx%d -> %dx%d, dedicatedFrame set:%d %lf/%lf %lfx%lf scale %lf\n",
+ self, oldTexWidth, oldTexHeight, newTexWidth, newTexHeight,
+ dedicatedFrameSet, dedicatedFrame.origin.x, dedicatedFrame.origin.y, dedicatedFrame.size.width, dedicatedFrame.size.height,
+ [self contentsScale]);
+NS_HANDLER
+NS_ENDHANDLER
#endif
} else {
changed = NO;
@@ -638,7 +655,15 @@ static const GLfloat gl_verts[] = {
GLenum textureTarget;
- Bool texSizeChanged = [self validateTexSize: ( dedicatedFrameSet ? dedicatedFrame : [self bounds] ) ];
+ CGRect texDim = dedicatedFrameSet ? dedicatedFrame : [self bounds];
+ CGFloat _contentsScale = 1;
+NS_DURING
+ // Available >= 10.7
+ _contentsScale = [self contentsScale];
+NS_HANDLER
+NS_ENDHANDLER
+ Bool texSizeChanged = [self validateTexSize: (int)(texDim.size.width * _contentsScale + 0.5f)
+ height:(int)(texDim.size.height * _contentsScale + 0.5f)];
if( texSizeChanged ) {
[context update];
}
@@ -873,9 +898,10 @@ static const GLfloat gl_verts[] = {
@end
-NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, int gl3ShaderProgramName, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight) {
+NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, int gl3ShaderProgramName, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight, int winWidth, int winHeight) {
return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx gl3ShaderProgramName: (GLuint)gl3ShaderProgramName pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID
- opaque: opaque texWidth: texWidth texHeight: texHeight];
+ opaque: opaque texWidth: texWidth texHeight: texHeight
+ winWidth: winWidth winHeight: winHeight];
}
void setNSOpenGLLayerEnabled(NSOpenGLLayer* layer, Bool enable) {