Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Sep 22, 2023
1 parent e89a1ac commit b45e93d
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 57 deletions.
86 changes: 60 additions & 26 deletions api/raylib.json
Original file line number Diff line number Diff line change
Expand Up @@ -3006,8 +3006,8 @@
"name": "fileName"
},
{
"type": "unsigned int *",
"name": "bytesRead"
"type": "int *",
"name": "dataSize"
}
]
},
Expand All @@ -3025,8 +3025,8 @@
"name": "data"
},
{
"type": "unsigned int",
"name": "bytesToWrite"
"type": "int",
"name": "dataSize"
}
]
},
Expand Down Expand Up @@ -3273,6 +3273,21 @@
}
]
},
{
"name": "SetWindowMaxSize",
"description": "Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)",
"returnType": "void",
"params": [
{
"type": "int",
"name": "width"
},
{
"type": "int",
"name": "height"
}
]
},
{
"name": "SetWindowSize",
"description": "Set window dimensions",
Expand Down Expand Up @@ -4162,8 +4177,8 @@
"name": "fileName"
},
{
"type": "unsigned int *",
"name": "bytesRead"
"type": "int *",
"name": "dataSize"
}
]
},
Expand Down Expand Up @@ -4192,8 +4207,8 @@
"name": "data"
},
{
"type": "unsigned int",
"name": "bytesToWrite"
"type": "int",
"name": "dataSize"
}
]
},
Expand All @@ -4207,8 +4222,8 @@
"name": "data"
},
{
"type": "unsigned int",
"name": "size"
"type": "int",
"name": "dataSize"
},
{
"type": "const char *",
Expand Down Expand Up @@ -4363,7 +4378,7 @@
},
{
"name": "GetApplicationDirectory",
"description": "Get the directory if the running application (uses static string)",
"description": "Get the directory of the running application (uses static string)",
"returnType": "const char *"
},
{
Expand Down Expand Up @@ -4917,7 +4932,7 @@
"returnType": "bool",
"params": [
{
"type": "int",
"type": "unsigned int",
"name": "gesture"
}
]
Expand Down Expand Up @@ -6206,6 +6221,25 @@
}
]
},
{
"name": "LoadImageSvg",
"description": "Load image from SVG file data or string with specified size",
"returnType": "Image",
"params": [
{
"type": "const char *",
"name": "fileNameOrString"
},
{
"type": "int",
"name": "width"
},
{
"type": "int",
"name": "height"
}
]
},
{
"name": "LoadImageAnim",
"description": "Load image sequence from file (frames appended to image.data)",
Expand Down Expand Up @@ -8036,7 +8070,7 @@
},
{
"name": "LoadFontEx",
"description": "Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set",
"description": "Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character setFont",
"returnType": "Font",
"params": [
{
Expand All @@ -8049,11 +8083,11 @@
},
{
"type": "int *",
"name": "fontChars"
"name": "codepoints"
},
{
"type": "int",
"name": "glyphCount"
"name": "codepointCount"
}
]
},
Expand Down Expand Up @@ -8099,11 +8133,11 @@
},
{
"type": "int *",
"name": "fontChars"
"name": "codepoints"
},
{
"type": "int",
"name": "glyphCount"
"name": "codepointCount"
}
]
},
Expand Down Expand Up @@ -8137,11 +8171,11 @@
},
{
"type": "int *",
"name": "fontChars"
"name": "codepoints"
},
{
"type": "int",
"name": "glyphCount"
"name": "codepointCount"
},
{
"type": "int",
Expand All @@ -8156,11 +8190,11 @@
"params": [
{
"type": "const GlyphInfo *",
"name": "chars"
"name": "glyphs"
},
{
"type": "Rectangle **",
"name": "recs"
"name": "glyphRecs"
},
{
"type": "int",
Expand All @@ -8187,7 +8221,7 @@
"params": [
{
"type": "GlyphInfo *",
"name": "chars"
"name": "glyphs"
},
{
"type": "int",
Expand Down Expand Up @@ -8375,7 +8409,7 @@
},
{
"type": "int",
"name": "count"
"name": "codepointCount"
},
{
"type": "Vector2",
Expand Down Expand Up @@ -10054,7 +10088,7 @@
"name": "fileName"
},
{
"type": "unsigned int *",
"type": "int *",
"name": "animCount"
}
]
Expand Down Expand Up @@ -10099,8 +10133,8 @@
"name": "animations"
},
{
"type": "unsigned int",
"name": "count"
"type": "int",
"name": "animCount"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/raylib
Submodule raylib updated 92 files
+1 −1 .github/workflows/linux.yml
+1 −1 .github/workflows/webassembly.yml
+6 −3 BINDINGS.md
+5 −0 CMakeOptions.txt
+1 −1 README.md
+5 −0 cmake/CompileDefinitions.cmake
+1 −2 cmake/InstallConfigurations.cmake
+0 −13 cmake/LibraryConfigurations.cmake
+6 −51 examples/Makefile
+12 −54 examples/Makefile.Web
+21 −20 examples/README.md
+10 −1 examples/audio/audio_module_playing.c
+ examples/audio/audio_module_playing.png
+ examples/audio/audio_sound_multi.png
+ examples/core/core_2d_camera_smooth_pixelperfect.png
+167 −0 examples/core/core_2d_camera_split_screen.c
+ examples/core/core_2d_camera_split_screen.png
+1 −1 examples/core/core_3d_camera_free.c
+55 −32 examples/core/core_3d_camera_split_screen.c
+ examples/core/core_3d_camera_split_screen.png
+1 −1 examples/core/core_basic_window_web.c
+2 −7 examples/core/core_input_gamepad.c
+ examples/core/core_split_screen.png
+1 −1 examples/core/core_vr_simulator.c
+7 −7 examples/models/models_loading_gltf.c
+ examples/models/models_loading_gltf.png
+18 −17 examples/models/models_loading_m3d.c
+ examples/models/models_loading_m3d.png
+1 −1 examples/models/models_skybox.c
+11 −11 examples/others/easings_testbed.c
+ examples/others/easings_testbed.png
+1 −1 examples/others/raylib_opengl_interop.c
+3 −3 examples/shaders/resources/shaders/glsl100/wave.fs
+3 −3 examples/shaders/resources/shaders/glsl330/wave.fs
+1 −1 examples/shaders/shaders_basic_lighting.c
+1 −1 examples/shaders/shaders_custom_uniform.c
+1 −1 examples/shaders/shaders_eratosthenes.c
+1 −1 examples/shaders/shaders_fog.c
+1 −1 examples/shaders/shaders_hot_reloading.c
+1 −1 examples/shaders/shaders_hybrid_render.c
+1 −1 examples/shaders/shaders_julia_set.c
+1 −1 examples/shaders/shaders_lightmap.c
+1 −1 examples/shaders/shaders_mesh_instancing.c
+1 −1 examples/shaders/shaders_model_shader.c
+1 −1 examples/shaders/shaders_multi_sample2d.c
+1 −1 examples/shaders/shaders_palette_switch.c
+1 −1 examples/shaders/shaders_postprocessing.c
+1 −1 examples/shaders/shaders_raymarching.c
+1 −1 examples/shaders/shaders_shapes_textures.c
+1 −1 examples/shaders/shaders_simple_mask.c
+1 −1 examples/shaders/shaders_spotlight.c
+1 −1 examples/shaders/shaders_texture_drawing.c
+10 −10 examples/shaders/shaders_texture_outline.c
+ examples/shaders/shaders_texture_outline.png
+2 −2 examples/shaders/shaders_texture_waves.c
+1 −1 examples/shaders/shaders_write_depth.c
+5 −1 examples/shapes/shapes_bouncing_ball.c
+4 −1 examples/shapes/shapes_collision_area.c
+ examples/shapes/shapes_collision_area.png
+21 −3 examples/shapes/shapes_lines_bezier.c
+155 −0 examples/shapes/shapes_lines_splines.c
+2 −0 examples/text/text_codepoints_loading.c
+2 −0 examples/text/text_font_loading.c
+1 −1 examples/text/text_font_sdf.c
+1 −0 examples/textures/resources/test.svg
+2 −1 examples/textures/textures_fog_of_war.c
+ examples/textures/textures_fog_of_war.png
+3 −1 examples/textures/textures_image_rotate.c
+ examples/textures/textures_image_rotate.png
+72 −0 examples/textures/textures_svg_loading.c
+ examples/textures/textures_svg_loading.png
+1 −1 projects/CMake/core_basic_window.c
+387 −0 projects/VS2022/examples/core_2d_camera_split_screen.vcxproj
+3 −3 projects/VS2022/examples/core_3d_camera_split_screen.vcxproj
+38 −19 projects/VS2022/raylib.sln
+1 −1 projects/VSCode/Makefile
+6 −55 src/Makefile
+15 −15 src/config.h
+10,713 −11,578 src/external/miniaudio.h
+5 −5 src/external/msf_gif.h
+3,053 −0 src/external/nanosvg.h
+1,458 −0 src/external/nanosvgrast.h
+20 −20 src/raudio.c
+17 −15 src/raylib.h
+53 −34 src/raymath.h
+198 −188 src/rcore.c
+1 −1 src/rgestures.h
+28 −13 src/rlgl.h
+35 −33 src/rmodels.c
+42 −41 src/rtext.c
+137 −15 src/rtextures.c
+36 −21 src/utils.c
36 changes: 20 additions & 16 deletions src/raylib.nim
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,8 @@ proc setWindowMonitor*(monitor: int32) {.importc: "SetWindowMonitor".}
## Set monitor for the current window
proc setWindowMinSize*(width: int32, height: int32) {.importc: "SetWindowMinSize".}
## Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
proc setWindowMaxSize*(width: int32, height: int32) {.importc: "SetWindowMaxSize".}
## Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)
proc setWindowSize*(width: int32, height: int32) {.importc: "SetWindowSize".}
## Set window dimensions
proc setWindowOpacity*(opacity: float32) {.importc: "SetWindowOpacity".}
Expand Down Expand Up @@ -1160,6 +1162,8 @@ proc getCollisionRec*(rec1: Rectangle, rec2: Rectangle): Rectangle {.importc: "G
## Get collision rectangle for two rectangles collision
proc loadImagePriv(fileName: cstring): Image {.importc: "LoadImage".}
proc loadImageRawPriv(fileName: cstring, width: int32, height: int32, format: PixelFormat, headerSize: int32): Image {.importc: "LoadImageRaw".}
proc loadImageSvg*(fileNameOrString: cstring, width: int32, height: int32): Image {.importc: "LoadImageSvg".}
## Load image from SVG file data or string with specified size
proc loadImageAnim*(fileName: cstring, frames: out int32): Image {.importc: "LoadImageAnim".}
## Load image sequence from file (frames appended to image.data)
proc loadImageFromMemoryPriv(fileType: cstring, fileData: ptr UncheckedArray[uint8], dataSize: int32): Image {.importc: "LoadImageFromMemory".}
Expand Down Expand Up @@ -1341,13 +1345,13 @@ proc getPixelDataSize*(width: int32, height: int32, format: PixelFormat): int32
proc getFontDefault*(): Font {.importc: "GetFontDefault".}
## Get the default Font
proc loadFontPriv(fileName: cstring): Font {.importc: "LoadFont".}
proc loadFontPriv(fileName: cstring, fontSize: int32, fontChars: ptr UncheckedArray[int32], glyphCount: int32): Font {.importc: "LoadFontEx".}
proc loadFontPriv(fileName: cstring, fontSize: int32, codepoints: ptr UncheckedArray[int32], codepointCount: int32): Font {.importc: "LoadFontEx".}
proc loadFontFromImagePriv(image: Image, key: Color, firstChar: int32): Font {.importc: "LoadFontFromImage".}
proc loadFontFromMemoryPriv(fileType: cstring, fileData: ptr UncheckedArray[uint8], dataSize: int32, fontSize: int32, fontChars: ptr UncheckedArray[int32], glyphCount: int32): Font {.importc: "LoadFontFromMemory".}
proc loadFontFromMemoryPriv(fileType: cstring, fileData: ptr UncheckedArray[uint8], dataSize: int32, fontSize: int32, codepoints: ptr UncheckedArray[int32], codepointCount: int32): Font {.importc: "LoadFontFromMemory".}
proc isFontReady*(font: Font): bool {.importc: "IsFontReady".}
## Check if a font is ready
proc loadFontDataPriv(fileData: ptr UncheckedArray[uint8], dataSize: int32, fontSize: int32, fontChars: ptr UncheckedArray[int32], glyphCount: int32, `type`: FontType): ptr UncheckedArray[GlyphInfo] {.importc: "LoadFontData".}
proc genImageFontAtlasPriv(chars: ptr UncheckedArray[GlyphInfo], recs: ptr ptr UncheckedArray[Rectangle], glyphCount: int32, fontSize: int32, padding: int32, packMethod: int32): Image {.importc: "GenImageFontAtlas".}
proc loadFontDataPriv(fileData: ptr UncheckedArray[uint8], dataSize: int32, fontSize: int32, codepoints: ptr UncheckedArray[int32], codepointCount: int32, `type`: FontType): ptr UncheckedArray[GlyphInfo] {.importc: "LoadFontData".}
proc genImageFontAtlasPriv(glyphs: ptr UncheckedArray[GlyphInfo], glyphRecs: ptr ptr UncheckedArray[Rectangle], glyphCount: int32, fontSize: int32, padding: int32, packMethod: int32): Image {.importc: "GenImageFontAtlas".}
proc unloadFont(font: Font) {.importc: "UnloadFont".}
proc exportFontAsCode*(font: Font, fileName: cstring): bool {.importc: "ExportFontAsCode".}
## Export font as code file, returns true on success
Expand All @@ -1361,7 +1365,7 @@ proc drawText*(font: Font, text: cstring, position: Vector2, origin: Vector2, ro
## Draw text using Font and pro parameters (rotation)
proc drawTextCodepoint*(font: Font, codepoint: Rune, position: Vector2, fontSize: float32, tint: Color) {.importc: "DrawTextCodepoint".}
## Draw one character (codepoint)
proc drawTextCodepointsPriv(font: Font, codepoints: ptr UncheckedArray[int32], count: int32, position: Vector2, fontSize: float32, spacing: float32, tint: Color) {.importc: "DrawTextCodepoints".}
proc drawTextCodepointsPriv(font: Font, codepoints: ptr UncheckedArray[int32], codepointCount: int32, position: Vector2, fontSize: float32, spacing: float32, tint: Color) {.importc: "DrawTextCodepoints".}
proc setTextLineSpacing*(spacing: int32) {.importc: "SetTextLineSpacing".}
## Set vertical line spacing when drawing with line-breaks
proc measureText*(text: cstring, fontSize: int32): int32 {.importc: "MeasureText".}
Expand Down Expand Up @@ -1479,7 +1483,7 @@ proc loadMaterialDefault*(): Material {.importc: "LoadMaterialDefault".}
proc isMaterialReady*(material: Material): bool {.importc: "IsMaterialReady".}
## Check if a material is ready
proc unloadMaterial(material: Material) {.importc: "UnloadMaterial".}
proc loadModelAnimationsPriv(fileName: cstring, animCount: ptr uint32): ptr UncheckedArray[ModelAnimation] {.importc: "LoadModelAnimations".}
proc loadModelAnimationsPriv(fileName: cstring, animCount: ptr int32): ptr UncheckedArray[ModelAnimation] {.importc: "LoadModelAnimations".}
proc updateModelAnimation*(model: Model, anim: ModelAnimation, frame: int32) {.importc: "UpdateModelAnimation".}
## Update model animation pose
proc unloadModelAnimation(anim: ModelAnimation) {.importc: "UnloadModelAnimation".}
Expand Down Expand Up @@ -1916,7 +1920,7 @@ proc setShaderValueV*[T: ShaderV](shader: Shader, locIndex: ShaderLocation, valu

proc loadModelAnimations*(fileName: string): RArray[ModelAnimation] =
## Load model animations from file
var len = 0'u32
var len = 0'i32
let data = loadModelAnimationsPriv(fileName.cstring, addr len)
if len <= 0: raiseRaylibError("Failed to load ModelAnimations from " & fileName)
result = RArray[ModelAnimation](len: len.int, data: data)
Expand Down Expand Up @@ -2063,13 +2067,13 @@ proc setPixelColor*[T: Pixel](pixel: var T, color: Color) =
assert getPixelDataSize(1, 1, kind(T)) == sizeof(T), "Pixel size does not match expected format"
setPixelColorPriv(addr pixel, color, kind(T))

proc loadFontData*(fileData: openArray[uint8]; fontSize: int32; fontChars: openArray[int32];
proc loadFontData*(fileData: openArray[uint8]; fontSize: int32; codepoints: openArray[int32];
`type`: FontType): RArray[GlyphInfo] =
## Load font data for further use
let data = loadFontDataPriv(cast[ptr UncheckedArray[uint8]](fileData), fileData.len.int32,
fontSize, if fontChars.len == 0: nil else: cast[ptr UncheckedArray[int32]](fontChars),
fontChars.len.int32, `type`)
result = RArray[GlyphInfo](len: if fontChars.len == 0: 95 else: fontChars.len, data: data)
fontSize, if codepoints.len == 0: nil else: cast[ptr UncheckedArray[int32]](codepoints),
codepoints.len.int32, `type`)
result = RArray[GlyphInfo](len: if codepoints.len == 0: 95 else: codepoints.len, data: data)

proc loadFontData*(fileData: openArray[uint8]; fontSize, glyphCount: int32;
`type`: FontType): RArray[GlyphInfo] =
Expand All @@ -2082,10 +2086,10 @@ proc loadFont*(fileName: string): Font =
result = loadFontPriv(fileName.cstring)
if not isFontReady(result): raiseRaylibError("Failed to load Font from " & fileName)

proc loadFont*(fileName: string; fontSize: int32; fontChars: openArray[int32]): Font =
## Load font from file with extended parameters, use an empty array for fontChars to load the default character set
proc loadFont*(fileName: string; fontSize: int32; codepoints: openArray[int32]): Font =
## Load font from file with extended parameters, use an empty array for codepoints to load the default character set
result = loadFontPriv(fileName.cstring, fontSize,
if fontChars.len == 0: nil else: cast[ptr UncheckedArray[int32]](fontChars), fontChars.len.int32)
if codepoints.len == 0: nil else: cast[ptr UncheckedArray[int32]](codepoints), codepoints.len.int32)
if not isFontReady(result): raiseRaylibError("Failed to load Font from " & fileName)

proc loadFont*(fileName: string; fontSize, glyphCount: int32): Font =
Expand All @@ -2098,11 +2102,11 @@ proc loadFontFromImage*(image: Image, key: Color, firstChar: int32): Font =
if not isFontReady(result): raiseRaylibError("Failed to load Font from Image")

proc loadFontFromMemory*(fileType: string; fileData: openArray[uint8]; fontSize: int32;
fontChars: openArray[int32]): Font =
codepoints: openArray[int32]): Font =
## Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
result = loadFontFromMemoryPriv(fileType.cstring,
cast[ptr UncheckedArray[uint8]](fileData), fileData.len.int32, fontSize,
if fontChars.len == 0: nil else: cast[ptr UncheckedArray[int32]](fontChars), fontChars.len.int32)
if codepoints.len == 0: nil else: cast[ptr UncheckedArray[int32]](codepoints), codepoints.len.int32)
if not isFontReady(result): raiseRaylibError("Failed to load Font from buffer")

proc loadFontFromMemory*(fileType: string; fileData: openArray[uint8]; fontSize: int32;
Expand Down
3 changes: 0 additions & 3 deletions src/raymath.nim
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,13 @@ func project*(v1, v2: Vector3): Vector3 {.inline.} =
## Calculate the projection of the vector v1 on to v2
let v1dv2 = v1.x*v2.x + v1.y*v2.y + v1.z*v2.z
let v2dv2 = v2.x*v2.x + v2.y*v2.y + v2.z*v2.z

let mag = v1dv2/v2dv2

result = Vector3(x: v2.x*mag, y: v2.y*mag, z: v2.z*mag)

func reject*(v1, v2: Vector3): Vector3 {.inline.} =
## Calculate the rejection of the vector v1 on to v2
let v1dv2 = v1.x*v2.x + v1.y*v2.y + v1.z*v2.z
let v2dv2 = v2.x*v2.x + v2.y*v2.y + v2.z*v2.z

let mag = v1dv2/v2dv2
result = Vector3(x: v1.x - (v2.x*mag), y: v1.y - (v2.y*mag), z: v1.z - (v2.z*mag))

Expand Down
2 changes: 1 addition & 1 deletion tools/raylib_gen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ proc genBindings(t: TopLevel, fname: string; header, middle: string) =
let many = (fnc.name, param.name) != ("LoadImageAnim", "frames") and isPlural(param.name)
const
replacements = [
("GenImageFontAtlas", "recs", "ptr ptr UncheckedArray[$1]"),
("GenImageFontAtlas", "glyphRecs", "ptr ptr UncheckedArray[$1]"),
("CheckCollisionLines", "collisionPoint", "out $1"),
("LoadImageAnim", "frames", "out $1"),
("SetTraceLogCallback", "callback", "TraceLogCallbackImpl"),
Expand Down
Loading

0 comments on commit b45e93d

Please sign in to comment.