VISU - PHP Game Framework

Window
in package

Table of Contents

Properties

$hints  : WindowHints
Current windows hints
$framebuffer  : WindowFramebuffer
The windows current framebuffer object
$handle  : GLFWwindow|null
GLFW Window handle
$eventHandler  : WindowEventHandlerInterface
Current window event handler
$height  : int
Window height
$title  : string
Window title
$width  : int
Window width

Methods

__construct()  : mixed
Window constructor The constructor does not create thw window resource yet, use `initailize` for that.
__destruct()  : mixed
Window destructor
activate()  : void
Active the windows GL context and make it the current context This internally calls `glfwMakeContextCurrent`
focus()  : void
Give the window input focus Call this to really annoy the user.
getAttribute()  : int
Returns a window attribute using a GLFW constant.
getFramebuffer()  : WindowFramebuffer
Returns the window framebuffer object
getFramebufferHeight()  : int
Get the window framebuffer height in pixels
getFramebufferSizeVec()  : Vec2
Get the window framebuffer size in pixels as a Vec2
getFramebufferWidth()  : int
Get the window framebuffer width in pixels
getGLFWHandle()  : GLFWwindow
Returns the plain GLFW window handle
getHeight()  : int
Get the window height
getPositionVec()  : Vec2
Get the window position in screen coordinates as a Vec2
getRenderTarget()  : RenderTarget
Creates and returns the windows render target
getSizeVec()  : Vec2
Get the window size in screen coordinates as a Vec2
getTitle()  : string
Get the window title
getWidth()  : int
Get the window width
hasFocus()  : bool
Returns boolean if the window has input focus
hide()  : void
Hide the window This will make the window invisible but not destroy it
iconify()  : void
Iconifies the window
initailize()  : void
This will actually craete the window resource and launch it
isIconified()  : bool
Returns boolean if the window is iconified
isMaximized()  : bool
Returns boolean if the window is maximized
isVisible()  : bool
Returns boolean if the window is visible (show/hide state)
maximize()  : void
Maximizes the window
pollEvents()  : void
Poll the queued window events and run the callbacks
pullSize()  : void
Pulls the window size from the window resource If you allow the user to resize the window you should call this method to update the internal size variables.
requestAttention()  : void
Request attention, window attention request This will make the window title bar flash depending on the OS
restore()  : void
Restores the window This can be called to undo a maximize or iconify call
setAspectRatio()  : void
Set the windows aspect ratio
setAttribute()  : void
Sets a window attribute using a GLFW constant.
setEventHandler()  : void
Sets the windows event handler and registers it with GLFW
setFullscreen()  : void
Sets the window monitor
setPosition()  : void
Set the window position in screen coordinates
setShouldClose()  : void
Sets the window should close flag
setSize()  : void
Set the window size in screen coordinates
setSizeLimits()  : void
Set the windows size limits in screen coordinates
setSwapInterval()  : void
Enables / disalbes the current contexts swap interval aka vsync
setTitle()  : void
Updates the window title
setWindowed()  : void
Sets the window into windowed mode
shouldClose()  : bool
Does the window request closing?
show()  : void
Show the window This will make the window visible again after a hide call. Dont confuse this with initialize.
swapBuffers()  : void
Swap the windows framebuffer
triggerWindowCharEvent()  : void
Triggers a window char event.
triggerWindowCharModsEvent()  : void
Triggers a window char mods event.
triggerWindowCursorEnterEvent()  : void
Triggers a window cursor enter event.
triggerWindowCursorPosEvent()  : void
Triggers a window cursor position event.
triggerWindowDropEvent()  : void
Triggers a window drop event.
triggerWindowKeyEvent()  : void
Triggers a window key event.
triggerWindowMouseButtonEvent()  : void
Triggers a window mouse button event.
triggerWindowScrollEvent()  : void
Triggers a window scroll event.
requiresInitialization()  : GLFWwindow
Throws an exception if the window is not initialized

Properties

$handle

GLFW Window handle

protected GLFWwindow|null $handle = null

$height

Window height

private int $height

$title

Window title

private string $title

$width

Window width

private int $width

Methods

__construct()

Window constructor The constructor does not create thw window resource yet, use `initailize` for that.

public __construct(string $title[, int $width = 1280 ][, int $height = 720 ][, WindowHints $hints = null ]) : mixed

Make sure GLFW is initialized before creating a window.

Parameters
$title : string

The window title displayed in the title bar

$width : int = 1280

The window width in screen coordinates

$height : int = 720

The window height in screen coordinates

$hints : WindowHints = null

The window hints used during initalization

__destruct()

Window destructor

public __destruct() : mixed

activate()

Active the windows GL context and make it the current context This internally calls `glfwMakeContextCurrent`

public activate() : void

focus()

Give the window input focus Call this to really annoy the user.

public focus() : void

getAttribute()

Returns a window attribute using a GLFW constant.

public getAttribute(int $attribute) : int
Parameters
$attribute : int

The attribute to query

Return values
int

The attribute value

getFramebufferHeight()

Get the window framebuffer height in pixels

public getFramebufferHeight() : int
Return values
int

The window framebuffer height in pixels

getFramebufferSizeVec()

Get the window framebuffer size in pixels as a Vec2

public getFramebufferSizeVec() : Vec2
Return values
Vec2

a vector containing the window framebuffer size

getFramebufferWidth()

Get the window framebuffer width in pixels

public getFramebufferWidth() : int
Return values
int

The window framebuffer width in pixels

getHeight()

Get the window height

public getHeight() : int
Return values
int

the windows height in screen coordinates

getPositionVec()

Get the window position in screen coordinates as a Vec2

public getPositionVec() : Vec2
Return values
Vec2

a vector containing the window position

getSizeVec()

Get the window size in screen coordinates as a Vec2

public getSizeVec() : Vec2
Return values
Vec2

The window size as a Vec2

getTitle()

Get the window title

public getTitle() : string
Return values
string

current window title

getWidth()

Get the window width

public getWidth() : int
Return values
int

The window width in screen coordinates

hasFocus()

Returns boolean if the window has input focus

public hasFocus() : bool
Return values
bool

True if the window has input focus

hide()

Hide the window This will make the window invisible but not destroy it

public hide() : void

iconify()

Iconifies the window

public iconify() : void

initailize()

This will actually craete the window resource and launch it

public initailize(GLState $state[, null|GLFWmonitor $initalMonitor = null ]) : void
Parameters
$state : GLState

A state object representing the current global OpenGL state

$initalMonitor : null|GLFWmonitor = null

If not null, the window will be created in fullscreen mode for the specified monitor

isIconified()

Returns boolean if the window is iconified

public isIconified() : bool
Return values
bool

True if the window is iconified, false otherwise

isMaximized()

Returns boolean if the window is maximized

public isMaximized() : bool
Return values
bool

True if the window is maximized, false otherwise

isVisible()

Returns boolean if the window is visible (show/hide state)

public isVisible() : bool
Return values
bool

True if the window is visible

maximize()

Maximizes the window

public maximize() : void

pollEvents()

Poll the queued window events and run the callbacks

public pollEvents() : void

pullSize()

Pulls the window size from the window resource If you allow the user to resize the window you should call this method to update the internal size variables.

public pullSize() : void

requestAttention()

Request attention, window attention request This will make the window title bar flash depending on the OS

public requestAttention() : void

restore()

Restores the window This can be called to undo a maximize or iconify call

public restore() : void

setAspectRatio()

Set the windows aspect ratio

public setAspectRatio(int $numerator, int $denominator) : void
Parameters
$numerator : int

The aspect ratio numerator

$denominator : int

The aspect ratio denominator

setAttribute()

Sets a window attribute using a GLFW constant.

public setAttribute(int $attribute, int $value) : void

VISU validates the options and throws an exception if the attribute is not changeable.

Parameters
$attribute : int
$value : int

setFullscreen()

Sets the window monitor

public setFullscreen(int $width, int $height, int $refreshRate[, GLFWmonitor|null $monitor = null ]) : void
Parameters
$width : int
$height : int
$refreshRate : int
$monitor : GLFWmonitor|null = null

setPosition()

Set the window position in screen coordinates

public setPosition(int $x, int $y) : void
Parameters
$x : int

The new window x position in screen coordinates

$y : int

The new window y position in screen coordinates

setShouldClose()

Sets the window should close flag

public setShouldClose(bool $value) : void
Parameters
$value : bool

true to request closing, false to cancel a request

setSize()

Set the window size in screen coordinates

public setSize(int $width, int $height) : void
Parameters
$width : int

The new window width in screen coordinates

$height : int

The new window height in screen coordinates

setSizeLimits()

Set the windows size limits in screen coordinates

public setSizeLimits(int $minWidth, int $minHeight, int $maxWidth, int $maxHeight) : void
Parameters
$minWidth : int

The minimum window width in screen coordinates

$minHeight : int

The minimum window height in screen coordinates

$maxWidth : int

The maximum window width in screen coordinates

$maxHeight : int

The maximum window height in screen coordinates

setSwapInterval()

Enables / disalbes the current contexts swap interval aka vsync

public setSwapInterval(int $interval) : void
Parameters
$interval : int

The swap interval, 0 for no vsync, 1 for vsync

setTitle()

Updates the window title

public setTitle(string $title) : void
Parameters
$title : string

The new window title

setWindowed()

Sets the window into windowed mode

public setWindowed(int $width, int $height[, int $x = 0 ][, int $y = 0 ]) : void
Parameters
$width : int
$height : int
$x : int = 0
$y : int = 0

shouldClose()

Does the window request closing?

public shouldClose() : bool
Return values
bool

True if the window should close, false otherwise

show()

Show the window This will make the window visible again after a hide call. Dont confuse this with initialize.

public show() : void

swapBuffers()

Swap the windows framebuffer

public swapBuffers() : void

This will swap the front and back buffer of the window If not explicitly disabled we have a double buffered window by default which requires this call to be made after rendering

triggerWindowCharEvent()

Triggers a window char event.

public triggerWindowCharEvent(int $codepoint) : void

This methods assumes that setEventHandler has been called before. You can call this method yourself to simulate a char event.

Parameters
$codepoint : int

triggerWindowCharModsEvent()

Triggers a window char mods event.

public triggerWindowCharModsEvent(int $codepoint, int $mods) : void

This methods assumes that setEventHandler has been called before. You can call this method yourself to simulate a char mods event.

Parameters
$codepoint : int
$mods : int

triggerWindowCursorEnterEvent()

Triggers a window cursor enter event.

public triggerWindowCursorEnterEvent(int $entered) : void

This methods assumes that setEventHandler has been called before. You can call this method yourself to simulate a cursor enter event.

Parameters
$entered : int

triggerWindowCursorPosEvent()

Triggers a window cursor position event.

public triggerWindowCursorPosEvent(float $xpos, float $ypos) : void

This methods assumes that setEventHandler has been called before. You can call this method yourself to simulate a cursor position event.

Parameters
$xpos : float
$ypos : float

triggerWindowDropEvent()

Triggers a window drop event.

public triggerWindowDropEvent(int $num, array<string|int, string> $paths) : void

This methods assumes that setEventHandler has been called before. You can call this method yourself to simulate a drop event.

Parameters
$num : int
$paths : array<string|int, string>

triggerWindowKeyEvent()

Triggers a window key event.

public triggerWindowKeyEvent(int $key, int $scancode, int $action, int $mods) : void

This methods assumes that setEventHandler has been called before. You can call this method yourself to simulate a key event.

Parameters
$key : int
$scancode : int
$action : int
$mods : int

triggerWindowMouseButtonEvent()

Triggers a window mouse button event.

public triggerWindowMouseButtonEvent(int $button, int $action, int $mods) : void

This methods assumes that setEventHandler has been called before. You can call this method yourself to simulate a mouse button event.

Parameters
$button : int
$action : int
$mods : int

triggerWindowScrollEvent()

Triggers a window scroll event.

public triggerWindowScrollEvent(float $xoffset, float $yoffset) : void

This methods assumes that setEventHandler has been called before. You can call this method yourself to simulate a scroll event.

Parameters
$xoffset : float
$yoffset : float

requiresInitialization()

Throws an exception if the window is not initialized

private requiresInitialization() : GLFWwindow
Return values
GLFWwindow

        
On this page

Search results