- Replace ffi module with bindgen.
- Hand coding ffi gives us more control, but makes it much harder to support multiple architectures which might interpret enums differently (caugh wasm).
- We can use binggen and build.rs ins raylib-sys to expose all the functions in raylib.
- Use Argdev's cmake system if we can get cmake to compile to any architecture for any architecture otherwise use the cc crate.
- Hoping to support windows, mac, linux, and web at the very least with pi, android, ios, and UWP later.
- Implement the new architecture. At the very least get core working.
- See new architecture.
- Bundle in rgui as a feature flag.
- I think rgui should come in by default since it's cheap, but that's debatable.
We should take advantage of rust's type system to make UB impossible. We do this mostly through drop already, but it's still possible to do things like start draw before initializing the window. The draw process should look like this
let drawCtx = handle.start_draw();
// Do the draw
let handle = drawCtx.end_draw();
// Using a texture
let drawCtx = handle.begin_texture_mode(target)
// Do the draw
let (target, handle) = drawCtx.end_draw();
This could be done by having two zero sized types RegularDraw and TextureDraw that implement an unsafe trait RaylibDraw.
We'd have to figure out how to keep things thread safe. I'm open to suggestions.
below are all functions currently exposed by raylib. I've maked them safe, safe with specific caveats, and always unsafe.
Safe for a function means you can call it from any thread assuming you have a &RaylibContext or &mut RaylibContext. Unsafe for a function means you probably can't call it from any thread with out some concurrency guarentees (Often &mut RalibContext will be enough) A ? means I'm not entirely sure if the function belongs in the category.
Safe for a struct means the traits Clone and Send/Sync are trivial to implement and a drop implementation is mostly unecessary.
GetMonitorCount GetMonitorWidth GetMonitorHeight GetMonitorPhysicalWidth GetMonitorPhysicalHeight GetMonitorName GetClipboardText SetClipboardText
GetWorldToScreen GetCameraMatrix
ColorToInt ColorNormalize ColorToHSV ColorFromHSV GetColor Fade
SetTraceLogLevel SetTraceLogExit SetTraceLogCallback TraceLog
GetRandomValue
FileExists IsFileExtension GetExtension GetFileName GetDirectoryPath GetWorkingDirectory
ChangeDirectory GetFileModTime
StorageSaveValue StorageLoadValue
OpenURL
IsKeyPressed IsKeyDown IsKeyReleased IsKeyUp GetKeyPressed SetExitKey
IsGamepadAvailable IsGamepadName GetGamepadName IsGamepadButtonPressed IsGamepadButtonDown IsGamepadButtonReleased IsGamepadButtonUp GetGamepadButtonPressed GetGamepadAxisCount GetGamepadAxisMovement
IsMouseButtonPressed IsMouseButtonDown IsMouseButtonReleased IsMouseButtonUp GetMouseX GetMouseY GetMousePosition SetMousePosition SetMouseOffset SetMouseScale GetMouseWheelMove
GetTouchX GetTouchY GetTouchPosition
SetGesturesEnabled IsGestureDetected GetGestureDetected GetTouchPointsCount GetGestureHoldDuration GetGestureDragVector GetGestureDragAngle GetGesturePinchVector GetGesturePinchAngle
SetCameraMode ?UpdateCamera - does this require window
SetCameraPanControl SetCameraAltControl SetCameraSmoothZoomControl SetCameraMoveControls
?SetConfigFlags - before window is open
WindowShouldClose IsWindowReady IsWindowMinimized IsWindowResized IsWindowHidden ?ToggleFullscreen - can this be called every frame ?UnhideWindow - safe if not hidden? ?HideWindow SetWindowIcon SetWindowTitle SetWindowPosition GetScreenWidth GetScreenHeight
GetMouseRay
ShowCursor HideCursor IsCursorHidden EnableCursor DisableCursor
?BeginDrawing - can only be called once
SetTargetFPS GetFPS GetFrameTime GetTime
TakeScreenshot
IsFileDropped
ClearBackground EndDrawing BeginMode2D BeginMode3D BeginTextureMode
EndMode2D
EndMode3D
EndTextureMode
InitWindow - can only be called once CloseWindow - can only be called once SetWindowMonitor - only works in full screen mode SetWindowMinSize - only if FLAG_WINDOW_RESIZABLE is set SetWindowSize - only if FLAG_WINDOW_RESIZABLE is set
GetFileNameWithoutExt - memory should be freed GetDirectoryFiles && ClearDirectoryFiles - memory should be freed GetDroppedFiles && ClearDroppedFiles - free memory
GetWindowHandle
CheckCollisionRecs CheckCollisionCircles CheckCollisionCircleRec GetCollisionRec CheckCollisionPointRec CheckCollisionPointCircle CheckCollisionPointTriangle
DrawPixel DrawPixelV DrawLine DrawLineV DrawLineEx DrawLineBezier DrawCircle DrawCircleSector DrawCircleSectorLines DrawCircleGradient DrawCircleV DrawCircleLines DrawRing DrawRingLines DrawRectangle DrawRectangleV DrawRectangleRec DrawRectanglePro DrawRectangleGradientV DrawRectangleGradientH DrawRectangleGradientEx DrawRectangleLines DrawRectangleLinesEx DrawRectangleRounded DrawRectangleRoundedLines DrawTriangle DrawTriangleLines DrawPoly DrawPolyEx DrawPolyExLines
?SetShapesTexture - is this a window open op
LoadImage && UnloadImage LoadImageEx LoadImagePro ?LoadImageRaw - Feels very unsafe. ExportImage ExportImageAsCode LoadTexture && UnloadTexture LoadTextureFromImage LoadTextureCubemap LoadRenderTexture GetPixelDataSize GetTextureData
ImageCopy ImageFormat ImageAlphaMask ImageAlphaClear ImageAlphaCrop ImageAlphaPremultiply ImageCrop ImageResize ImageResizeNN ImageResizeCanvas ImageMipmaps ImageDither ImageExtractPalette ImageText ImageTextEx ImageFlipVertical ImageFlipHorizontal ImageRotateCW ImageRotateCCW ImageColorTint ImageColorInvert ImageColorGrayscale ImageColorContrast ImageColorBrightness ImageColorReplace
GenImageColor GenImageGradientV GenImageGradientH GenImageGradientRadial GenImageChecked GenImageWhiteNoise GenImagePerlinNoise GenImageCellular
GenTextureMipmaps SetTextureFilter SetTextureWrap
GetScreenData
ImageDraw ImageDrawRectangle ImageDrawRectangleLines ImageDrawText ImageDrawTextEx
DrawTexture DrawTextureV DrawTextureEx DrawTextureRec DrawTextureQuad DrawTexturePro DrawTextureNPatch
GetImageData GetImageDataNormalized UpdateTexture ImageToPOT
GetFontDefault LoadFont & UnloadFont LoadFontEx LoadFontFromImage LoadFontData GenImageFontAtlas
MeasureText MeasureTextEx GetGlyphIndex
TextIsEqual TextLength TextFormat TextSubtext TextReplace TextInsert TextJoin TextSplit TextAppend TextFindIndex TextToUpper TextToLower TextToPascal TextToInteger
DrawFPS DrawText DrawTextEx DrawTextRec DrawTextRecEx
LoadModel && UnloadModel LoadModelFromMesh
LoadMeshes && UnloadMesh ExportMesh
LoadMaterials LoadMaterialDefault UnloadMaterial SetMaterialTexture SetModelMeshMaterial
LoadModelAnimations UpdateModelAnimation UnloadModelAnimation IsModelAnimationValid
GenMeshPoly GenMeshPlane GenMeshCube GenMeshSphere GenMeshHemiSphere GenMeshCylinder GenMeshTorus GenMeshKnot GenMeshHeightmap GenMeshCubicmap
MeshBoundingBox MeshTangents MeshBinormals
CheckCollisionSpheres CheckCollisionBoxes CheckCollisionBoxSphere CheckCollisionRaySphere CheckCollisionRaySphereEx CheckCollisionRayBox GetCollisionRayModel GetCollisionRayTriangle GetCollisionRayGround
DrawLine3D DrawCircle3D DrawCube DrawCubeV DrawCubeWires DrawCubeWiresV DrawCubeTexture DrawSphere DrawSphereEx DrawSphereWires DrawCylinder DrawCylinderWires DrawPlane DrawRay DrawGrid DrawGizmo
DrawModel DrawModelEx DrawModelWires DrawModelWiresEx DrawBoundingBox DrawBillboard DrawBillboardRec
LoadText LoadShader LoadShaderCode UnloadShader
GetShaderLocation SetShaderValue SetShaderValueV SetShaderValueMatrix SetShaderValueTexture SetMatrixProjection SetMatrixModelview GetMatrixModelview
GetShaderDefault GetTextureDefault
BeginShaderMode EndShaderMode BeginBlendMode EndBlendMode BeginScissorMode EndScissorMode
InitVrSimulator CloseVrSimulator UpdateVrTracking SetVrConfiguration IsVrSimulatorReady ToggleVrMode BeginVrDrawing EndVrDrawing
InitAudioDevice IsAudioDeviceReady
LoadWave LoadWaveEx LoadSound LoadSoundFromWave UpdateSound UnloadWave UnloadSound ExportWave ExportWaveAsCode
SetSoundVolume SetSoundPitch WaveFormat WaveCopy GetWaveData
LoadMusicStream - UnloadMusicStream UpdateMusicStream SetMusicVolume SetMusicPitch SetMusicLoopCount GetMusicTimeLength GetMusicTimePlayed
InitAudioStream CloseAudioStream IsAudioBufferProcessed
SetAudioStreamVolume SetAudioStreamPitch
CloseAudioDevice IsAudioDeviceReady
PlaySound PauseSound ResumeSound StopSound IsSoundPlaying
PlayMusicStream StopMusicStream PauseMusicStream ResumeMusicStream IsMusicPlaying
PlayAudioStream PauseAudioStream ResumeAudioStream IsAudioStreamPlaying StopAudioStream
Vector2 Vector3 Vector4 Quaternion Matrix Color Rectangle
NPatchInfo CharInfo
Camera Camera2D Mesh MaterialMap
Transform BoneInfo ?ModelAnimation Ray RayHitInfo BoundingBox
Image Texture
RenderTexture NPatchInfo Font Shader Material Model