mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Merge branch 'odin-lang:master' into master
This commit is contained in:
@@ -14,7 +14,7 @@ import "core:slice"
|
|||||||
// The sole exception is if 'skip_dir' is returned as true:
|
// The sole exception is if 'skip_dir' is returned as true:
|
||||||
// when 'skip_dir' is invoked on a directory. 'walk' skips directory contents
|
// when 'skip_dir' is invoked on a directory. 'walk' skips directory contents
|
||||||
// when 'skip_dir' is invoked on a non-directory. 'walk' skips the remaining files in the containing directory
|
// when 'skip_dir' is invoked on a non-directory. 'walk' skips the remaining files in the containing directory
|
||||||
Walk_Proc :: #type proc(info: os.File_Info, in_err: os.Errno) -> (err: os.Errno, skip_dir: bool)
|
Walk_Proc :: #type proc(info: os.File_Info, in_err: os.Errno, user_data: rawptr) -> (err: os.Errno, skip_dir: bool)
|
||||||
|
|
||||||
// walk walks the file tree rooted at 'root', calling 'walk_proc' for each file or directory in the tree, including 'root'
|
// walk walks the file tree rooted at 'root', calling 'walk_proc' for each file or directory in the tree, including 'root'
|
||||||
// All errors that happen visiting files and directories are filtered by walk_proc
|
// All errors that happen visiting files and directories are filtered by walk_proc
|
||||||
@@ -22,28 +22,28 @@ Walk_Proc :: #type proc(info: os.File_Info, in_err: os.Errno) -> (err: os.Errno,
|
|||||||
// NOTE: Walking large directories can be inefficient due to the lexical sort
|
// NOTE: Walking large directories can be inefficient due to the lexical sort
|
||||||
// NOTE: walk does not follow symbolic links
|
// NOTE: walk does not follow symbolic links
|
||||||
// NOTE: os.File_Info uses the 'context.temp_allocator' to allocate, and will delete when it is done
|
// NOTE: os.File_Info uses the 'context.temp_allocator' to allocate, and will delete when it is done
|
||||||
walk :: proc(root: string, walk_proc: Walk_Proc) -> os.Errno {
|
walk :: proc(root: string, walk_proc: Walk_Proc, user_data: rawptr) -> os.Errno {
|
||||||
info, err := os.lstat(root, context.temp_allocator)
|
info, err := os.lstat(root, context.temp_allocator)
|
||||||
defer os.file_info_delete(info, context.temp_allocator)
|
defer os.file_info_delete(info, context.temp_allocator)
|
||||||
|
|
||||||
skip_dir: bool
|
skip_dir: bool
|
||||||
if err != 0 {
|
if err != 0 {
|
||||||
err, skip_dir = walk_proc(info, err)
|
err, skip_dir = walk_proc(info, err, user_data)
|
||||||
} else {
|
} else {
|
||||||
err, skip_dir = _walk(info, walk_proc)
|
err, skip_dir = _walk(info, walk_proc, user_data)
|
||||||
}
|
}
|
||||||
return 0 if skip_dir else err
|
return 0 if skip_dir else err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@(private)
|
@(private)
|
||||||
_walk :: proc(info: os.File_Info, walk_proc: Walk_Proc) -> (err: os.Errno, skip_dir: bool) {
|
_walk :: proc(info: os.File_Info, walk_proc: Walk_Proc, user_data: rawptr) -> (err: os.Errno, skip_dir: bool) {
|
||||||
if !info.is_dir {
|
if !info.is_dir {
|
||||||
if info.fullpath == "" && info.name == "" {
|
if info.fullpath == "" && info.name == "" {
|
||||||
// ignore empty things
|
// ignore empty things
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return walk_proc(info, 0)
|
return walk_proc(info, 0, user_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fis: []os.File_Info
|
fis: []os.File_Info
|
||||||
@@ -51,14 +51,14 @@ _walk :: proc(info: os.File_Info, walk_proc: Walk_Proc) -> (err: os.Errno, skip_
|
|||||||
fis, err = read_dir(info.fullpath, context.temp_allocator)
|
fis, err = read_dir(info.fullpath, context.temp_allocator)
|
||||||
defer os.file_info_slice_delete(fis, context.temp_allocator)
|
defer os.file_info_slice_delete(fis, context.temp_allocator)
|
||||||
|
|
||||||
err1, skip_dir = walk_proc(info, err)
|
err1, skip_dir = walk_proc(info, err, user_data)
|
||||||
if err != 0 || err1 != 0 || skip_dir {
|
if err != 0 || err1 != 0 || skip_dir {
|
||||||
err = err1
|
err = err1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for fi in fis {
|
for fi in fis {
|
||||||
err, skip_dir = _walk(fi, walk_proc)
|
err, skip_dir = _walk(fi, walk_proc, user_data)
|
||||||
if err != 0 || skip_dir {
|
if err != 0 || skip_dir {
|
||||||
if !fi.is_dir || !skip_dir {
|
if !fi.is_dir || !skip_dir {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -85,3 +85,15 @@ foreign Opengl32 {
|
|||||||
wglUseFontBitmaps :: proc(hdc: HDC, first, count, list_base: DWORD) -> BOOL ---
|
wglUseFontBitmaps :: proc(hdc: HDC, first, count, list_base: DWORD) -> BOOL ---
|
||||||
wglUseFontOutlines :: proc(hdc: HDC, first, count, list_base: DWORD, deviation, extrusion: f32, format: c.int, gmf: LPGLYPHMETRICSFLOAT) -> BOOL ---
|
wglUseFontOutlines :: proc(hdc: HDC, first, count, list_base: DWORD, deviation, extrusion: f32, format: c.int, gmf: LPGLYPHMETRICSFLOAT) -> BOOL ---
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used by vendor:OpenGL
|
||||||
|
// https://www.khronos.org/opengl/wiki/Load_OpenGL_Functions#Windows
|
||||||
|
gl_set_proc_address :: proc(p: rawptr, name: cstring) {
|
||||||
|
func := wglGetProcAddress(name)
|
||||||
|
switch uintptr(func) {
|
||||||
|
case 0, 1, 2, 3, ~uintptr(0):
|
||||||
|
module := LoadLibraryW(L("opengl32.dll"))
|
||||||
|
func = GetProcAddress(module, name)
|
||||||
|
}
|
||||||
|
(^rawptr)(p)^ = func
|
||||||
|
}
|
||||||
|
|||||||
Vendored
+1
-7
@@ -7,17 +7,11 @@ Includes procedures to load OpenGL function pointers. Currently only supports th
|
|||||||
```go
|
```go
|
||||||
gl.load_up_to(4, 5, proc(p: rawptr, name: cstring) do (cast(^rawptr)p)^ = glfw.GetProcAddress(name); );
|
gl.load_up_to(4, 5, proc(p: rawptr, name: cstring) do (cast(^rawptr)p)^ = glfw.GetProcAddress(name); );
|
||||||
```
|
```
|
||||||
[odin-glfw](https://github.com/vassvik/odin-glfw) also provides a useful helper you can pass straight to `gl.load_up_to`:
|
`vendor:glfw` also provides a useful helper you can pass straight to `gl.load_up_to`:
|
||||||
```go
|
```go
|
||||||
gl.load_up_to(4, 5, glfw.gl_set_proc_address);
|
gl.load_up_to(4, 5, glfw.gl_set_proc_address);
|
||||||
```
|
```
|
||||||
|
|
||||||
#### NOTE: It is recommended to put this into the shared collection:
|
|
||||||
```
|
|
||||||
cd /path/to/Odin/shared
|
|
||||||
git clone https://github.com/vassvik/odin-gl.git
|
|
||||||
```
|
|
||||||
|
|
||||||
## Extra utility procedures (Outdated. See the end of `gl.odin`)
|
## Extra utility procedures (Outdated. See the end of `gl.odin`)
|
||||||
|
|
||||||
Some useful helper procedures can be found in `helpers.odin`, for tasks such as:
|
Some useful helper procedures can be found in `helpers.odin`, for tasks such as:
|
||||||
|
|||||||
Reference in New Issue
Block a user