Class GLFWWindow
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum of window cursor modes.static classA dimension.static interfaceA drag 'n drop event listener interface.static classAn implementation ofGLFWWindow.InputListenerthat provides a blank, no-op implementation so that only the desired functions need overriding.static interfaceAn input event listener interface.static classA single point.static classA single point, floating-point.static classA rectangle bound.static classWindow characteristic state that can be fetched outside of the main thread.static classAn implementation ofGLFWWindow.WindowListenerthat provides a blank, no-op implementation so that only the desired functions need overriding.static interfaceA window event listener interface. -
Constructor Summary
ConstructorsConstructorDescriptionGLFWWindow(GLFWWindowHints hints, GLFWMonitor monitor, GLFWWindow sharedWindow, String title, int width, int height) Creates a new GLFW window, sharing its OpenGL resources with another window.GLFWWindow(GLFWWindowHints hints, GLFWMonitor monitor, String title, int width, int height) Creates a new GLFW window.GLFWWindow(GLFWWindowHints hints, GLFWWindow sharedWindow, String title, int width, int height) Creates a new GLFW window, sharing its OpenGL resources with another window.GLFWWindow(GLFWWindowHints hints, String title, int width, int height) Creates a new GLFW window. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDropListener(GLFWWindow.DropListener listener) Adds aGLFWWindow.DropListenerto this window for listening for window events.voidaddInputListener(GLFWWindow.InputListener listener) Adds anGLFWWindow.InputListenerto this window for listening for window events.voidaddWindowListener(GLFWWindow.WindowListener listener) Adds aGLFWWindow.WindowListenerto this window for listening for window events.voidcenter(GLFWMonitor monitor) Sets this window's position (upper-left coordinate) to center of the screen using its current size and a monitor.voiddestroy()Destroys this handle.voidfocus()Requests focus on the window.Gets the content scale for the specified window.Gets the frame buffer size.Gets the window's frame size.longSets the current monitor for this window.floatgetOpacity(float scalar) Gets the window opacity.Gets this window's position (upper-left coordinate).getSize()Gets this window's size.getState()Gets a window characteristic state that can be fetched outside of the main polling thread.voidiconify()Iconifies the window.booleanChecks the closing flag of this window.booleanvoidmaximize()Maximizes the window.voidremoveDropListener(GLFWWindow.DropListener listener) Removes aGLFWWindow.DropListenerfrom this window.voidremoveInputListener(GLFWWindow.InputListener listener) Removes anGLFWWindow.InputListenerfrom this window.voidRemoves aGLFWWindow.WindowListenerfrom this window.voidSignals user attention from this window.voidrestore()Restores the window.voidsetAspectRatio(int numer, int denom) Sets this window's aspect ratio limits.voidsetAutoIconified(boolean value) Sets if this window is iconified on creation.voidsetClosing(boolean state) Sets the closing flag of this window (aka "window should close").voidsetCursor(GLFWCursor cursor) Sets this window's cursor.voidsetCursorMode(GLFWWindow.CursorMode cursorMode) Sets this window's cursor mode.voidsetDecorated(boolean value) Sets if this window is decorated (has shell bordering).voidsetFloating(boolean value) Sets if this window is floating, or rather, "always on top".voidsetFocusOnShow(boolean value) Sets if this window requests focus when shown.voidsetIcon(BufferedImage icon) Sets this window's icon.voidsetLockKeyMods(boolean enabled) Sets if the lock keys pass their modifier bits to the input system.voidsetMonitor(GLFWMonitor monitor, int xpos, int ypos, int width, int height, int refreshRate) Sets the target monitor for this window in fullscreen mode.voidsetOpacity(float scalar) Sets the window opacity.voidsetPosition(int x, int y) Sets this window's position (upper-left coordinate).voidsetRawMouseMotion(boolean enabled) Sets if the mouse motion on this window is raw, no acceleration applied.voidsetResizable(boolean value) Sets if this window is resizable (via user, not program).voidsetSize(int width, int height) Sets this window's size.voidsetSizeLimits(int minwidth, int minheight, int maxwidth, int maxheight) Sets the size limits of the content area of the specified window.voidsetStickyKeys(boolean enabled) Sets if sticky keys is enabled.voidsetStickyMouseButtons(boolean enabled) Sets if sticky mouse buttons is enabled.voidSets this window's title.voidsetVisible(boolean state) Sets the visibility of the window.voidSwaps the front and back buffer on the window, redrawing its contents to the foreground.
-
Constructor Details
-
GLFWWindow
Creates a new GLFW window.This must only be called from the main thread.
- Parameters:
hints- the hints to use for the window.title- the window title.width- the window's initial width.height- the window's initial height.- Throws:
GLFWException- if the window could not be created.- See Also:
-
GLFWWindow
public GLFWWindow(GLFWWindowHints hints, GLFWWindow sharedWindow, String title, int width, int height) Creates a new GLFW window, sharing its OpenGL resources with another window.This must only be called from the main thread.
- Parameters:
hints- the hints to use for the window.sharedWindow- the window to share OpenGL resources with.title- the window title.width- the window's initial width.height- the window's initial height.- Throws:
GLFWException- if the window could not be created.- See Also:
-
GLFWWindow
Creates a new GLFW window.This must only be called from the main thread.
- Parameters:
hints- the hints to use for the window.monitor- the monitor to use for fullscreen mode.title- the window title.width- the window's initial width.height- the window's initial height.- Throws:
GLFWException- if the window could not be created.- See Also:
-
GLFWWindow
public GLFWWindow(GLFWWindowHints hints, GLFWMonitor monitor, GLFWWindow sharedWindow, String title, int width, int height) Creates a new GLFW window, sharing its OpenGL resources with another window.This must only be called from the main thread.
- Parameters:
hints- the hints to use for the window.monitor- the monitor to use for fullscreen mode.sharedWindow- the window to share OpenGL resources with.title- the window title.width- the window's initial width.height- the window's initial height.- Throws:
GLFWException- if the window could not be created.- See Also:
-
-
Method Details
-
getHandle
public long getHandle()- Specified by:
getHandlein classGLFWHandle- Returns:
- this handle's GLFW address handle.
-
isCreated
public boolean isCreated()- Specified by:
isCreatedin classGLFWHandle- Returns:
- true if this handle was allocated, false if not.
-
destroy
public void destroy()Description copied from class:GLFWHandleDestroys this handle. Does nothing if already destroyed.- Specified by:
destroyin classGLFWHandle
-
addWindowListener
Adds aGLFWWindow.WindowListenerto this window for listening for window events. Events are dispatched to listeners in the order added. This method is thread safe.- Parameters:
listener- the listener to add.
-
removeWindowListener
Removes aGLFWWindow.WindowListenerfrom this window. This method is thread safe.- Parameters:
listener- the listener to remove.
-
addInputListener
Adds anGLFWWindow.InputListenerto this window for listening for window events. Events are dispatched to listeners in the order added. This method is thread safe.- Parameters:
listener- the listener to add.
-
removeInputListener
Removes anGLFWWindow.InputListenerfrom this window. This method is thread safe.- Parameters:
listener- the listener to remove.
-
addDropListener
Adds aGLFWWindow.DropListenerto this window for listening for window events. Events are dispatched to listeners in the order added. This method is thread safe.- Parameters:
listener- the listener to add.
-
removeDropListener
Removes aGLFWWindow.DropListenerfrom this window. This method is thread safe.- Parameters:
listener- the listener to remove.
-
setMonitor
public void setMonitor(GLFWMonitor monitor, int xpos, int ypos, int width, int height, int refreshRate) Sets the target monitor for this window in fullscreen mode.This must only be called from the main thread.
- Parameters:
monitor- the desired monitor, or null to set windowed mode.xpos- the desired x-coordinate of the upper-left corner of the content area.ypos- the desired y-coordinate of the upper-left corner of the content area.width- the desired width in screen coordinates of the content area or video mode.height- the desired height in screen coordinates of the content area or video mode.refreshRate- the desired refresh rate in Hz of the video mode, orGLFWWindowHints.DONT_CARE
-
getMonitor
Sets the current monitor for this window.- Returns:
- the current monitor, or null if none.
-
setTitle
Sets this window's title.This must only be called from the main thread.
- Parameters:
title- the new title.
-
setIcon
Sets this window's icon. Only works in non-macOS environments. In macOS, the application bundle icons are used.This must only be called from the main thread.
- Parameters:
icon- the new icon.
-
setCursor
Sets this window's cursor.- Parameters:
cursor- the cursor.This must only be called from the main thread.
-
setCursorMode
Sets this window's cursor mode.- Parameters:
cursorMode- the cursor mode.This must only be called from the main thread.
-
setRawMouseMotion
public void setRawMouseMotion(boolean enabled) Sets if the mouse motion on this window is raw, no acceleration applied. Only works if the cursor mode isGLFWWindow.CursorMode.DISABLED.This must only be called from the main thread.
- Parameters:
enabled- true to enable, false to disable.
-
setStickyKeys
public void setStickyKeys(boolean enabled) Sets if sticky keys is enabled.This must only be called from the main thread.
- Parameters:
enabled- true to enable, false to disable.
-
setStickyMouseButtons
public void setStickyMouseButtons(boolean enabled) Sets if sticky mouse buttons is enabled.This must only be called from the main thread.
- Parameters:
enabled- true to enable, false to disable.
-
setLockKeyMods
public void setLockKeyMods(boolean enabled) Sets if the lock keys pass their modifier bits to the input system.This must only be called from the main thread.
- Parameters:
enabled- true to enable, false to disable.
-
center
Sets this window's position (upper-left coordinate) to center of the screen using its current size and a monitor.This must only be called from the main thread.
- Parameters:
monitor- the monitor to center on.- See Also:
-
iconify
public void iconify()Iconifies the window. Fires an event to listeners, but only when GLFW's Poll Events function is called.This must only be called from the main thread.
-
restore
public void restore()Restores the window. Fires an event to listeners, but only when GLFW's Poll Events function is called.This must only be called from the main thread.
-
maximize
public void maximize()Maximizes the window. Fires an event to listeners, but only when GLFW's Poll Events function is called.This must only be called from the main thread.
-
setVisible
public void setVisible(boolean state) Sets the visibility of the window. Fires an event to listeners, but only when GLFW's Poll Events function is called.This must only be called from the main thread.
- Parameters:
state- true to show, false to hide.
-
focus
public void focus()Requests focus on the window. Fires an event to listeners, but only when GLFW's Poll Events function is called.This must only be called from the main thread.
-
requestAttention
public void requestAttention()Signals user attention from this window. Fires an event to listeners, but only when GLFW's Poll Events function is called.This must only be called from the main thread.
-
isClosing
public boolean isClosing()Checks the closing flag of this window.This can be called from any thread.
- Returns:
- true if set, false if not.
-
setClosing
public void setClosing(boolean state) Sets the closing flag of this window (aka "window should close").This can be called from any thread.
- Parameters:
state- the closing state.
-
setPosition
public void setPosition(int x, int y) Sets this window's position (upper-left coordinate).This must only be called from the main thread.
- Parameters:
x- the x-coordinate.y- the y-coordinate.- See Also:
-
getPosition
Gets this window's position (upper-left coordinate).This must only be called from the main thread.
- Returns:
- a Point representing the current window position.
-
setSize
public void setSize(int width, int height) Sets this window's size.This must only be called from the main thread.
- Parameters:
width- the new width in pixels.height- the new height in pixels.
-
getSize
Gets this window's size.This must only be called from the main thread.
- Returns:
- a Dimension representing the current window size/dimensions.
-
setSizeLimits
public void setSizeLimits(int minwidth, int minheight, int maxwidth, int maxheight) Sets the size limits of the content area of the specified window.This must only be called from the main thread.
- Parameters:
minwidth- the minimum width in screen coordinates of the content area, orGLFWWindowHints.DONT_CAREminheight- the minimum height in screen coordinates of the content area, orGLFWWindowHints.DONT_CAREmaxwidth- the maximum width in screen coordinates of the content area, orGLFWWindowHints.DONT_CAREmaxheight- the maximum height in screen coordinates of the content area, orGLFWWindowHints.DONT_CARE
-
setOpacity
public void setOpacity(float scalar) Sets the window opacity.This must only be called from the main thread.
- Parameters:
scalar- the new opacity scalar.
-
getOpacity
public float getOpacity(float scalar) Gets the window opacity.This must only be called from the main thread.
- Parameters:
scalar- the new opacity scalar.- Returns:
- the window opacity.
-
setAspectRatio
public void setAspectRatio(int numer, int denom) Sets this window's aspect ratio limits.This must only be called from the main thread.
- Parameters:
numer- the numerator of the desired aspect ratio, orGLFWWindowHints.DONT_CAREdenom- the denominator of the desired aspect ratio, orGLFWWindowHints.DONT_CARE
-
setDecorated
public void setDecorated(boolean value) Sets if this window is decorated (has shell bordering).This must only be called from the main thread.
- Parameters:
value- true if so, false if not.
-
setResizable
public void setResizable(boolean value) Sets if this window is resizable (via user, not program).This must only be called from the main thread.
- Parameters:
value- true if so, false if not.
-
setAutoIconified
public void setAutoIconified(boolean value) Sets if this window is iconified on creation.This must only be called from the main thread.
- Parameters:
value- true if so, false if not.
-
setFloating
public void setFloating(boolean value) Sets if this window is floating, or rather, "always on top".This must only be called from the main thread.
- Parameters:
value- true if so, false if not.
-
setFocusOnShow
public void setFocusOnShow(boolean value) Sets if this window requests focus when shown.This must only be called from the main thread.
- Parameters:
value- true if so, false if not.
-
getFramebufferSize
Gets the frame buffer size.This must only be called from the main thread.
- Returns:
- a Dimension that represents the framebuffer size.
-
getFrameSize
Gets the window's frame size.This must only be called from the main thread.
- Returns:
- a Rectangle that represents the framebuffer size (x, y, width, height).
-
getContentScale
Gets the content scale for the specified window. The content scale is the ratio between the current DPI and the platform's default DPI. Depends on monitor.- Returns:
- the scalars.
-
getState
Gets a window characteristic state that can be fetched outside of the main polling thread. The reference returned is the only instance - the values on this object can change frequently.- Returns:
- this window's characteristics, set from the last event poll.
-
swapBuffers
public void swapBuffers()Swaps the front and back buffer on the window, redrawing its contents to the foreground. If a swap interval is set, the system may wait for a set of vertical blank signals before this happens, and will block until they occur.This is only necessary for OpenGL/GLES contexts.
This can be called from any thread.
- See Also:
-