Class Window

java.lang.Object
dev.prozilla.pine.core.Window
All Implemented Interfaces:
Destructible, Initializable, Printable
Direct Known Subclasses:
HeadlessWindow

public class Window extends Object implements Initializable, Destructible, Printable
Represents a GLFW window object.
  • Field Details

    • width

      public int width
    • height

      public int height
    • isInitialized

      protected boolean isInitialized
  • Constructor Details

  • Method Details

    • init

      public void init() throws RuntimeException
      Sets the window hints and creates a GLFW window object.
      Specified by:
      init in interface Initializable
      Throws:
      RuntimeException
    • update

      public void update()
      Swaps the buffers and polls the events each frame.
    • input

      public void input(Input input)
    • destroy

      public void destroy()
      Destroys the window.
      Specified by:
      destroy in interface Destructible
    • shouldClose

      public boolean shouldClose()
      Determines whether the window should be closed.
      Returns:
      true if the window should be closed.
    • getSize

      public Vector2i getSize()
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • getId

      public long getId()
    • setTitle

      public void setTitle(String title)
      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

      public void setIcons(Image[] images)
      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 of 0f and 1f
    • setDecorated

      public void setDecorated(boolean decorated)
      Sets the value of the WindowHint.DECORATED window hint.
      Parameters:
      decorated - The value to use
    • setVisible

      public void setVisible(boolean visible)
      Sets the value of the WindowHint.VISIBLE window hint.
      Parameters:
      visible - The value to use
    • setEnableTransparentFramebuffer

      public void setEnableTransparentFramebuffer(boolean enableTransparentFramebuffer)
      Sets the value of the WindowHint.ENABLE_TRANSPARENT_FRAMEBUFFER window hint.
      Parameters:
      enableTransparentFramebuffer - The value to use
    • setResizable

      public void setResizable(boolean resizable)
      Sets the value of the WindowHint.RESIZABLE window hint.
      Parameters:
      resizable - The value to use
    • setFocused

      public void setFocused(boolean focused)
      Sets the value of the WindowHint.FOCUSED window hint.
      Parameters:
      focused - The value to use
    • setFloating

      public void setFloating(boolean floating)
      Sets the value of the WindowHint.FLOATING window hint.
      Parameters:
      floating - The value to use
    • setMaximized

      public void setMaximized(boolean maximized)
      Sets the value of the WindowHint.MAXIMIZED window hint.
      Parameters:
      maximized - The value to use
    • setCenterCursor

      public void setCenterCursor(boolean centerCursor)
      Sets the value of the WindowHint.CENTER_CURSOR window hint.
      Parameters:
      centerCursor - The value to use
    • setHint

      public void setHint(WindowHint hint, boolean value)
      Sets the value of the given window hint.
      Parameters:
      hint - The window hint to set the value of
      value - The value to use
      See Also:
    • setHint

      public void setHint(WindowHint hint, int value)
      Sets the value of the given window hint.
      Parameters:
      hint - The window hint to set the value of
      value - 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 of
      value - 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 of
      value - The value to use
    • setDefaultHints

      public void setDefaultHints()
      Resets all window hints to their default values.
    • checkStatus

      protected void checkStatus() throws IllegalStateException
      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

      @NotNull public @NotNull String toString()
      Description copied from interface: Printable
      Returns a string representation of this object.
      Specified by:
      toString in interface Printable
      Overrides:
      toString in class Object
      Returns:
      String representation of this object.