forked from empirephoenix/JME3-JFX
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce DisplayInfo interface to have read access of "Display" for …
…jogl and lwjgl
- Loading branch information
Showing
7 changed files
with
258 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.jme3.system.jogl; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import org.lwjgl.opengl.Display; | ||
|
||
import com.jme3x.jfx.DisplayInfo; | ||
import com.jogamp.newt.event.WindowEvent; | ||
import com.jogamp.newt.event.WindowListener; | ||
import com.jogamp.newt.event.WindowUpdateEvent; | ||
import com.jogamp.newt.opengl.GLWindow; | ||
|
||
public class DisplayInfo_Jogl implements DisplayInfo { | ||
final AtomicBoolean resized = new AtomicBoolean(false); | ||
final GLWindow canvas; | ||
|
||
public DisplayInfo_Jogl(JoglNewtAbstractDisplay d) { | ||
this(d.canvas); | ||
} | ||
|
||
public DisplayInfo_Jogl(GLWindow canvas) { | ||
super(); | ||
this.canvas = canvas; | ||
canvas.addWindowListener(new WindowListener() { | ||
|
||
@Override | ||
public void windowResized(WindowEvent e) { | ||
resized.set(true); | ||
} | ||
|
||
@Override | ||
public void windowRepaint(WindowUpdateEvent e) { | ||
} | ||
|
||
@Override | ||
public void windowMoved(WindowEvent e) { | ||
} | ||
|
||
@Override | ||
public void windowLostFocus(WindowEvent e) { | ||
} | ||
|
||
@Override | ||
public void windowGainedFocus(WindowEvent e) { | ||
} | ||
|
||
@Override | ||
public void windowDestroyed(WindowEvent e) { | ||
} | ||
|
||
@Override | ||
public void windowDestroyNotify(WindowEvent e) { | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public int getWidth() { | ||
return canvas.getWidth(); | ||
} | ||
|
||
@Override | ||
public int getHeight() { | ||
return canvas.getHeight(); | ||
} | ||
|
||
@Override | ||
public int getX() { | ||
return canvas.getX(); | ||
} | ||
|
||
@Override | ||
public int getY() { | ||
return canvas.getY(); | ||
} | ||
|
||
@Override | ||
public boolean isFullscreen() { | ||
return canvas.isFullscreen(); | ||
} | ||
|
||
@Override | ||
public AtomicBoolean wasResized() { | ||
return resized; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.jme3x.jfx; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
public interface DisplayInfo { | ||
int getWidth(); | ||
int getHeight(); | ||
int getX(); | ||
int getY(); | ||
boolean isFullscreen(); | ||
AtomicBoolean wasResized(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.jme3x.jfx; | ||
|
||
import com.jme3.app.Application; | ||
import com.jme3.system.JmeContext; | ||
import com.jme3.system.jogl.DisplayInfo_Jogl; | ||
|
||
public class DisplayInfoProvider { | ||
|
||
public static DisplayInfo find(Application app) { | ||
JmeContext ctx = app.getContext(); | ||
if (ctx.getClass().getName().startsWith("com.jme3.system.jogl.JoglNewt")) { | ||
return new DisplayInfo_Jogl((com.jme3.system.jogl.JoglNewtAbstractDisplay) ctx); | ||
} | ||
if (ctx.getClass().getName().startsWith("com.jme3.system.lwjgl")) { | ||
return new DisplayInfo_Lwjgl(); | ||
} | ||
return new DisplayInfo_AppSettings(ctx.getSettings()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.jme3x.jfx; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import org.lwjgl.opengl.Display; | ||
|
||
import com.jme3.system.AppSettings; | ||
|
||
class DisplayInfo_AppSettings implements DisplayInfo { | ||
final AtomicBoolean resized = new AtomicBoolean(false); | ||
final AppSettings settings; | ||
|
||
public DisplayInfo_AppSettings(AppSettings settings) { | ||
super(); | ||
this.settings = settings; | ||
} | ||
|
||
@Override | ||
public int getWidth() { | ||
return settings.getWidth(); | ||
} | ||
|
||
@Override | ||
public int getHeight() { | ||
return settings.getHeight(); | ||
} | ||
|
||
/** | ||
* Always return 0; (not supported by avoid throwing exception) | ||
*/ | ||
@Override | ||
public int getX() { | ||
return 0; | ||
} | ||
|
||
/** | ||
* Always return 0; (not supported by avoid throwing exception) | ||
*/ | ||
@Override | ||
public int getY() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean isFullscreen() { | ||
return settings.isFullscreen(); | ||
} | ||
|
||
@Override | ||
public AtomicBoolean wasResized() { | ||
return resized; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.jme3x.jfx; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import org.lwjgl.opengl.Display; | ||
|
||
class DisplayInfo_Lwjgl implements DisplayInfo { | ||
final AtomicBoolean resized = new AtomicBoolean(false); | ||
|
||
public DisplayInfo_Lwjgl() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public int getWidth() { | ||
return Display.getWidth(); | ||
} | ||
|
||
@Override | ||
public int getHeight() { | ||
return Display.getHeight(); | ||
} | ||
|
||
@Override | ||
public int getX() { | ||
return Display.getX(); | ||
} | ||
|
||
@Override | ||
public int getY() { | ||
return Display.getY(); | ||
} | ||
|
||
@Override | ||
public boolean isFullscreen() { | ||
return Display.isFullscreen(); | ||
} | ||
|
||
@Override | ||
public AtomicBoolean wasResized() { | ||
resized.set(Display.wasResized()); | ||
return resized; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.