bprinting loaded project into string fields
This commit is contained in:
parent
c3999f8ade
commit
6bbcd80268
2 changed files with 15 additions and 9 deletions
13
project.odin
13
project.odin
|
|
@ -48,7 +48,7 @@ ProjectReadErrorType :: enum {
|
|||
VersionNeedsUpgrade,
|
||||
}
|
||||
|
||||
project_read :: proc(project: ^ProjectData, path: string) -> ProjectReadError {
|
||||
project_read :: proc(project: ^ProjectData, path: string, allocator: mem.Allocator) -> ProjectReadError {
|
||||
f := os.open(path, {.Read}) or_return
|
||||
defer os.close(f)
|
||||
r := io.to_reader(os.to_stream(f))
|
||||
|
|
@ -57,14 +57,15 @@ project_read :: proc(project: ^ProjectData, path: string) -> ProjectReadError {
|
|||
if num, err := io.read_full(r, header_buffer[:]); err != nil {
|
||||
return ProjectReadErrorType.FailedReadingHeader
|
||||
}
|
||||
if mem.compare(transmute([]byte)header[:], header_buffer[:]) != 0 {
|
||||
if mem.compare(transmute([]byte)header, header_buffer[:]) != 0 {
|
||||
return ProjectReadErrorType.BadHeader
|
||||
}
|
||||
version: u32
|
||||
_ = io.read_ptr(r, &version, size_of(u32)) or_return
|
||||
if version != PROJECT_DATA_VERSION {
|
||||
_ = io.read_ptr(r, &project.version, size_of(project.matrix_count)) or_return
|
||||
if project.version != PROJECT_DATA_VERSION {
|
||||
return ProjectReadErrorType.VersionNeedsUpgrade
|
||||
}
|
||||
project.version = version
|
||||
_ = io.read_ptr(r, &project.matrix_count, size_of(project.matrix_count)) or_return
|
||||
project.matrices = make([]f32, size_of(f32) * int(project.matrix_count) * 9)
|
||||
_ = io.read_ptr(r, raw_data(project.matrices), size_of(f32) * len(project.matrices)) or_return
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue