/  Basic Classes

GG

GWindow

NextFrameEvent

WindowResizeEvent

WindowResizeEvent

WindowCloseEvent

ContentScaleChangedEvent

SG_Component

Color

AssLoader

Basic classes for ChuGL: strongly-timed audiovisual programming in ChucK.

GG

inherits : Object

No description available

examples

static member functions

float fps()

FPS of current window, updated every second.

NextFrameEvent nextFrame()

Registers the calling shred to be notified when the next frame is finished rendering. When all graphics shreds are finished calling.Note: this function returns an event that MUST be waited on for correct behavior, i.e. GG.nextFrame() => now;See the ChuGL tutorial and examples for more information.

void logLevel(int level)

Set the log level for ChuGL's renderer and graphics thread. Levels are: GG.LogLevel_Trace, GG.LogLevel_Debug, GG.LogLevel_Info, GG.LogLevel_Warn, GG.LogLevel_Error, GG.LogLevel_Fatal. Setting a log level will allow all messages of that level and higher to be printed to the console. Default is GG.LogLevel_Error.

GScene scene()

No description available

GScene scene(GScene scene)

No description available

void fps(int fps)

Hard-limit the frame rate of the graphics thread. By default this is 60. Lowering this value may improve audio performance in chuck, as graphics shreds will run less frequently, giving the chuck VM more time to compute audio samples. Set to a negative value or 0 to disable frame rate limiting and let graphics run as fast as possible (up to the refresh rate of the monitor)

float dt()

Return the laptime of the graphics thread's last frame in seconds.

int fc()

Return the number of frames rendered since the start of the program.

GPass rootPass()

Get the root pass of the current scene.

RenderPass renderPass()

Get the default render pass (renders the main scene.

OutputPass outputPass()

Get the default output pass (renders the main scene to the screen, with default tonemapping and exposure settings.

int autoUpdate()

Returns true if GGen update() functions are automatically called on all GGens in each active scene graph every frame. Default is true.

void autoUpdate(int autoUpdate)

Set whether GGen update() functions are automatically called on all GGens in active scene graphs every frame. Default is true.

void fullscreen()

Shorthand for GWindow.fullscreen(). Added for backwards compatibility.

void windowed(int width, int height)

Shorthand for GWindow.windowed(). Added for backwards compatibility.

void windowed()

Shorthand for GWindow.windowed(). Added for backwards compatibility.

GCamera camera()

Shorthand for getting the default Camera that is created upon startup.

void windowTitle(string title)

Shorthand for GWindow.title(). Added for backwards compatibility.

float windowWidth()

Get the width of the current window. Shorthand for GWindow.size().x, added for backwards compatibility.

float windowHeight()

Get the height of the current window. Shorthand for GWindow.size().y, added for backwards compatibility.

float mouseX()

Get the x position of the mouse cursor in screen coordinates.

float mouseY()

Get the y position of the mouse cursor in screen coordinates.

float frameWidth()

Get the width of the current window's framebuffer in pixels. Shorthand for GWindow.framebufferSize().x, added for backwards compatibility.

float frameHeight()

Get the height of the current window's framebuffer in pixels. Shorthand for GWindow.framebufferSize().y, added for backwards compatibility.

void unregisterShred()

Unregisters the calling shred from ChuGL so that it is no longer marked as a graphics shred. Do this if you want a shred to exit a GG.nextFrame() => now gameloop and move on to other tasks. Otherwise, the window will hang as it waits for this shred to call GG.nextFrame() again.

static member variables

int LogLevel_Trace

No description available

int LogLevel_Debug

No description available

int LogLevel_Info

No description available

int LogLevel_Warn

No description available

int LogLevel_Error

No description available

int LogLevel_Fatal

No description available


GWindow

inherits : Object

All the properties and methods for window management.

examples

static member functions

void center()

Center the window on its current monitor.

void position(int x, int y)

Set the window position in screen coordinates.

int key(int key)

Get the whether the specified key is being held down. Use the GWindow key constants for param `key`, e.g. GWindow.key(GWindow.Key_Space)

void close()

Close the window.

vec2 mouseDeltaPos()

Get the change in mouse position since the last call.

void mouseMode(int mode)

Set the mouse mode. Possible values are: GWindow.MouseMode_Normal (0) , GWindow.MouseMode_Disabled (1), and GWindow.MouseMode_Hidden (2)Normal mode is the default mode, the cursor is visible and behaves normally.Disabled mode hides the cursor and locks it to the window, useful for first-person games.Hidden mode hides the cursor when it is focused and hovering over the window, but does not lock it to the window.

float scrollX()

Get the horizontal scroll delta of the mouse wheel.

float scrollY()

Get the vertical scroll delta of the mouse wheel.

vec2 scroll()

Get the 2D scroll delta of the mouse wheel.

int mouseLeft()

Get the state of the left mouse button. 1 if pressed, 0 if not.

int mouseRight()

Get the state of the right mouse button. 1 if pressed, 0 if not.

int mouseLeftDown()

1 on the frame the left mouse button is pressed, 0 otherwise.

int mouseRightDown()

1 on the frame the right mouse button is pressed, 0 otherwise.

int mouseLeftUp()

1 on the frame the left mouse button is released, 0 otherwise.

int mouseRightUp()

1 on the frame the right mouse button is released, 0 otherwise.

int keyDown(int key)

Get the whether the specified key was pressed this frame. Use the GWindow key constants for param `key`, e.g. GWindow.keyDown(GWindow.Key_Space)

int keyUp(int key)

Get the whether the specified key was released this frame. Use the GWindow key constants for param `key`, e.g. GWindow.keyUp(GWindow.Key_Space)

WindowResizeEvent resizeEvent()

Returns the event triggered whenever the ChuGL window is resized, either by the user or programmatically.

WindowCloseEvent closeEvent()

Returns the event triggered whenever the user attempts to close this ChuGL window.

Event contentScaleEvent()

Returns the event triggered whenever the content scale of the window changes.The content scale is the ratio between the current DPI and the platform's default DPI.

void closeable(int closeable)

Enable or disable the window's close button.

int closeable()

Get the current state of the window's close button.

void fullscreen()

Set the window to fullscreen mode.

void fullscreen(int width, int height)

Set the window to fullscreen mode with the specified resolution.

void maximize()

Set the window to windowed fullscreen mode.

void windowed(int width, int height)

Set the window to windowed mode with the specified width and height.

void windowed()

Set the window to windowed mode with the last size before going fullscreen. Default 1280 x 960.

vec2 windowSize()

Get the window size in screen coordinates.

vec2 framebufferSize()

Get the framebuffer size in pixels.

vec2 contentScale()

Get the content scale of current monitor.

void sizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight, vec2 aspectRatio)

Set the window size limits, including min/max size and aspect ratio.To disable a limit, pass 0 for the corresponding argument, or @(0, 0)to disable fixed aspect ratio.

void title(string title)

Set the window title.

void iconify()

Iconify the window.

void restore()

Restore the window from iconified state.

void resizable(int resizable)

Set the window resizable attribute. Must call before GG.nextFrame(). Default is true.

void decorated(int decorated)

Set whether the window has decorations such as a border, a close widget, etc.Must call before GG.nextFrame(). Default is true.

void floating(int floating)

Set whether the specified window is floating, also called topmost or always-on-top. Must call before GG.nextFrame(). Default is false.

void transparent(int transparent)

Set whether the specified window has a transparent framebuffer, i.e. the window contents is composited with the background using the window framebuffer alpha channel.Not supported on all platforms. To enable, call GWindow.transparent() BEFORE GG.nextFrame() is ever called.If platform supports it, you can change opacity via GWindow.opacity(float)

void opacity(float opacity)

Set the window opacity, 0.0 is fully transparent, 1.0 is fully opaque.only works if GWindow.transparent() has been called before GG.nextFrame()AND the platform supports transparent framebuffers.

vec2 mousePos()

Get the current mouse position in screen coordinates.

static member variables

int Key_Space

No description available

int Key_Apostrophe

No description available

int Key_Comma

No description available

int Key_Minus

No description available

int Key_Period

No description available

int Key_Slash

No description available

int Key_0

No description available

int Key_1

No description available

int Key_2

No description available

int Key_3

No description available

int Key_4

No description available

int Key_5

No description available

int Key_6

No description available

int Key_7

No description available

int Key_8

No description available

int Key_9

No description available

int Key_Semicolon

No description available

int Key_Equal

No description available

int Key_A

No description available

int Key_B

No description available

int Key_C

No description available

int Key_D

No description available

int Key_E

No description available

int Key_F

No description available

int Key_G

No description available

int Key_H

No description available

int Key_I

No description available

int Key_J

No description available

int Key_K

No description available

int Key_L

No description available

int Key_M

No description available

int Key_N

No description available

int Key_O

No description available

int Key_P

No description available

int Key_Q

No description available

int Key_R

No description available

int Key_S

No description available

int Key_T

No description available

int Key_U

No description available

int Key_V

No description available

int Key_W

No description available

int Key_X

No description available

int Key_Y

No description available

int Key_Z

No description available

int Key_LeftBracket

No description available

int Key_Backslash

No description available

int Key_RightBracket

No description available

int Key_GraveAccent

No description available

int Key_World1

No description available

int Key_World2

No description available

int Key_Escape

No description available

int Key_Enter

No description available

int Key_Tab

No description available

int Key_Backspace

No description available

int Key_Insert

No description available

int Key_Delete

No description available

int Key_Right

No description available

int Key_Left

No description available

int Key_Down

No description available

int Key_Up

No description available

int Key_PageUp

No description available

int Key_PageDown

No description available

int Key_Home

No description available

int Key_End

No description available

int Key_CapsLock

No description available

int Key_ScrollLock

No description available

int Key_NumLock

No description available

int Key_PrintScreen

No description available

int Key_Pause

No description available

int Key_F1

No description available

int Key_F2

No description available

int Key_F3

No description available

int Key_F4

No description available

int Key_F5

No description available

int Key_F6

No description available

int Key_F7

No description available

int Key_F8

No description available

int Key_F9

No description available

int Key_F10

No description available

int Key_F11

No description available

int Key_F12

No description available

int Key_F13

No description available

int Key_F14

No description available

int Key_F15

No description available

int Key_F16

No description available

int Key_F17

No description available

int Key_F18

No description available

int Key_F19

No description available

int Key_F20

No description available

int Key_F21

No description available

int Key_F22

No description available

int Key_F23

No description available

int Key_F24

No description available

int Key_F25

No description available

int Keypad_0

No description available

int Keypad_1

No description available

int Keypad_2

No description available

int Keypad_3

No description available

int Keypad_4

No description available

int Keypad_5

No description available

int Keypad_6

No description available

int Keypad_7

No description available

int Keypad_8

No description available

int Keypad_9

No description available

int Keypad_Decimal

No description available

int Keypad_Divide

No description available

int Keypad_Multiply

No description available

int Keypad_Subtract

No description available

int Keypad_Add

No description available

int Keypad_Enter

No description available

int Keypad_Equal

No description available

int Key_LeftShift

No description available

int Key_LeftControl

No description available

int Key_LeftAlt

No description available

int Key_LeftSuper

No description available

int Key_RightShift

No description available

int Key_RightControl

No description available

int Key_RightAlt

No description available

int Key_RightSuper

No description available

int Key_Menu

No description available

int MouseMode_Normal

Normal mouse mode, the cursor is visible and behaves normally. Set via GWindow.mouseMode()

int MouseMode_Hidden

Hidden mouse mode, hides the cursor when it is focused and hovering over the window, but does not lock it to the window. Set via GWindow.mouseMode(). May not be supported on all platforms.

int MouseMode_Disabled

Disabled mouse mode, hides the cursor and locks it to the window, useful for first-person games. Set via GWindow.mouseMode()


NextFrameEvent

inherits : Event : Object

Don't instantiate this class directly. Use GG.nextFrame() => now; instead.

examples

constructors

NextFrameEvent()

Default constructor for NextFrameEvent.

member functions

void waiting_on()

No description available


WindowResizeEvent

inherits : Event : Object

Event triggered whenever the ChuGL window is resized, either by the user or programmatically.Don't instantiate directly, use GWindow.resizeEvent() instead.


WindowResizeEvent

inherits : Event : Object

Event triggered whenever the ChuGL window is resized, either by the user or programmatically.Don't instantiate directly, use GWindow.resizeEvent() instead.


WindowCloseEvent

inherits : Event : Object

Event triggered whenever the user attempts to close the ChuGL window, useful if GWindow.closeable(false) has been set and you need to do cleanup (save game, flush logs, etc.) before exiting.Don't instantiate directly, use GWindow.closeEvent() instead.


ContentScaleChangedEvent

inherits : Event : Object

Event triggered whenever the content scale of the window changes.The content scale is the ratio between the current DPI and the platform's default DPI.Don't instantiate directly, use GWindow.contentScaleEvent() instead.


SG_Component

inherits : Object

Base class for ALL chugl scenegraph components. Don't instantiate directly. Contains methods for setting and getting the name of the component (useful for debugging) and the unique id which chugl assigns.

constructors

SG_Component()

Default constructor for SG_Component.

member functions

string name()

Get the name of this component.

int id()

Get the unique chugl id of this component.

string name(string name)

Set the name of this component.


Color

inherits : Object

ChuGL color utility class.

static member functions

vec3 hsv2rgb(vec3 hsv)

Convert from hsv colorspace to rgb.

vec3 rgb2hsv(vec3 rgb)

Convert from rgb colorspace to hsvhsv stands for hue, saturation, value, and is a more human-friendly color formathue takes on a value between 0 and 360, and represents the color itselfsaturation takes on a value between 0 and 1, and represents the amount of colorvalue takes on a value between 0 and 1, and represents the brightness of the color.

vec3 grayscale(vec3 rgb)

Convert an rgb value to grayscale, scaled according to NTSC formula based on human perception.

vec3 random()

Generate a random rgb color.

static member variables

vec3 RED

Red: (1.0, 0.0, 0.0)

vec3 GREEN

Green: (0.0, 1.0, 0.0)

vec3 BLUE

Blue: (0.0, 0.0, 1.0)

vec3 LIGHTGRAY

Lightgray: (.784, .784, .784)

vec3 GRAY

Gray: (.51, .51, .51)

vec3 DARKGRAY

Darkgray: (.3, .3, .3)

vec3 YELLOW

Yellow: (.9921, .976, 0)

vec3 GOLD

Gold: (1.0, .796, 0)

vec3 ORANGE

Orange: (1.0, .631, 0)

vec3 PINK

Pink: (1.0, .427, .76)

vec3 MAROON

Maroon: (.745, .129, .216)

vec3 LIME

Lime: (0, .619, .184)

vec3 DARKGREEN

Darkgreen: (0, .459, .173)

vec3 SKYBLUE

Skyblue: (.4, .749, 1.0)

vec3 DARKBLUE

Darkblue: (0, .322, .675)

vec3 PURPLE

Purple: (.784, .478, 1.0)

vec3 VIOLET

Violet: (.529, .235, .745)

vec3 DARKPURPLE

Darkpurple: (.439, .122, .494)

vec3 BEIGE

Beige: (.827, .69, .514)

vec3 BROWN

Brown: (.498, .416, .31)

vec3 DARKBROWN

Darkbrown: (.298, .247, .184)

vec3 WHITE

White: (1.0, 1.0, 1.0)

vec3 BLACK

Black: (0.0, 0.0, 0.0)

vec3 MAGENTA

Magenta: (1.0, 0.0, 1.0)


AssLoader

inherits : Object

Utility for asset loading; supports .obj files.

examples

static member functions

GGen loadObj(string filepath)

Load an .obj file from the given filepath.

GGen loadObj(string filepath, int flip_y)

Load an .obj file from the given filepath. If flip_y is true, the y-axis is flipped (default is false)