mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-28 18:30:06 +00:00
down_cast
This commit is contained in:
+21
-9
@@ -9,20 +9,32 @@ main :: proc() {
|
||||
name: string
|
||||
}
|
||||
|
||||
Frog :: type struct {
|
||||
Amp :: type struct {
|
||||
using entity: Entity
|
||||
jump_height: f32
|
||||
}
|
||||
|
||||
f := Frog{}
|
||||
f.name = "ribbit"
|
||||
|
||||
print_name :: proc(using e: Entity) {
|
||||
print_string(name); nl()
|
||||
Frog :: type struct {
|
||||
using amp: Amp
|
||||
volume: f64
|
||||
}
|
||||
|
||||
print_name(f.entity)
|
||||
print_name(f)
|
||||
f := Frog{};
|
||||
f.name = "ribbit";
|
||||
f.jump_height = 1337;
|
||||
|
||||
e := ^f.entity;
|
||||
parent := e down_cast ^Frog;
|
||||
|
||||
print_name :: proc(using e: Entity, v: Vec3) {
|
||||
print_string(name); nl()
|
||||
print_int(v.x as int); nl()
|
||||
}
|
||||
|
||||
print_f32(f.jump_height); nl()
|
||||
print_f32(parent.jump_height); nl()
|
||||
|
||||
print_name(f.entity, Vec3{1, 2, 3})
|
||||
print_name(parent.entity, Vec3{3, 2, 1})
|
||||
|
||||
|
||||
}
|
||||
|
||||
+17
-17
@@ -27,23 +27,23 @@ GL_TEXTURE_MIN_FILTER :: 0x2801
|
||||
GL_TEXTURE_WRAP_S :: 0x2802
|
||||
GL_TEXTURE_WRAP_T :: 0x2803
|
||||
|
||||
glClear :: proc(mask: u32) #foreign
|
||||
glClearColor :: proc(r, g, b, a: f32) #foreign
|
||||
glBegin :: proc(mode: i32) #foreign
|
||||
glEnd :: proc() #foreign
|
||||
glColor3f :: proc(r, g, b: f32) #foreign
|
||||
glColor4f :: proc(r, g, b, a: f32) #foreign
|
||||
glVertex2f :: proc(x, y: f32) #foreign
|
||||
glVertex3f :: proc(x, y, z: f32) #foreign
|
||||
glTexCoord2f :: proc(u, v: f32) #foreign
|
||||
glLoadIdentity :: proc() #foreign
|
||||
glClear :: proc(mask: u32) #foreign
|
||||
glClearColor :: proc(r, g, b, a: f32) #foreign
|
||||
glBegin :: proc(mode: i32) #foreign
|
||||
glEnd :: proc() #foreign
|
||||
glColor3f :: proc(r, g, b: f32) #foreign
|
||||
glColor4f :: proc(r, g, b, a: f32) #foreign
|
||||
glVertex2f :: proc(x, y: f32) #foreign
|
||||
glVertex3f :: proc(x, y, z: f32) #foreign
|
||||
glTexCoord2f :: proc(u, v: f32) #foreign
|
||||
glLoadIdentity :: proc() #foreign
|
||||
glOrtho :: proc(left, right, bottom, top, near, far: f64) #foreign
|
||||
glBlendFunc :: proc(sfactor, dfactor: i32) #foreign
|
||||
glEnable :: proc(cap: i32) #foreign
|
||||
glDisable :: proc(cap: i32) #foreign
|
||||
glGenTextures :: proc(count: i32, result: ^u32) #foreign
|
||||
glTexParameteri :: proc(target, pname, param: i32) #foreign
|
||||
glTexParameterf :: proc(target: i32, pname: i32, param: f32) #foreign
|
||||
glBindTexture :: proc(target: i32, texture: u32) #foreign
|
||||
glBlendFunc :: proc(sfactor, dfactor: i32) #foreign
|
||||
glEnable :: proc(cap: i32) #foreign
|
||||
glDisable :: proc(cap: i32) #foreign
|
||||
glGenTextures :: proc(count: i32, result: ^u32) #foreign
|
||||
glTexParameteri :: proc(target, pname, param: i32) #foreign
|
||||
glTexParameterf :: proc(target: i32, pname: i32, param: f32) #foreign
|
||||
glBindTexture :: proc(target: i32, texture: u32) #foreign
|
||||
glTexImage2D :: proc(target, level, internal_format, width, height, border, format, _type: i32, pixels: rawptr) #foreign
|
||||
|
||||
|
||||
Reference in New Issue
Block a user