aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-20 23:07:19 +0100
committerSven Gothel <[email protected]>2011-12-20 23:07:19 +0100
commita2ad741de1d9e784e2016184d07c2b7901f04f42 (patch)
treef89d8a834dce22621e2293d06aca21f3133a6275 /src/newt/classes
parentbaca92ef4cead762663efa61e81584c8a8ece7b4 (diff)
NEWT OSX: Add native ScreenMode impl. - TODO: Programmatically set the rotation! (How to ?)
Get/Set ScreenMode impl on OSX. Set is limited to resolution and size, since I don't know how to change the rotation.
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java58
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java6
2 files changed, 60 insertions, 4 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java b/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java
index 67a3f8e92..7785a5078 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2011 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,9 +34,14 @@
package jogamp.newt.driver.macosx;
-import com.jogamp.newt.*;
+import java.util.List;
+
+import javax.media.nativewindow.DefaultGraphicsScreen;
+
import jogamp.newt.ScreenImpl;
-import javax.media.nativewindow.*;
+
+import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.util.ScreenModeUtil;
public class MacScreen extends ScreenImpl {
static {
@@ -54,4 +60,52 @@ public class MacScreen extends ScreenImpl {
private static native int getWidthImpl0(int scrn_idx);
private static native int getHeightImpl0(int scrn_idx);
+
+ private int[] getScreenModeIdx(int idx) {
+ int[] modeProps = getScreenMode0(screen_idx, idx);
+ if (null == modeProps || 0 == modeProps.length) {
+ return null;
+ }
+ if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) {
+ throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length);
+ }
+ return modeProps;
+ }
+
+ private int nativeModeIdx;
+
+ protected int[] getScreenModeFirstImpl() {
+ nativeModeIdx = 0;
+ return getScreenModeNextImpl();
+ }
+
+ protected int[] getScreenModeNextImpl() {
+ int[] modeProps = getScreenModeIdx(nativeModeIdx);
+ if (null != modeProps && 0 < modeProps.length) {
+ nativeModeIdx++;
+ return modeProps;
+ }
+ return null;
+ }
+
+ protected ScreenMode getCurrentScreenModeImpl() {
+ int[] modeProps = getScreenModeIdx(-1);
+ if (null != modeProps && 0 < modeProps.length) {
+ return ScreenModeUtil.streamIn(modeProps, 0);
+ }
+ return null;
+ }
+
+ protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) {
+ final List<ScreenMode> screenModes = this.getScreenModesOrig();
+ final int screenModeIdx = screenModes.indexOf(screenMode);
+ if(0>screenModeIdx) {
+ throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode);
+ }
+ final int nativeModeIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx);
+ return setScreenMode0(screen_idx, nativeModeIdx);
+ }
+
+ private native int[] getScreenMode0(int screen_index, int mode_index);
+ private native boolean setScreenMode0(int screen_index, int mode_idx);
}
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
index 6566d72ec..ef06667ce 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,12 +33,13 @@
*/
package jogamp.newt.driver.windows;
+import javax.media.nativewindow.DefaultGraphicsScreen;
+
import jogamp.newt.ScreenImpl;
+
import com.jogamp.newt.ScreenMode;
import com.jogamp.newt.util.ScreenModeUtil;
-import javax.media.nativewindow.*;
-
public class WindowsScreen extends ScreenImpl {
static {