annotate src/semicongine/vulkan/utils.nim @ 103:1e2027dfc642

add: finally working initial approach for shader definitions
author Sam <sam@basx.dev>
date Mon, 20 Mar 2023 10:25:50 +0700
parents e872cf354110
children 2d0351a68a4e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
89
6e8037c1f655 add: better vulkan wrappers
Sam <sam@basx.dev>
parents:
diff changeset
1 import std/strutils
103
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
2 import std/os
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
3 import std/strformat
89
6e8037c1f655 add: better vulkan wrappers
Sam <sam@basx.dev>
parents:
diff changeset
4
6e8037c1f655 add: better vulkan wrappers
Sam <sam@basx.dev>
parents:
diff changeset
5 func cleanString*(str: openArray[char]): string =
6e8037c1f655 add: better vulkan wrappers
Sam <sam@basx.dev>
parents:
diff changeset
6 for i in 0 ..< len(str):
6e8037c1f655 add: better vulkan wrappers
Sam <sam@basx.dev>
parents:
diff changeset
7 if str[i] == char(0):
6e8037c1f655 add: better vulkan wrappers
Sam <sam@basx.dev>
parents:
diff changeset
8 result = join(str[0 ..< i])
6e8037c1f655 add: better vulkan wrappers
Sam <sam@basx.dev>
parents:
diff changeset
9 break
6e8037c1f655 add: better vulkan wrappers
Sam <sam@basx.dev>
parents:
diff changeset
10
92
e872cf354110 add: more stuff for the vulkan API wrappers
Sam <sam@basx.dev>
parents: 89
diff changeset
11 func toCPointer*[T](list: var seq[T]): ptr T =
e872cf354110 add: more stuff for the vulkan API wrappers
Sam <sam@basx.dev>
parents: 89
diff changeset
12 if list.len > 0: addr list[0] else: nil
103
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
13
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
14 proc staticExecChecked*(command: string, input = ""): string {.compileTime.} =
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
15 let (output, exitcode) = gorgeEx(
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
16 command = command,
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
17 input = input)
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
18 if exitcode != 0:
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
19 raise newException(Exception, &"Running '{command}' produced exit code: {exitcode}" & output)
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
20 return output
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
21
1e2027dfc642 add: finally working initial approach for shader definitions
Sam <sam@basx.dev>
parents: 92
diff changeset
22