mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-19 12:22:23 -07: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:
|
||||
// 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
|
||||
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'
|
||||
// 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: walk does not follow symbolic links
|
||||
// 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)
|
||||
defer os.file_info_delete(info, context.temp_allocator)
|
||||
|
||||
skip_dir: bool
|
||||
if err != 0 {
|
||||
err, skip_dir = walk_proc(info, err)
|
||||
err, skip_dir = walk_proc(info, err, user_data)
|
||||
} else {
|
||||
err, skip_dir = _walk(info, walk_proc)
|
||||
err, skip_dir = _walk(info, walk_proc, user_data)
|
||||
}
|
||||
return 0 if skip_dir else err
|
||||
}
|
||||
|
||||
|
||||
@(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.fullpath == "" && info.name == "" {
|
||||
// ignore empty things
|
||||
return
|
||||
}
|
||||
return walk_proc(info, 0)
|
||||
return walk_proc(info, 0, user_data)
|
||||
}
|
||||
|
||||
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)
|
||||
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 {
|
||||
err = err1
|
||||
return
|
||||
}
|
||||
|
||||
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 !fi.is_dir || !skip_dir {
|
||||
return
|
||||
|
||||
@@ -85,3 +85,15 @@ foreign Opengl32 {
|
||||
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 ---
|
||||
}
|
||||
|
||||
// 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
+2
-8
@@ -7,17 +7,11 @@ Includes procedures to load OpenGL function pointers. Currently only supports th
|
||||
```go
|
||||
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
|
||||
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`)
|
||||
|
||||
Some useful helper procedures can be found in `helpers.odin`, for tasks such as:
|
||||
@@ -56,4 +50,4 @@ glGetError() returned NO_ERROR
|
||||
glGetError() returned NO_ERROR
|
||||
call: glClearColor(0.800, 0.800, 0.800, 1.000)
|
||||
in: C:/<snip>/main.odin(272:6)
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user