Package dev.prozilla.pine.core
Class Window
java.lang.Object
dev.prozilla.pine.core.Window
- All Implemented Interfaces:
Destructible,Initializable,Printable
- Direct Known Subclasses:
HeadlessWindow
Represents a GLFW window object.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks if the window has been initialized.voiddestroy()Destroys the window.intlonggetId()floatfloatgetSize()intgetWidth()voidinit()Sets the window hints and creates a GLFW window object.voidvoidsetCenterCursor(boolean centerCursor) Sets the value of theWindowHint.CENTER_CURSORwindow hint.voidsetDecorated(boolean decorated) Sets the value of theWindowHint.DECORATEDwindow hint.voidResets all window hints to their default values.voidsetEnableTransparentFramebuffer(boolean enableTransparentFramebuffer) Sets the value of theWindowHint.ENABLE_TRANSPARENT_FRAMEBUFFERwindow hint.voidsetFloating(boolean floating) Sets the value of theWindowHint.FLOATINGwindow hint.voidsetFocused(boolean focused) Sets the value of theWindowHint.FOCUSEDwindow hint.voidsetFullscreen(boolean fullscreen) Toggles the fullscreen mode of this window.voidsetHint(int hint, boolean value) Sets the value of the given window hint.voidsetHint(int hint, int value) Sets the value of the given window hint.voidsetHint(WindowHint hint, boolean value) Sets the value of the given window hint.voidsetHint(WindowHint hint, int value) Sets the value of the given window hint.voidUpdates the icons of this window.voidsetMaximized(boolean maximized) Sets the value of theWindowHint.MAXIMIZEDwindow hint.voidsetOpacity(float opacity) Sets the opacity of the entire window.voidsetResizable(boolean resizable) Sets the value of theWindowHint.RESIZABLEwindow hint.voidUpdates the title of this window.voidsetVisible(boolean visible) Sets the value of theWindowHint.VISIBLEwindow hint.booleanDetermines whether the window should be closed.@NotNull StringtoString()Returns a string representation of this object.voidupdate()Swaps the buffers and polls the events each frame.
-
Field Details
-
width
public int width -
height
public int height -
isInitialized
protected boolean isInitialized
-
-
Constructor Details
-
Window
-
-
Method Details
-
init
Sets the window hints and creates a GLFW window object.- Specified by:
initin interfaceInitializable- Throws:
RuntimeException
-
update
public void update()Swaps the buffers and polls the events each frame. -
input
-
destroy
public void destroy()Destroys the window.- Specified by:
destroyin interfaceDestructible
-
shouldClose
public boolean shouldClose()Determines whether the window should be closed.- Returns:
trueif the window should be closed.
-
getSize
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getId
public long getId() -
setTitle
Updates the title of this window.- Parameters:
title- Title
-
setFullscreen
public void setFullscreen(boolean fullscreen) Toggles the fullscreen mode of this window.- Parameters:
fullscreen- Whether to enable or disable fullscreen mode
-
setIcons
Updates the icons of this window. Uses the first element of the images array as the default icon.- Parameters:
images- Array of icon images
-
setOpacity
public void setOpacity(float opacity) Sets the opacity of the entire window.- Parameters:
opacity- The opacity, in the range of0fand1f
-
setDecorated
public void setDecorated(boolean decorated) Sets the value of theWindowHint.DECORATEDwindow hint.- Parameters:
decorated- The value to use
-
setVisible
public void setVisible(boolean visible) Sets the value of theWindowHint.VISIBLEwindow hint.- Parameters:
visible- The value to use
-
setEnableTransparentFramebuffer
public void setEnableTransparentFramebuffer(boolean enableTransparentFramebuffer) Sets the value of theWindowHint.ENABLE_TRANSPARENT_FRAMEBUFFERwindow hint.- Parameters:
enableTransparentFramebuffer- The value to use
-
setResizable
public void setResizable(boolean resizable) Sets the value of theWindowHint.RESIZABLEwindow hint.- Parameters:
resizable- The value to use
-
setFocused
public void setFocused(boolean focused) Sets the value of theWindowHint.FOCUSEDwindow hint.- Parameters:
focused- The value to use
-
setFloating
public void setFloating(boolean floating) Sets the value of theWindowHint.FLOATINGwindow hint.- Parameters:
floating- The value to use
-
setMaximized
public void setMaximized(boolean maximized) Sets the value of theWindowHint.MAXIMIZEDwindow hint.- Parameters:
maximized- The value to use
-
setCenterCursor
public void setCenterCursor(boolean centerCursor) Sets the value of theWindowHint.CENTER_CURSORwindow hint.- Parameters:
centerCursor- The value to use
-
setHint
Sets the value of the given window hint.- Parameters:
hint- The window hint to set the value ofvalue- The value to use- See Also:
-
setHint
Sets the value of the given window hint.- Parameters:
hint- The window hint to set the value ofvalue- The value to use- See Also:
-
setHint
public void setHint(int hint, boolean value) Sets the value of the given window hint.- Parameters:
hint- The window hint to set the value ofvalue- The value to use- See Also:
-
setHint
public void setHint(int hint, int value) Sets the value of the given window hint.The window hints determine how the next window will be created. Invalid values will only cause an error when the next window is created.
Some hints will only have an effect on specific platforms and will be ignored on other platforms.
- Parameters:
hint- The window hint to set the value ofvalue- The value to use
-
setDefaultHints
public void setDefaultHints()Resets all window hints to their default values. -
checkStatus
Checks if the window has been initialized.- Throws:
IllegalStateException- If the window has not been initialized yet.
-
getPixelRatioX
public float getPixelRatioX() -
getPixelRatioY
public float getPixelRatioY() -
toString
Description copied from interface:PrintableReturns a string representation of this object.
-