parin.engine
The engine module functions as a lightweight 2D game engine.
var _engineState _screenshotRequestPath defaultEngineArenaCapacity defaultEngineAssetsPathCapacity defaultEngineDebugColor1 defaultEngineDebugColor2 defaultEngineDebugModeKey defaultEngineDprintCapacity defaultEngineDprintFont defaultEngineDprintLineCountLimit defaultEngineDprintPosition defaultEngineEngineTasksCapacity defaultEngineEnvArgsCapacity defaultEngineFlags defaultEngineFpsMax defaultEngineHeight defaultEngineLoadErrorMessage defaultEngineLoadOrSaveTextCapacity defaultEngineSaveErrorMessage defaultEngineScreenshotTargetPathCapacity defaultEngineTitle defaultEngineValidateErrorMessage defaultEngineVsync defaultEngineWidth defaultEngineWindowMinHeight defaultEngineWindowMinSize defaultEngineWindowMinWidth engineFont engineFontSmall engineViewport
struct _Attached Clip DepthSort DepthSortCommand DepthSortData DepthSortPair EngineState EngineViewport FontId SoundId TextureId ViewportId
fn _parinSortLayered _parinSortTopDown _parinSortTopDownFast _parinSortTopDownFastest _TEMP_REPLACE_ME_GetCodepointNext _TEMP_REPLACE_ME_GetCodepointPrevious _updateEngineMouseBuffer _updateEngineWasdBuffer _updateViewportInfoBuffer assetsPath attach Attached beginClip beginDepthSort cancelTask clearAllEngineTasks clearDprintBuffer closeWindow defaultFilter defaultFont defaultWrap deltaMouse deltaTime deltaWheel dequeuePressedKey dequeuePressedRune detach didLoadOrSaveSucceed dprintBuffer dprintfln dprintln drawCirc drawDebugBoxWorld drawDebugEngineInfo drawDebugTileInfo drawDprintBuffer drawLine drawRect drawRune drawSprite drawSpriteStack drawSpriteStackLayer drawSurface drawSurfaceArea drawText drawTexture drawTextureArea drawTextureSlice drawTile drawTileMap drawVec2 drawViewport drawViewportArea droppedPaths elapsedTicks elapsedTickTime elapsedTime endClip endDepthSort engineViewportInfo envArgs fontIdCount fps fpsMax frameMake frameMakeBlank frameMakeSlice frameMakeSliceBlank frameMalloc frameMemoryContext frameRealloc frameResizeSlice freeAllFontIds freeAllResourceIds freeAllSoundIds freeAllTextureIds freeAllViewportIds getRequestedScreenshot isCursorVisible isDebugMode isDown isEnteringDebugMode isExitingDebugMode isFullscreen isLoggingLoadOrSaveFaults isLoggingMemoryTrackingInfo isLoggingWithDprint isNullFontVisible isNullTextureVisible isPixelPerfect isPixelSnapped isPressed isReleased isResolutionLocked isUsingAssetsPath isWindowResized lastLoadOrSaveFault loadBytes loadBytesIntoBuffer loadFont loadSound loadSurface loadTempBytes loadTempText loadText loadTextIntoBuffer loadTexture loadViewport lockResolution masterVolume measureTextSize mouse openUrl openWindow openWindowC pauseSound playSound prepareTempText randf randi randomize repeatTask requestScreenshot resolution resolutionHeight resolutionWidth resumeSound saveBytes saveScreenshot saveText screenHeight screenSize screenWidth setAssetsPath setDebugModeKey setDefaultFilter setDefaultFont setDefaultWrap setDprintFont setDprintLineCountLimit setDprintOptions setDprintPosition setDprintVisibility setFpsMax setIsCursorVisible setIsDebugMode setIsFullscreen setIsLoggingLoadOrSaveFaults setIsLoggingMemoryTrackingInfo setIsLoggingWithDprint setIsNullFontVisible setIsNullTextureVisible setIsPixelPerfect setIsPixelSnapped setIsUsingAssetsPath setMasterVolume setRandomSeed setVsync setWindowBackgroundColor setWindowBorderColor setWindowIconFromFiles setWindowMaxSize setWindowMinSize setWindowTitle soundIdCount startSound stopSound takeScreenshot textureIdCount toAssetsPath toCanvasPoint toggleDprintVisibility toggleIsCursorVisible toggleIsDebugMode toggleIsFullscreen toggleResolution toggleSoundIsActive toggleSoundIsPaused toScenePoint unlockResolution updateWindow viewportIdCount vsync wasd wasdPressed wasdReleased windowBackgroundColor windowBorderColor windowHeight windowSize windowWidth
Types 19
aliasEngineTasks = GenList!(
Task,
SparseList!(Task, FixedList!(SparseListItem!Task, defaultEngineEngineTasksCapacity)),
FixedList!(Gen, defaultEngineEngineTasksCapacity)
)
A container type holding scheduled engine tasks.
aliasEngineTaskId = GenIndex
An identifier for a scheduled engine task.
aliasEngineFlags = uint
Type representing the internal engine flags.
enumEngineFlag : EngineFlags
The internal engine flags.
none = 0x000000
isUpdating = 0x000001
isUsingAssetsPath = 0x000002
isPixelSnapped = 0x000004
isPixelPerfect = 0x000008
isNullTextureVisible = 0x000010
isNullFontVisible = 0x000020
isLoggingLoadOrSaveFaults = 0x000040
isLoggingMemoryTrackingInfo = 0x000080
isLoggingWithDprint = 0x000100
isDebugMode = 0x000200
structEngineViewport
Internal representation of a viewport within the engine.
structEngineState
Internal state of the engine.
Fields
EngineFlags flagsUpdateFunc updateFuncCallFunc debugModeFuncCallFunc debugModeBeginFuncCallFunc debugModeEndFuncKeyboard debugModeKeybool debugModePreviousStatebool debugModeEnteringFrameStatebool debugModeExitingFrameStateViewportInfo viewportInfoBufferVec2 mouseBufferVec2 wasdBufferVec2 wasdPressedBufferVec2 wasdReleasedBufferdouble elapsedTickTimeBufferbool clipIsActiveRgba windowBorderColorFilter defaultFilterWrap defaultWrapFontId defaultFontTextureId currentScreenshotTextureCamera userCameraViewportId userViewportFault lastLoadOrSaveFaultIStr memoryTrackingInfoFilterFStr!defaultEngineAssetsPathCapacity assetsPathFStr!defaultEngineScreenshotTargetPathCapacity screenshotTargetPathFStr!defaultEngineScreenshotTargetPathCapacity screenshotLastFaultPathIStr screenshotLastFaultFileSz screenshotLastFaultLineEngineTasks tasksFStr!defaultEngineDprintCapacity dprintBufferFontId dprintFontVec2 dprintPositionDrawOptions dprintOptionsSz dprintLineCountSz dprintLineCountLimitbool dprintIsVisibleDepthSortData depthSortDataDepthSortMode depthSortModebool depthSortActiveEngineViewport viewportGrowingArena arenastructTextureId
A texture identifier.
Fields
ResourceId datastructFontId
A font identifier.
Fields
ResourceId datastructSoundId
A sound identifier.
Fields
ResourceId dataMethods
SoundId validate(IStr message = defaultEngineValidateErrorMessage) @safe nothrow @nogcReturns this resource if valid, or asserts with the given message if not.void setVolume(float value) @safe nothrow @nogcSets the volume. The default value is 1.0 (normal level).void setPitch(float value, bool canUpdatePitchVarianceBase = false) @safe nothrow @nogcSets the pitch. The default value is 1.0 (base level).float pitchVariance() @safe nothrow @nogcReturns the pitch variance. The default value is 1.0 (no variation).void setPitchVariance(float value) @safe nothrow @nogcSets the pitch variance. The default value is 1.0 (no variation).float pitchVarianceBase() @safe nothrow @nogcReturns the pitch variance base. The default value is 1.0 (base level).void setPitchVarianceBase(float value) @safe nothrow @nogcSets the pitch variance base. The default value is 1.0 (base level).float progress() @safe nothrow @nogcReturns the progress. The value is between 0.0 and 1.0 (inclusive).structViewportId
A viewport identifier.
Fields
ResourceId dataMethods
ViewportId validate(IStr message = defaultEngineValidateErrorMessage) @safe nothrow @nogcReturns this resource if valid, or asserts with the given message if not.void resize(int newWidth, int newHeight) @safe nothrow @nogcResizes the viewport. Internally, this creates a new texture, so avoid calling it while the viewport is in use.structClip
structDepthSortData
Methods
enumDepthSortMode : ubyte
Depth sorting modes.
topDownSorts with: Layer + Y + Call Order
topDownFastSorts with: Layer + Y
topDownFastestSorts with: Y
layeredSorts with: Layer + Call Order
structDepthSortCommand
structDepthSortPair
Fields
float yushort iubyte layerstructDepthSort
A depth sort. Works only with textures. Designed to be used with the with keyword.
Fields
DepthSortMode _depthSortModeDestructors
aliastickTime = elapsedTickTime
deprecated Use `elapsedTickTime`. It's a better name.
Functions 231
fn
_Attached!T Attached(T)(ref T object) @trusted nothrow @nogc @safeAttaches the camera for the scope and detaches automatically. Designed to be used with the `with` keyword.fn
int _parinSortTopDownFast(const(void) * a, const(void) * b) extern(C) @trusted nothrow @nogc @safefn
int _parinSortTopDownFastest(const(void) * a, const(void) * b) extern(C) @trusted nothrow @nogc @safefn
void openWindow(int width, int height, const(IStr)[] args, IStr title = "Parin", bool vsync = defaultEngineVsync) @trusted @safeOpens the window with the given information. Avoid calling this function manually.fn
void openWindowC(int width, int height, int argc, IStrz * argv, IStrz title = "Parin", bool vsync = defaultEngineVsync) @trusted @safeOpens the window with the given information using C strings. Avoid calling this function manually.fn
void updateWindow(UpdateFunc updateFunc, CallFunc debugModeFunc = null, CallFunc debugModeBeginFunc = null, CallFunc debugModeEndFunc = null) @safeStarts the main window loop. Accepts an update function and optional debug callbacks. Returns when the update function returns true. Avoid calling this function manually.fn
Vec2 drawText(A...)(FontId font, InterpolationHeader header, A args, InterpolationFooter footer, Vec2 position, DrawOptions options = DrawOptions(), TextOptions extra = TextOptions()) @safefn
Vec2 drawText(A...)(InterpolationHeader header, A args, InterpolationFooter footer, Vec2 position, DrawOptions options = DrawOptions(), TextOptions extra = TextOptions()) @safefn
void * frameMalloc(Sz alignment, Sz size, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowAllocates raw memory from the frame arena.fn
void * frameRealloc(Sz alignment, void * oldPtr, Sz oldSize, Sz newSize, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowReallocates memory from the frame arena.fn
T * frameMakeBlank(T)(IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowAllocates uninitialized memory for a single value of type `T`.fn
T * frameMake(T)(IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowAllocates and initializes a single value of type `T`.fn
T * frameMake(T)(const(T) value, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowAllocates and initializes a single value of type `T`.fn
T[] frameMakeSliceBlank(T)(Sz length, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowAllocates uninitialized memory for an array of type `T` with the given length.fn
T[] frameMakeSlice(T)(Sz length, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowAllocates and initializes an array of type `T` with the given length.fn
T[] frameMakeSlice(T)(Sz length, const(T) value, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowAllocates and initializes an array of type `T` with the given length.fn
T[] frameMakeSlice(T)(const(T)[] values, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowAllocates and initializes an array of type `T` with the given slice.fn
T[] frameResizeSlice(T)(T * values, Sz oldLength, Sz newLength, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowResizes an array of type `T` with the given slice pointer and length.fn
MemoryContext frameMemoryContext() @safe @trusted nothrowReturns a memory context from the frame allocator.fn
BStr prepareTempText(Sz capacity = defaultEngineLoadOrSaveTextCapacity, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowAllocates a temporary text buffer for this frame. Each call returns a new buffer.fn
EngineTaskId repeatTask(UpdateFunc func, float interval, int count = - 1, bool canCallNow = false) @safe @trusted nothrowSchedules a task to run every interval. Set `count` to limit how many times it runs. Use -1 to run indefinitely. If `canCallNow` is true, the task runs immediately.fn
Surface loadSurface(IStr path, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a surface file (PNG) with default filter and wrap modes. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the p...fn
Surface loadSurface(const(ubyte)[] memory, IStr ext = ".png", IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a surface file (PNG) from memory with default filter and wrap modes.fn
TextureId loadTexture(IStr path, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a texture file (PNG) with default filter and wrap modes. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the p...fn
TextureId loadTexture(const(ubyte)[] memory, IStr ext = ".png", IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a texture file (PNG) from memory with default filter and wrap modes.fn
FontId loadFont(IStr path, int size, int runeSpacing = - 1, int lineSpacing = - 1, IStr32 runes = "", IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a font file (TTF) with default filter and wrap modes. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the plat...fn
FontId loadFont(const(ubyte)[] memory, int size, int runeSpacing = - 1, int lineSpacing = - 1, IStr32 runes = "", IStr ext = ".ttf", IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a font file (TTF) from memory with default filter and wrap modes.fn
FontId loadFont(TextureId texture, int tileWidth, int tileHeight, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a font file (TTF) from a texture with default filter and wrap modes. The input texture will be invalidated after loading.fn
SoundId loadSound(IStr path, float volume, float pitch, bool canRepeat, float pitchVariance = 1.0f, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a sound file (WAV, OGG, MP3) with default playback settings. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to t...fn
ViewportId loadViewport(int width, int height, Rgba color, Blend blend = Blend.alpha, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a viewport with default filter and wrap modes.fn
LStr loadBytes(IStr path, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads bytes from a file and returns the contents as a list. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the plat...fn
IStr loadTempBytes(IStr path, Sz capacity = defaultEngineLoadOrSaveTextCapacity, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads bytes from a file into a temporary buffer for the current frame. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized ...fn
Fault loadBytesIntoBuffer(L = LStr)(IStr path, ref L listBuffer, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads bytes from a file into the given buffer. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the platform's native...fn
Fault saveBytes(IStr path, IStr bytes, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowSaves bytes into a file with the given content. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the platform's nativ...fn
LStr loadText(IStr path, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a text file and returns the contents as a list. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the platform's...fn
IStr loadTempText(IStr path, Sz capacity = defaultEngineLoadOrSaveTextCapacity, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a text file into a temporary buffer for the current frame. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the...fn
Fault loadTextIntoBuffer(L = LStr)(IStr path, ref L listBuffer, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowLoads a text file into the given buffer. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the platform's native format.fn
Fault saveText(IStr path, IStr text, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowSaves a text file with the given content. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the platform's native format.fn
Fault saveScreenshot(IStr path, ViewportId viewport, bool hasAlpha, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrowSaves an image taken from the given viewport. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the platform's native ...fn
int _TEMP_REPLACE_ME_GetCodepointNext(const(char) * text, int * codepointSize) @safe @trusted nothrow @nogcfn
int _TEMP_REPLACE_ME_GetCodepointPrevious(const(char) * text, int * codepointSize) @safe @trusted nothrow @nogcfn
IStr toAssetsPath(IStr path) @safe @trusted nothrow @nogcConverts a path to one within the assets folder. Returns the path unchanged if it is absolute or asset paths are disabled.fn
bool isUsingAssetsPath() @safe @trusted nothrow @nogcReturns true if the assets path is used when loading.fn
void setIsUsingAssetsPath(bool value) @safe @trusted nothrow @nogcSets whether the assets path should be used when loading.fn
bool isLoggingLoadOrSaveFaults() @safe @trusted nothrow @nogcReturns true if load or save faults should be logged.fn
void setIsLoggingLoadOrSaveFaults(bool value) @safe @trusted nothrow @nogcSets whether load or save faults should be logged.fn
bool isLoggingMemoryTrackingInfo() @safe @trusted nothrow @nogcReturns true if memory tracking logs are enabled.fn
void setIsLoggingMemoryTrackingInfo(bool value, IStr pathFilter = "") @safe @trusted nothrow @nogcEnables or disables memory tracking logs.fn
bool isLoggingWithDprint() @safe @trusted nothrow @nogcReturns true if load or save faults should be logged with the `dprint` functions.fn
void setIsLoggingWithDprint(bool value) @safe @trusted nothrow @nogcSets whether load or save faults should be logged with the `dprint` functions.fn
bool isEnteringDebugMode() @safe @trusted nothrow @nogcReturns true when entering debug mode this frame.fn
bool isExitingDebugMode() @safe @trusted nothrow @nogcReturns true when exiting debug mode this frame.fn
void setIsDebugMode(bool value) @safe @trusted nothrow @nogcSets whether debug mode should be active.fn
void setDebugModeKey(Keyboard value) @safe @trusted nothrow @nogcSets the key that toggles debug mode.fn
void setWindowMinSize(int width, int height) @safe @trusted nothrow @nogcSets the minimum size of the window.fn
void setWindowMaxSize(int width, int height) @safe @trusted nothrow @nogcSets the maximum size of the window.fn
Rgba windowBackgroundColor() @safe @trusted nothrow @nogcReturns the current background color (fill color) of the window.fn
void setWindowBackgroundColor(Rgba value) @safe @trusted nothrow @nogcSets the background color (fill color) of the window.fn
Rgba windowBorderColor() @safe @trusted nothrow @nogcReturns the current color of the window borders shown when the aspect ratio is fixed.fn
void setWindowBorderColor(Rgba value) @safe @trusted nothrow @nogcSets the color of the window borders shown when the aspect ratio is fixed.fn
Fault setWindowIconFromFiles(IStr path) @safe @trusted nothrow @nogcSets the window icon using an texture file (PNG). Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the platform's nat...fn
void lockResolution(int width, int height) @safe @trusted nothrow @nogcLocks the resolution to the given width and height.fn
void toggleResolution(int width, int height) @safe @trusted nothrow @nogcToggles resolution lock using the specified width and height.fn
ViewportInfo engineViewportInfo() @safe @trusted nothrow @nogcReturns information about the engine viewport, including its size and position.fn
bool isFullscreen() @safe @trusted nothrow @nogcReturns true if the application is in fullscreen mode.fn
void setIsFullscreen(bool value) @safe @trusted nothrow @nogcSets whether the application should be in fullscreen mode.fn
void setIsCursorVisible(bool value) @safe @trusted nothrow @nogcSets whether the cursor should be visible.fn
void setVsync(bool value) @safe @trusted nothrow @nogcSets the vertical synchronization (VSync) state.fn
double elapsedTime() @safe @trusted nothrow @nogcReturns the total elapsed time since the application started. Prefer using `elapsedTickTime`.fn
double elapsedTickTime() @safe @trusted nothrow @nogcReturns the total elapsed time since the application started, at the start of the current tick.fn
ulong elapsedTicks() @safe @trusted nothrow @nogcReturns the total number of ticks since the application started.fn
int randi() @safe @trusted nothrow @nogcReturns a random integer between 0 and int.max (inclusive).fn
void setRandomSeed(int value) @safe @trusted nothrow @nogcSets the random number generator seed to the given value.fn
Filter defaultFilter() @safe @trusted nothrow @nogcReturns the default filter mode used for textures, fonts and viewports.fn
void setDefaultFilter(Filter value) @safe @trusted nothrow @nogcSets the default filter mode used for textures, fonts and viewports.fn
Wrap defaultWrap() @safe @trusted nothrow @nogcReturns the default wrap mode used for textures, fonts and viewports.fn
void setDefaultWrap(Wrap value) @safe @trusted nothrow @nogcSets the default wrap mode used for textures, fonts and viewports.fn
void setDefaultFont(FontId value) @safe @trusted nothrow @nogcSets the default font used for null fonts.fn
bool isNullTextureVisible() @safe @trusted nothrow @nogcReturns true if drawing is done when using a null texture.fn
void setIsNullTextureVisible(bool value) @safe @trusted nothrow @nogcSets whether drawing should be done when using a null texture.fn
bool isNullFontVisible() @safe @trusted nothrow @nogcReturns true if drawing is done when using a null font.fn
void setIsNullFontVisible(bool value) @safe @trusted nothrow @nogcSets whether drawing should be done when using a null font.fn
bool isPixelSnapped() @safe @trusted nothrow @nogcReturns true if drawing is snapped to pixel coordinates.fn
void setIsPixelSnapped(bool value) @safe @trusted nothrow @nogcSets whether drawing should snap to pixel coordinates.fn
void setIsPixelPerfect(bool value) @safe @trusted nothrow @nogcSets whether drawing should be pixel-perfect.fn
Vec2 measureTextSize(FontId font, IStr text, DrawOptions options = DrawOptions(), TextOptions extra = TextOptions()) @safe @trusted nothrow @nogcReturns the size of the text.fn
Vec2 toCanvasPoint(Vec2 point, Camera camera) @safe @trusted nothrow @nogcConverts a scene point to a canvas point using the given camera and resolution.fn
Vec2 toCanvasPoint(Vec2 point, Camera camera, Vec2 canvasSize) @safe @trusted nothrow @nogcConverts a scene point to a canvas point using the given camera and canvas size.fn
Vec2 toScenePoint(Vec2 point, Camera camera) @safe @trusted nothrow @nogcConverts a canvas point to a scene point using the given camera and resolution.fn
Vec2 toScenePoint(Vec2 point, Camera camera, Vec2 canvasSize) @safe @trusted nothrow @nogcConverts a canvas point to a scene point using the given camera and canvas size.fn
IStr[] envArgs() @safe @trusted nothrow @nogcReturns the arguments this application was started with.fn
IStr[] droppedPaths() @safe @trusted nothrow @nogcReturns the dropped paths from the current frame.fn
void takeScreenshot(IStr path, bool isUsingLockedResolution = false, bool hasAlpha = false, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrow @nogcTakes a screenshot and saves it to the given path. Uses the assets path unless the input starts with `/` or `\`, or `isUsingAssetsPath` is false. Path separators are normalized to the platform's na...fn
void requestScreenshot(bool isUsingLockedResolution = false, bool hasAlpha = false, IStr file = __FILE__, Sz line = __LINE__) @safe @trusted nothrow @nogcTakes a screenshot and creates a texture from it that can be used with the `getRequestedScreenshot` function.fn
bool getRequestedScreenshot(ref TextureId result, bool canFreeGivenTexture) @safe @trusted nothrow @nogcReturns the texture created by the last screenshot request, if available (true). When `canFreeGivenTexture` is true, the existing texture in `result` is freed.fn
Fault lastLoadOrSaveFault() @safe @trusted nothrow @nogcReturns the last fault from a load or save call.fn
bool didLoadOrSaveSucceed(Fault fault, IStr message) @safe @trusted nothrow @nogcHelper for checking the result of a load or save call. Returns true if the fault is none, false otherwise.fn
void freeAllResourceIds() @safe @trusted nothrow @nogcFrees all loaded textures, fonts, sounds, and viewports.fn
Vec2 deltaMouse() @safe @trusted nothrow @nogcReturns the change in mouse position since the last frame.fn
float deltaWheel() @safe @trusted nothrow @nogcReturns the change in mouse wheel position since the last frame.fn
bool isDown(char key) @safe @trusted nothrow @nogcReturns true if the specified character is currently pressed.fn
bool isDown(IStr keys) @safe @trusted nothrow @nogcReturns true if one of the specified characters is currently pressed.fn
bool isDown(const(Keyboard) key1, const(Keyboard)[] keys...) @safe @trusted nothrow @nogcReturns true if one of the specified keyboard keys is currently pressed.fn
bool isDown(Mouse key) @safe @trusted nothrow @nogcReturns true if the specified mouse button is currently pressed.fn
bool isDown(Gamepad key, int id = 0) @safe @trusted nothrow @nogcReturns true if the specified gamepad button is currently pressed.fn
bool isDown(InputBinding binding) @safe @trusted nothrow @nogcReturns true if any of the keyboard keys or the gamepad button in the specified binding is currently pressed.fn
bool isPressed(char key) @safe @trusted nothrow @nogcReturns true if the specified character was pressed this frame.fn
bool isPressed(IStr keys) @safe @trusted nothrow @nogcReturns true if one of the specified characters was pressed this frame.fn
bool isPressed(const(Keyboard) key1, const(Keyboard)[] keys...) @safe @trusted nothrow @nogcReturns true if one of the specified keyboard keys was pressed this frame.fn
bool isPressed(Mouse key) @safe @trusted nothrow @nogcReturns true if the specified mouse button was pressed this frame.fn
bool isPressed(Gamepad key, int id = 0) @safe @trusted nothrow @nogcReturns true if the specified gamepad button was pressed this frame.fn
bool isPressed(InputBinding binding) @safe @trusted nothrow @nogcReturns true if any of the keyboard keys or the gamepad button in the specified binding was pressed this frame.fn
bool isReleased(char key) @safe @trusted nothrow @nogcReturns true if the specified character was released this frame.fn
bool isReleased(IStr keys) @safe @trusted nothrow @nogcReturns true if one of the specified characters was released this frame.fn
bool isReleased(const(Keyboard) key1, const(Keyboard)[] keys...) @safe @trusted nothrow @nogcReturns true if one of the specified keyboard keys was released this frame.fn
bool isReleased(Mouse key) @safe @trusted nothrow @nogcReturns true if the specified mouse button was released this frame.fn
bool isReleased(Gamepad key, int id = 0) @safe @trusted nothrow @nogcReturns true if the specified gamepad button was released this frame.fn
bool isReleased(InputBinding binding) @safe @trusted nothrow @nogcReturns true if any of the keyboard keys or the gamepad button in the specified binding was released this frame.fn
Vec2 wasd() @safe @trusted nothrow @nogcReturns the direction from the WASD and arrow keys that are currently down. The result is not normalized.fn
Vec2 wasdPressed() @safe @trusted nothrow @nogcReturns the direction from the WASD and arrow keys that were pressed this frame. The result is not normalized.fn
Vec2 wasdReleased() @safe @trusted nothrow @nogcReturns the direction from the WASD and arrow keys that were released this frame. The result is not normalized.fn
Keyboard dequeuePressedKey() @safe @trusted nothrow @nogcReturns the next recently pressed keyboard key. This acts like a queue. Returns `Keyboard.none` if the queue is empty.fn
dchar dequeuePressedRune() @safe @trusted nothrow @nogcReturns the next recently pressed character. This acts like a queue. Returns `\0` if the queue is empty.fn
void attach(ref Camera camera, Rounding type = Rounding.none) @safe @trusted nothrow @nogcAttaches the given camera and makes it active.fn
void attach(ViewportId viewport) @safe @trusted nothrow @nogcAttaches the given viewport and makes it active.fn
void detach(ViewportId viewport) @safe @trusted nothrow @nogcDetaches the currently active viewport.fn
void beginClip(Rect area) @safe @trusted nothrow @nogcBegins a clipping region using the given area.fn
void beginClip(float x, float y, float w, float h) @safe @trusted nothrow @nogcBegins a clipping region using the given area.fn
void beginDepthSort(DepthSortMode mode = DepthSortMode.topDown) @safe @trusted nothrow @nogcBegins a depth sort. Works only with textures.fn
void drawRect(Rect area, Rgba color = white, float thickness = - 1.0f) @safe @trusted nothrow @nogcDraws a rectangle with the specified area and color.fn
void drawRect(Vec2 position, Vec2 size, Rgba color = white, float thickness = - 1.0f) @safe @trusted nothrow @nogcDraws a rectangle with the specified area and color.fn
void drawRect(float x, float y, float w, float h, Rgba color = white, float thickness = - 1.0f) @safe @trusted nothrow @nogcDraws a rectangle with the specified area and color.fn
void drawVec2(Vec2 point, Rgba color = white, float thickness = 9.0f) @safe @trusted nothrow @nogcDraws a point at the specified location with the given size and color.fn
void drawVec2(float x, float y, Rgba color = white, float thickness = 9.0f) @safe @trusted nothrow @nogcDraws a point at the specified location with the given size and color.fn
void drawCirc(Circ area, Rgba color = white, float thickness = - 1.0f) @safe @trusted nothrow @nogcDraws a circle with the specified area and color.fn
void drawCirc(Vec2 position, float radius, Rgba color = white, float thickness = - 1.0f) @safe @trusted nothrow @nogcDraws a circle with the specified area and color.fn
void drawCirc(float x, float y, float radius, Rgba color = white, float thickness = - 1.0f) @safe @trusted nothrow @nogcDraws a circle with the specified area and color.fn
void drawLine(Line area, Rgba color = white, float thickness = 9.0f) @safe @trusted nothrow @nogcDraws a line with the specified area, thickness, and color.fn
void drawLine(Vec2 a, Vec2 b, Rgba color = white, float thickness = 9.0f) @safe @trusted nothrow @nogcDraws a line with the specified area, thickness, and color.fn
void drawLine(float x1, float y1, float x2, float y2, Rgba color = white, float thickness = 9.0f) @safe @trusted nothrow @nogcDraws a line with the specified area, thickness, and color.fn
void drawSurface(ref Surface surface, Vec2 position, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws the surface at the given position with the specified draw options. Note: Surfaces are uploaded to a GPU atlas every frame they are drawn.fn
void drawSurfaceArea(ref Surface surface, Rect area, Vec2 position, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws a portion of the specified surface at the given position with the specified draw options. Note: Surfaces are uploaded to a GPU atlas every frame they are drawn.fn
void drawTexture(TextureId texture, Vec2 position, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws the texture at the given position with the specified draw options.fn
void drawTextureArea(TextureId texture, Rect area, Vec2 position, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws a portion of the specified texture at the given position with the specified draw options.fn
void drawTextureSlice(TextureId texture, Rect area, Rect target, Margin margin, bool canRepeat, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws a 9-slice from the specified texture area at the given target area.fn
void drawViewportArea(ViewportId viewport, Rect area, Vec2 position, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws a portion of the specified viewport at the given position with the specified draw options.fn
void drawViewport(ViewportId viewport, Vec2 position, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws the viewport at the given position with the specified draw options.fn
Vec2 drawRune(FontId font, dchar rune, Vec2 position, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws a single character from the specified font at the given position with the specified draw options.fn
Vec2 drawRune(dchar rune, Vec2 position, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws a single character from the default font at the given position with the specified draw options. Call `setDefaultFont` before using this function.fn
Vec2 drawText(FontId font, IStr text, Vec2 position, DrawOptions options = DrawOptions(), TextOptions extra = TextOptions()) @safe @trusted nothrow @nogcDraws the specified text with the given font at the given position using the provided draw options.fn
Vec2 drawText(IStr text, Vec2 position, DrawOptions options = DrawOptions(), TextOptions extra = TextOptions()) @safe @trusted nothrow @nogcDraws text with the default font at the given position with the provided draw options. Call `setDefaultFont` before using this function.fn
void dprintfln(A...)(IStr fmtStr, A args) @safe @trusted nothrow @nogcAppend a formatted line to the overlay text buffer. Drawn after everything else using the current default font.fn
void dprintln(A...)(A args) @safe @trusted nothrow @nogcAppend a line to the overlay text buffer. Drawn after everything else using the current default font.fn
IStr dprintBuffer() @safe @trusted nothrow @nogcReturns the contents of the overlay text buffer. The returned string references the internal buffer and may change if more text is printed.fn
void setDprintPosition(Vec2 value) @safe @trusted nothrow @nogcSets the position of the overlay text.fn
void setDprintOptions(DrawOptions value) @safe @trusted nothrow @nogcSets the drawing options for the overlay text.fn
void setDprintLineCountLimit(Sz value) @safe @trusted nothrow @nogcSets the maximum number of overlay text lines. Older lines are removed once this limit is reached. Use 0 for unlimited.fn
void setDprintVisibility(bool value) @safe @trusted nothrow @nogcSets the visibility state of the overlay text. Does not affect manual drawing via `drawDprintBuffer`.fn
void toggleDprintVisibility() @safe @trusted nothrow @nogcToggles the visibility state of the overlay text. Does not affect manual drawing via `drawDprintBuffer`.fn
void drawDprintBuffer() @safe @trusted nothrow @nogcDraws the overlay text now instead of at the end of the frame. The text will still be drawn automatically later unless the buffer is cleared with `clearDprintBuffer`, or visibility is disabled with...fn
void drawDebugEngineInfo(Vec2 screenPoint, Camera camera = Camera(), DrawOptions options = DrawOptions(), bool isLogging = false) @safe @trusted nothrow @nogcDraws debug engine information at the given position with the provided draw options. Hold the left mouse button to create and resize a debug area. Hold the right mouse button to move the debug area...fn
void drawDebugTileInfo(int tileWidth, int tileHeight, Vec2 screenPoint, Camera camera = Camera(), DrawOptions options = DrawOptions(), bool isLogging = false) @safe @trusted nothrow @nogcDraws debug tile information at the given position with the provided draw options.fn
void playSound(SoundId sound) @safe @trusted nothrow @nogcPlays the given sound. If the sound is already playing, this has no effect.fn
void startSound(SoundId sound) @safe @trusted nothrow @nogcStarts playback of the given sound from the beginning.fn
void resumeSound(SoundId sound) @safe @trusted nothrow @nogcResumes playback of the given sound if it was paused.fn
void toggleSoundIsActive(SoundId sound) @safe @trusted nothrow @nogcToggles whether the sound is playing or stopped.fn
void toggleSoundIsPaused(SoundId sound) @safe @trusted nothrow @nogcToggles whether the sound is paused or resumed.fn
void drawTile(TextureId texture, Tile tile, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws a tile with a texture.fn
void drawTileMap(Sz N)(TextureId texture, ref GTileMap!N map, Rect viewArea = Rect(), DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws a tile map with a texture. The view area controls what is visible.fn
void drawTileMap(Sz N)(TextureId texture, ref GTileMap!N map, Camera camera, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws a tile map with a texture. The camera controls what is visible.fn
void drawSprite(TextureId texture, Sprite sprite, DrawOptions options = DrawOptions()) @safe @trusted nothrow @nogcDraws a sprite with a texture. The Hook and Flip of the options is ignored.fn
void drawSpriteStackLayer(TextureId texture, SpriteStack stack, uint layer, Rgba layerColor = white, float layerScale = 1.0f) @safe @trusted nothrow @nogcDraws a sprite stack later.fn
void drawSpriteStack(TextureId texture, SpriteStack stack, Rgba layerColor = white, float layerScale = 1.0f) @safe @trusted nothrow @nogcDraws a sprite stack as is, without any depth.fn
void drawDebugBoxWorld(ref BoxWorld world, Rgba actorColor = blue, Rgba wallColor = maroon) @safe @trusted nothrow @nogcDraws debug rectangles based on the given box world.Variables 30
var
EngineState * _engineStateenumvar
defaultEngineTitle = "Parin"enumvar
defaultEngineWidth = 1280enumvar
defaultEngineHeight = 720enumvar
defaultEngineVsync = trueenumvar
defaultEngineFpsMax = 60enumvar
defaultEngineWindowMinWidth = 320enumvar
defaultEngineWindowMinHeight = 180enumvar
defaultEngineWindowMinSize = Vec2(defaultEngineWindowMinWidth, defaultEngineWindowMinHeight)enumvar
defaultEngineDebugModeKey = Keyboard.f3enumvar
defaultEngineFlags = EngineFlag.isUsingAssetsPath |
EngineFlag.isNullTextureVisible |
EngineFlag.isNullFontVisible |
EngineFlag.isLoggingLoadOrSaveFaults |
EngineFlag.isLoggingMemoryTrackingInfoenumvar
defaultEngineValidateErrorMessage = "Resource is invalid or was never assigned."enumvar
defaultEngineLoadErrorMessage = "ERROR({}:{}): Can't load {} from \"{}\""enumvar
defaultEngineSaveErrorMessage = "ERROR({}:{}): Can't save {} to \"{}\""enumvar
defaultEngineLoadOrSaveTextCapacity = 16 * kilobyteenumvar
defaultEngineEnvArgsCapacity = (64 / defaultEngineResourceScaleDenominator)enumvar
defaultEngineEngineTasksCapacity = (64 / defaultEngineResourceScaleDenominator)enumvar
defaultEngineAssetsPathCapacity = (8 / defaultEngineResourceScaleDenominator) * kilobyteenumvar
defaultEngineScreenshotTargetPathCapacity = (2 / defaultEngineResourceScaleDenominator) * kilobyteenumvar
defaultEngineArenaCapacity = (4 / defaultEngineResourceScaleDenominator) * megabyteenumvar
defaultEngineDprintCapacity = (4 / defaultEngineResourceScaleDenominator) * kilobyteenumvar
defaultEngineDprintPosition = Vec2(3, 3)enumvar
defaultEngineDprintLineCountLimit = 13enumvar
defaultEngineDprintFont = engineFontenumvar
defaultEngineDebugColor1 = white.alpha(120)enumvar
defaultEngineDebugColor2 = black.alpha(170)enumvar
engineFont = FontId(ResourceId(1))The engine font identifier.
enumvar
engineFontSmall = FontId(ResourceId(2))The second engine font identifier.
enumvar
engineViewport = ViewportId(ResourceId(1))The engine viewport identifier.
enumvar
_screenshotRequestPath = "[SCREENSHOT]"