SDL
The 'sdl' module provides SDL2 + ImGUI functionality
SDL2 Function Signatures
// Used to handle the correct event type in pollEvent
const EventType = {
QUIT: 256,
WINDOW: 512,
KEYDOWN: 768,
KEYUP: 769,
MOUSEMOTION: 1024,
MOUSEBUTTONDOWN: 1025,
MOUSEBUTTONUP: 1026,
MOUSEWHEEL: 1027
}
// Initializes the SDL library.
const initSDL = () => Number
// Creates a window with the specified parameters.
const createWindow = (windowName: String, xPos: Number, yPos: Number, width: Number, height: Number, flags = 4) => Pointer
// Creates a renderer for the given window.
const createRenderer = (window: Pointer, index = -1) => Pointer
// Clears the renderer's rendering target.
const renderClear = (renderer: Pointer) => None
// Presents the renderer's rendering target to the screen.
const renderPresent = (renderer: Pointer) => None
// Retrieves the name of the key corresponding to the given key code.
const getKeyName = (keyCode: Number) => String
// Sets the color used for drawing operations.
const setRenderDrawColor = (renderer: Pointer, r = 0, g = 0, b = 0, a = 255) => None
// Delays execution for the specified number of milliseconds.
const delay = (ms: Number) => None
// Retrieves the current state of the mouse.
const getMouseState = () => {
state: Number,
x: Number,
y: Number
}
// Draws a point on the renderer.
const drawPoint = (renderer: Pointer, xPos: Number, yPos: Number) => None
// Draws a line on the renderer.
const drawLine = (renderer: Pointer, x1: Number, y1: Number, x2: Number, y2: Number) => None
// Draws a rectangle on the renderer.
const drawRect = (renderer: Pointer, x: Number, y: Number, w: Number, h: Number) => None
// Draws geometry on the renderer.
const drawGeometry = (renderer: Pointer, vertices: Any, texture = None)
=> None
// Loads a texture onto the renderer.
const loadTexture = (renderer: Pointer, filePath: String) => Pointer
// Loads text onto the renderer with the specified font and parameters.
const loadText = (renderer: Pointer, fontPath: String, fontSize: Number, r: Number, g: Number, b: Number, text: String) => Pointer
// Retrieves the size of the window.
const getWindowSize = (window: Pointer) => {
w: Number,
h: Number
}
// Retrieves the position of the window.
const getWindowPos = (window: Pointer) => {
x: Number,
y: Number
}
// Shows or hides the cursor.
const showCursor = (flag: Boolean) => None
// Queries a texture for its information.
const queryTexture = (texture: Pointer) => {
x: Number,
y: Number
}
// Destroys a texture.
const destroyTexture = (texture: Pointer) => None
// Loads a WAV file.
const loadWav = (wav_file: String) => Pointer
// Plays a WAV file.
const playWav = (wav_ptr: Pointer, channel = -1, loops = 0) => Number
// Loads a music file.
const loadMusic = (music_file: String) => Pointer
// Plays a music file.
const playMusic = (music_ptr: Pointer, loops = 0) => Number
// Pauses music playback.
const pauseMusic = () => None
// Resumes music playback.
const resumeMusic = () => None
// Stops music playback.
const haltMusic = () => Number
// Retrieves the current status of music playback.
const musicStatus = () => {
playing: Boolean,
paused: Boolean
}
// Sets the volume of a channel or music.
const volume = (_volume = -1, channel = -1) => Number
// Sets the volume of music.
const musicVolume = (_volume = -1) => Number
// Polls for the next available event.
const pollEvent = () => {
status: Number,
event: {
type: Number,
button: {
button: Number,
clicks: Number,
x: Number,
y: Number,
which: Number
},
motion: {
x: Number,
y: Number,
which: Number,
windowID: Number
},
key: {
type: Number,
state: Number,
repeat: Number,
keysm: {
mod: Number,
scancode: Number,
sym: Number
}
},
window: {
event: Number,
data1: Number,
data2: Number,
windowID: Number
}
},
event_ptr: Pointer | None
}
/*
Information about the pollEvent() function:
- type {Number} - The type of the event.
- button {Object} - Information about a button event.
- button {Number} - The button number.
- clicks {Number} - The number of clicks.
- x {Number} - The x coordinate of the event.
- y {Number} - The y coordinate of the event.
- which {Number} - The mouse device index.
- motion {Object} - Information about a motion event.
- x {Number} - The x coordinate of the motion.
- y {Number} - The y coordinate of the motion.
- which {Number} - The mouse device index.
- windowID {Number} - The ID of the window where the motion occurred.
- key {Object} - Information about a keyboard event.
- type {Number} - The type of the keyboard event.
- state {Number} - The state of the key.
- repeat {Number} - The number of repeats for the key.
- keysm {Object} - Information about key modifiers.
- mod {Number} - The key modifier.
- scancode {Number} - The scancode of the key.
- sym {Number} - The symbolic code of the key.
- window {Object} - Information about a window event.
- event {Number} - The window event type.
- data1 {Number} - Additional data specific to the event.
- data2 {Number} - Additional data specific to the event.
- windowID {Number} - The ID of the window associated with the event.
- event_ptr {Pointer | None} - A pointer to the event data, or None if no event is available.
*/
ImGUI Function Signatures
Last updated