goopylib.core

This is goopylib’s most important module. It defines core and miscellaneous functions that allow you to configure and use the library. The module is automatically imported and initializes the underlying API.

It can be used to configure global settings, initialize/terminate the library, and gather runtime or compilation information about goopylib.

init() None

Initializes goopylib internally. This function is automatically called when goopylib is imported.

Raises

RuntimeError – if the initialization fails

Return type

None

terminate() None

Terminates goopylib internally and destroys all open windows. You should call this function before the program ends.

Note

goopylib can be reinitialized using gp.init()

Return type

None

update() None

Updates goopylib and its windows.

Examples

The following is a standard goopylib mainloop:

window = gp.Window(500, 500)

while window.is_open():
    gp.update()
Return type

None

update_on_event() None

Updates goopylib every time an event occurs. These can be key presses, cursor movement, window resizing, or others.

Return type

None

update_timeout(timeout: float = 0) None

Updates goopylib after a duration has passed.

Parameters

timeout (float, default: 0) – the duration (seconds) to wait between updates.

Raises

ValueError – if timeout is less than 0

Return type

None

set_buffer_swap_interval(interval: int) None

Sets the rate of swapping window buffers.

Parameters

interval (int) – the number of refreshes to wait before swapping buffers.

Raises
  • TypeError – if a non-integer value is passed.

  • ValueError – if interval is less than 0

Return type

None

get_refresh_rate() int

Returns the refresh rate of the primary monitor.

Returns

int – the refresh rate in Hertz

Raises

RuntimeError – if goopylib has not been initialized

get_screen_width() int

Returns the width of the primary monitor.

Returns

int – the screen width in screen coordinates

Raises

RuntimeError – if goopylib has not been initialized

get_screen_height() int

Returns the height of the primary monitor.

Returns

int – the screen height in screen coordinates

Raises

RuntimeError – if goopylib has not been initialized

number_of_monitors() int

Returns the number of monitors connected.

Raises

RuntimeError – if goopylib has not been initialized

Return type

int

glfw_compiled_version() str

Returns the version of GLFW that goopylib was compiled with.

Return type

str

glfw_current_version() str

Returns the version of GLFW that is currently running.

Return type

str

opengl_version() str

Returns the version of OpenGL being used.

Return type

str