Package com.jme3.system.lwjgl
Class LwjglWindow
java.lang.Object
com.jme3.system.lwjgl.LwjglContext
com.jme3.system.lwjgl.LwjglWindow
- All Implemented Interfaces:
JmeContext
,Runnable
- Direct Known Subclasses:
LwjglOffscreenBufferVR
A wrapper class over the GLFW framework in LWJGL 3.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.jme3.system.JmeContext
JmeContext.Type
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected boolean
protected final AtomicBoolean
protected final AtomicBoolean
protected boolean
Fields inherited from class com.jme3.system.lwjgl.LwjglContext
clContext, clPlatform, created, createdLock, joyInput, keyInput, listener, mouseInput, renderable, renderer, settings, THREAD_NAME, timer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
create
(boolean waitFor) Creates the context and makes it active.protected void
createContext
(AppSettings settings) Apply the settings, changing resolution, etc.protected void
De-initialize in the OpenGL thread.void
destroy
(boolean waitFor) Destroys the context completely, making it inactive.protected void
Destroy the context.int
Returns the height of the framebuffer.int
Returns the width of the framebuffer.getType()
getWindowContentScale
(Vector2f store) Get the window content scale, for HiDPI support.long
int
Returns the screen X coordinate of the left edge of the content area.int
Returns the screen Y coordinate of the top edge of the content area.protected boolean
Does LWJGL display initialization in the OpenGL threadvoid
registerWindowSizeListener
(WindowSizeListener listener) Registers the specified listener to get notified when window size changes.void
removeWindowSizeListener
(WindowSizeListener listener) Removes the specified listener from the listeners list.void
restart()
Restart if it's a windowed or full-screen display.void
run()
protected void
runLoop()
execute one iteration of the render loop in the OpenGL threadvoid
setAutoFlushFrames
(boolean enabled) void
Set the title if it's a windowed displayprotected void
setWindowIcon
(AppSettings settings) Set custom icons to the window of this application.protected void
Methods inherited from class com.jme3.system.lwjgl.LwjglContext
create, createContextAttribs, destroy, determineMaxSamples, getGLVersion, getNumSamplesToUse, getOpenCLContext, getRenderer, getSettings, getSystemListener, getTimer, initContextFirstTime, initOpenCL, internalCreate, internalDestroy, isCreated, isRenderable, loadNatives, printContextInitInfo, reinitContext, setSettings, setSystemListener, waitFor
-
Field Details
-
needClose
-
needRestart
-
wasActive
protected boolean wasActive -
autoFlush
protected boolean autoFlush -
allowSwapBuffers
protected boolean allowSwapBuffers
-
-
Constructor Details
-
LwjglWindow
-
-
Method Details
-
registerWindowSizeListener
Registers the specified listener to get notified when window size changes.- Parameters:
listener
- The WindowSizeListener to register.
-
removeWindowSizeListener
Removes the specified listener from the listeners list.- Parameters:
listener
- The WindowSizeListener to remove.
-
getType
- Specified by:
getType
in interfaceJmeContext
- Returns:
- Type.Display or Type.Canvas
-
setTitle
Set the title if it's a windowed display- Specified by:
setTitle
in interfaceJmeContext
- Parameters:
title
- the title to set
-
restart
public void restart()Restart if it's a windowed or full-screen display.- Specified by:
restart
in interfaceJmeContext
-
createContext
Apply the settings, changing resolution, etc.- Parameters:
settings
- the settings to apply when creating the context.
-
showWindow
protected void showWindow() -
setWindowIcon
Set custom icons to the window of this application.- Parameters:
settings
- settings for getting the icons
-
destroyContext
protected void destroyContext()Destroy the context. -
create
public void create(boolean waitFor) Description copied from interface:JmeContext
Creates the context and makes it active.- Specified by:
create
in interfaceJmeContext
- Parameters:
waitFor
- If true, will wait until context has initialized.
-
initInThread
protected boolean initInThread()Does LWJGL display initialization in the OpenGL thread- Returns:
- returns
true
if the context initialization was successful
-
runLoop
protected void runLoop()execute one iteration of the render loop in the OpenGL thread -
deinitInThread
protected void deinitInThread()De-initialize in the OpenGL thread. -
run
public void run() -
getJoyInput
- Specified by:
getJoyInput
in interfaceJmeContext
- Returns:
- Joystick input implementation. May be null if not available.
-
getMouseInput
- Specified by:
getMouseInput
in interfaceJmeContext
- Returns:
- Mouse input implementation. May be null if not available.
-
getKeyInput
- Specified by:
getKeyInput
in interfaceJmeContext
- Returns:
- Keyboard input implementation. May be null if not available.
-
getTouchInput
- Specified by:
getTouchInput
in interfaceJmeContext
- Returns:
- Touch device input implementation. May be null if not available.
-
setAutoFlushFrames
public void setAutoFlushFrames(boolean enabled) - Specified by:
setAutoFlushFrames
in interfaceJmeContext
- Parameters:
enabled
- If enabled, the context will automatically flush frames to the video card (swap buffers) after an update cycle.
-
destroy
public void destroy(boolean waitFor) Description copied from interface:JmeContext
Destroys the context completely, making it inactive.- Specified by:
destroy
in interfaceJmeContext
- Parameters:
waitFor
- If true, will wait until the context is destroyed fully.
-
getWindowHandle
public long getWindowHandle() -
getWindowContentScale
Get the window content scale, for HiDPI support. The content scale is the ratio between the current DPI and the platform's default DPI. This is especially important for text and any UI elements. If the pixel dimensions of your UI scaled by this look appropriate on your machine then it should appear at a reasonable size on other machines regardless of their DPI and scaling settings. This relies on the system DPI and scaling settings being somewhat correct.- Parameters:
store
- A vector2f to store the result- Returns:
- The window content scale
- See Also:
-
getFramebufferHeight
public int getFramebufferHeight()Returns the height of the framebuffer.- Specified by:
getFramebufferHeight
in interfaceJmeContext
- Overrides:
getFramebufferHeight
in classLwjglContext
- Returns:
- the height (in pixels)
-
getFramebufferWidth
public int getFramebufferWidth()Returns the width of the framebuffer.- Specified by:
getFramebufferWidth
in interfaceJmeContext
- Overrides:
getFramebufferWidth
in classLwjglContext
- Returns:
- the width (in pixels)
-
getWindowXPosition
public int getWindowXPosition()Returns the screen X coordinate of the left edge of the content area.- Specified by:
getWindowXPosition
in interfaceJmeContext
- Overrides:
getWindowXPosition
in classLwjglContext
- Returns:
- the screen X coordinate
-
getWindowYPosition
public int getWindowYPosition()Returns the screen Y coordinate of the top edge of the content area.- Specified by:
getWindowYPosition
in interfaceJmeContext
- Overrides:
getWindowYPosition
in classLwjglContext
- Returns:
- the screen Y coordinate
-