Saving projects
This commit is contained in:
parent
4261f07762
commit
64735fe60e
3 changed files with 182 additions and 63 deletions
32
project.odin
Normal file
32
project.odin
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import "core:os"
|
||||
import "core:io"
|
||||
|
||||
PROJECT_DATA_HEADER :: "WOWOWOW THIS IS HEADER WOWOWOW"
|
||||
PROJECT_DATA_VERSION :: 1
|
||||
|
||||
ProjectData :: struct {
|
||||
version: u32,
|
||||
matrix_count: u32,
|
||||
matrices: []f32,
|
||||
}
|
||||
|
||||
WriteProjectError :: union {
|
||||
os.Error,
|
||||
}
|
||||
|
||||
WriteProjectErrorType :: enum {
|
||||
IncompatibleVersion,
|
||||
}
|
||||
|
||||
project_write :: proc(project: ^ProjectData, path: string) -> os.Error {
|
||||
f := os.open(path, {.Create, .Trunc, .Write}) or_return
|
||||
w := io.to_writer(os.to_stream(f))
|
||||
version: u32 = PROJECT_DATA_VERSION
|
||||
io.write_ptr(w, &version, size_of(version))
|
||||
io.write_ptr(w, &project.matrix_count, size_of(project.matrix_count))
|
||||
io.write_ptr(w, raw_data(project.matrices), int(project.matrix_count) * 9 * size_of(f32))
|
||||
os.close(f)
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue