Skip to content

Commit

Permalink
mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Feb 29, 2024
1 parent 3f5dcbb commit 76ae379
Showing 1 changed file with 34 additions and 35 deletions.
69 changes: 34 additions & 35 deletions src/raylib.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1931,41 +1931,40 @@ proc getGamepadName*(gamepad: int32): string {.inline.} =
## Get gamepad internal name id
result = $getGamepadNamePriv(gamepad)

when false:
proc exportDataAsCode*(data: openArray[byte], fileName: string): bool =
## Export data to code (.nim), returns true on success
result = false
const TextBytesPerLine = 20
# NOTE: Text data buffer size is estimated considering raw data size in bytes
# and requiring 6 char bytes for every byte: "0x00, "
var txtData = newStringOfCap(data.len*6 + 300)
txtData.add("""
#
# DataAsCode exporter v1.0 - Raw data exported as an array of bytes
#
# more info and bugs-report: github.com/raysan5/raylib
# feedback and support: ray[at]raylib.com
#
# Copyright (c) 2022-2023 Ramon Santamaria (@raysan5)
#
""")
# Get the file name from the path
var (_, name, _) = splitFile(fileName)
txtData.addf("const $1Data: array[$2, byte] = [ ", name, data.len)
for i in 0..data.high - 1:
txtData.addf(
if i mod TextBytesPerLine == 0: "0x$1,\n" else: "0x$1, ", data[i].toHex)
txtData.addf("0x$1 ]\n", data[^1].toHex)
try:
writeFile(fileName, txtData)
result = true
except IOError:
discard

if result:
traceLog(Info, "FILEIO: [%s] Data as code exported successfully", fileName)
else:
traceLog(Warning, "FILEIO: [%s] Failed to export data as code", fileName)
proc exportDataAsCode*(data: openArray[byte], fileName: string): bool =
## Export data to code (.nim), returns true on success
result = false
const TextBytesPerLine = 20
# NOTE: Text data buffer size is estimated considering raw data size in bytes
# and requiring 6 char bytes for every byte: "0x00, "
var txtData = newStringOfCap(data.len*6 + 300)
txtData.add("""
#
# DataAsCode exporter v1.0 - Raw data exported as an array of bytes
#
# more info and bugs-report: github.com/raysan5/raylib
# feedback and support: ray[at]raylib.com
#
# Copyright (c) 2022-2023 Ramon Santamaria (@raysan5)
#
""")
# Get the file name from the path
var (_, name, _) = splitFile(fileName)
txtData.addf("const $1Data: array[$2, byte] = [ ", name, data.len)
for i in 0..data.high - 1:
txtData.addf(
if i mod TextBytesPerLine == 0: "0x$1,\n" else: "0x$1, ", data[i].toHex)
txtData.addf("0x$1 ]\n", data[^1].toHex)
try:
writeFile(fileName, txtData)
result = true
except IOError:
discard

if result:
traceLog(Info, "FILEIO: [%s] Data as code exported successfully", fileName)
else:
traceLog(Warning, "FILEIO: [%s] Failed to export data as code", fileName)

proc loadShader*(vsFileName, fsFileName: string): Shader =
## Load shader from files and bind default locations
Expand Down

0 comments on commit 76ae379

Please sign in to comment.