h-raylib-5.1.3.0: Raylib bindings for Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Raylib.Util

Description

Utility functions that may be useful for an h-raylib application

Synopsis

Bracket functions

withWindow Source #

Arguments

:: (MonadIO m, MonadMask m) 
=> Int

Window width

-> Int

Window height

-> String

Window title

-> Int

Target FPS

-> (WindowResources -> m b) 
-> m b 

NOTE: Only for native targets. If your program is intended to run on the web, use raylibApplication instead.

drawing :: (MonadIO m, MonadMask m) => m b -> m b Source #

mode2D :: (MonadIO m, MonadMask m) => Camera2D -> m b -> m b Source #

mode3D :: (MonadIO m, MonadMask m) => Camera3D -> m b -> m b Source #

textureMode :: (MonadIO m, MonadMask m) => RenderTexture -> m b -> m b Source #

shaderMode :: (MonadIO m, MonadMask m) => Shader -> m b -> m b Source #

blendMode :: (MonadIO m, MonadMask m) => BlendMode -> m b -> m b Source #

scissorMode :: (MonadIO m, MonadMask m) => Int -> Int -> Int -> Int -> m b -> m b Source #

Game loop functions

raylibApplication Source #

Arguments

:: Name

The startup function, should be of type IO AppState

-> Name

The mainLoop function, should be of type AppState -> IO AppState

-> Name

The shouldClose function, should be of type AppState -> IO Bool

-> Name

The teardown function, should be of type AppState -> IO ()

-> DecsQ 

Creates a raylib application using the given program functions. Supports both native and web targets, so it is recommended for all programs. If your program is intended only for native use, you may manually write a main function.

On a native (non-web) target, it simply creates a main function that uses the startup, mainLoop, shouldClose, and teardown functions. When building with platform-web enabled, it creates four foreign export statements (startup, mainLoop, shouldClose, and teardown), which will be called through the browser.

See raygui-suite for an example of how to use it.

whileWindowOpen Source #

Arguments

:: MonadIO m 
=> (a -> m a)

The game loop. Its only argument should be the current application state, and it should return a new state.

-> a

The initial application state.

-> m a

The application state after the last frame.

Calls the game loop every frame as long as the window is open. For larger projects, instead of using this function, consider making a custom game loop for flexibility.

NOTE: Only for native targets. If your program is intended to run on the web, use raylibApplication instead.

whileWindowOpen_ :: MonadIO m => (a -> m a) -> a -> m () Source #

Same as whileWindowOpen, but discards the final state.

whileWindowOpen0 :: MonadIO m => m () -> m () Source #

Same as whileWindowOpen, but without application state.

Miscellaneous

cameraDirectionRay :: Camera3D -> Ray Source #

Gets the direction of a camera as a ray.

setMaterialShader Source #

Arguments

:: Model

The model to operate on

-> Int

The index of the material

-> Shader

The shader to use

-> Model

The modified model

Sets the shader of a material at a specific index (WARNING: This will fail if the index provided is out of bounds).

inGHCi :: Bool Source #

True if the program is running in GHCi

inWeb :: Bool Source #

True if the program is running in the web

data WindowResources Source #

Tracks all raylib resources which cannot be immediately freed.

Each field is an IORef to a list, and the list contains the data to be tracked. Typically, data allocated on the GPU is stored here.

class Freeable a where Source #

A typeclass used internally to free complex data types. You will most likely not have to use this directly. If you do need to implement it, you can probably just stick with the default definitions of rlFree and rlFreeDependents.

Minimal complete definition

Nothing

Methods

rlFreeDependents :: a -> Ptr a -> IO () Source #

Frees the data "dependent" on a pointer, which usually means dynamic C arrays, i.e. more pointers

rlFree :: a -> Ptr a -> IO () Source #

Receives a pointer and frees all of the data associated with it, including the pointer itself

Instances

Instances details
Freeable CBool Source # 
Instance details

Defined in Raylib.Internal.Foreign

Freeable CChar Source # 
Instance details

Defined in Raylib.Internal.Foreign

Freeable CFloat Source # 
Instance details

Defined in Raylib.Internal.Foreign

Freeable CInt Source # 
Instance details

Defined in Raylib.Internal.Foreign

Methods

rlFreeDependents :: CInt -> Ptr CInt -> IO () Source #

rlFree :: CInt -> Ptr CInt -> IO () Source #

Freeable CShort Source # 
Instance details

Defined in Raylib.Internal.Foreign

Freeable CUChar Source # 
Instance details

Defined in Raylib.Internal.Foreign

Freeable CUInt Source # 
Instance details

Defined in Raylib.Internal.Foreign

Freeable CUShort Source # 
Instance details

Defined in Raylib.Internal.Foreign

Freeable AutomationEvent Source # 
Instance details

Defined in Raylib.Types.Core

Freeable AutomationEventList Source # 
Instance details

Defined in Raylib.Types.Core

Freeable Color Source # 
Instance details

Defined in Raylib.Types.Core

Freeable ConfigFlag Source # 
Instance details

Defined in Raylib.Types.Core

Freeable FilePathList Source # 
Instance details

Defined in Raylib.Types.Core

Freeable Matrix Source # 
Instance details

Defined in Raylib.Types.Core

Freeable Rectangle Source # 
Instance details

Defined in Raylib.Types.Core

Freeable Vector2 Source # 
Instance details

Defined in Raylib.Types.Core

Freeable Vector3 Source # 
Instance details

Defined in Raylib.Types.Core

Freeable Vector4 Source # 
Instance details

Defined in Raylib.Types.Core

Freeable VrDeviceInfo Source # 
Instance details

Defined in Raylib.Types.Core

Freeable VrStereoConfig Source # 
Instance details

Defined in Raylib.Types.Core

Freeable AudioStream Source # 
Instance details

Defined in Raylib.Types.Core.Audio

Freeable Music Source # 
Instance details

Defined in Raylib.Types.Core.Audio

Freeable RAudioBuffer Source # 
Instance details

Defined in Raylib.Types.Core.Audio

Freeable RAudioProcessor Source # 
Instance details

Defined in Raylib.Types.Core.Audio

Freeable Sound Source # 
Instance details

Defined in Raylib.Types.Core.Audio

Freeable Wave Source # 
Instance details

Defined in Raylib.Types.Core.Audio

Methods

rlFreeDependents :: Wave -> Ptr Wave -> IO () Source #

rlFree :: Wave -> Ptr Wave -> IO () Source #

Freeable Camera2D Source # 
Instance details

Defined in Raylib.Types.Core.Camera

Freeable Camera3D Source # 
Instance details

Defined in Raylib.Types.Core.Camera

Freeable BoneInfo Source # 
Instance details

Defined in Raylib.Types.Core.Models

Freeable BoundingBox Source # 
Instance details

Defined in Raylib.Types.Core.Models

Freeable Material Source # 
Instance details

Defined in Raylib.Types.Core.Models

Freeable MaterialMap Source # 
Instance details

Defined in Raylib.Types.Core.Models

Freeable Mesh Source # 
Instance details

Defined in Raylib.Types.Core.Models

Methods

rlFreeDependents :: Mesh -> Ptr Mesh -> IO () Source #

rlFree :: Mesh -> Ptr Mesh -> IO () Source #

Freeable Model Source # 
Instance details

Defined in Raylib.Types.Core.Models

Freeable ModelAnimation Source # 
Instance details

Defined in Raylib.Types.Core.Models

Freeable Ray Source # 
Instance details

Defined in Raylib.Types.Core.Models

Methods

rlFreeDependents :: Ray -> Ptr Ray -> IO () Source #

rlFree :: Ray -> Ptr Ray -> IO () Source #

Freeable RayCollision Source # 
Instance details

Defined in Raylib.Types.Core.Models

Freeable Shader Source # 
Instance details

Defined in Raylib.Types.Core.Models

Freeable Transform Source # 
Instance details

Defined in Raylib.Types.Core.Models

Freeable Font Source # 
Instance details

Defined in Raylib.Types.Core.Text

Methods

rlFreeDependents :: Font -> Ptr Font -> IO () Source #

rlFree :: Font -> Ptr Font -> IO () Source #

Freeable GlyphInfo Source # 
Instance details

Defined in Raylib.Types.Core.Text

Freeable Image Source # 
Instance details

Defined in Raylib.Types.Core.Textures

Freeable NPatchInfo Source # 
Instance details

Defined in Raylib.Types.Core.Textures

Freeable RenderTexture Source # 
Instance details

Defined in Raylib.Types.Core.Textures

Freeable Texture Source # 
Instance details

Defined in Raylib.Types.Core.Textures

Freeable GuiStyleProp Source # 
Instance details

Defined in Raylib.Types.Util.GUI

Freeable RLDrawCall Source # 
Instance details

Defined in Raylib.Types.Util.RLGL

Freeable RLRenderBatch Source # 
Instance details

Defined in Raylib.Types.Util.RLGL

Freeable RLVertexBuffer Source # 
Instance details

Defined in Raylib.Types.Util.RLGL

Freeable (Ptr CChar) Source # 
Instance details

Defined in Raylib.Internal.Foreign

(Freeable a, Storable a) => Freeable [a] Source # 
Instance details

Defined in Raylib.Internal.Foreign

Methods

rlFreeDependents :: [a] -> Ptr [a] -> IO () Source #

rlFree :: [a] -> Ptr [a] -> IO () Source #