#file #line directives

This commit is contained in:
Ginger Bill
2016-09-15 00:53:00 +01:00
parent bd365e5176
commit b6cb4f4d14
7 changed files with 113 additions and 73 deletions

View File

@@ -1,5 +1,5 @@
#import "fmt.odin" as fmt
#import "game.odin" as game
// #import "game.odin" as game
test_proc :: proc() {
fmt.println("Hello?")
@@ -7,6 +7,8 @@ test_proc :: proc() {
main :: proc() {
x := 0
// fmt.println("% % % %", "Hellope", true, 6.28, {4}int{1, 2, 3, 4})
game.run()
fmt.println("%(%)", #file, #line)
// game.run()
}

View File

@@ -46,9 +46,8 @@ make_window :: proc(title: string, msg, height: int, window_proc: win32.WNDPROC)
w.width, w.height = msg, height
class_name := "Win32-Odin-Window\x00"
c_class_name := ^class_name[0]
// w.c_title = to_c_string(title)
w.c_title = "Title\x00" as []byte
c_class_name := class_name.data
w.c_title = to_c_string(title)
instance := GetModuleHandleA(null)
@@ -66,7 +65,7 @@ make_window :: proc(title: string, msg, height: int, window_proc: win32.WNDPROC)
}
w.hwnd = CreateWindowExA(0,
c_class_name, ^w.c_title[0],
c_class_name, w.c_title.data,
WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT,
w.width as i32, w.height as i32,
@@ -125,6 +124,8 @@ display_window :: proc(w: ^Window) {
run :: proc() {
using win32
using math
win32_proc :: proc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT #no_inline {
if msg == WM_DESTROY || msg == WM_CLOSE || msg == WM_QUIT {
ExitProcess(0)
@@ -144,7 +145,7 @@ run :: proc() {
prev_time := time_now()
running := true
pos := math.Vec2{100, 100}
pos := Vec2{100, 100}
for running {
curr_time := time_now()
@@ -166,38 +167,38 @@ run :: proc() {
{
SPEED :: 500
v: math.Vec2
v: Vec2
if is_key_down(Key_Code.RIGHT) { v[0] += 1 }
if is_key_down(Key_Code.LEFT) { v[0] -= 1 }
if is_key_down(Key_Code.UP) { v[1] += 1 }
if is_key_down(Key_Code.DOWN) { v[1] -= 1 }
v = math.vec2_norm0(v)
v = vec2_norm0(v)
pos += v * math.Vec2{SPEED * dt}
pos += v * Vec2{SPEED * dt}
}
gl.clear_color(0.5, 0.7, 1.0, 1.0)
gl.clear(gl.COLOR_BUFFER_BIT)
gl.ClearColor(0.5, 0.7, 1.0, 1.0)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.load_identity()
gl.ortho(0, window.width as f64,
gl.LoadIdentity()
gl.Ortho(0, window.width as f64,
0, window.height as f64, 0, 1)
draw_rect :: proc(x, y, w, h: f32) {
gl.begin(gl.TRIANGLES)
gl.Begin(gl.TRIANGLES)
gl.color3f(1, 0, 0); gl.vertex3f(x, y, 0)
gl.color3f(0, 1, 0); gl.vertex3f(x+w, y, 0)
gl.color3f(0, 0, 1); gl.vertex3f(x+w, y+h, 0)
gl.Color3f(1, 0, 0); gl.Vertex3f(x, y, 0)
gl.Color3f(0, 1, 0); gl.Vertex3f(x+w, y, 0)
gl.Color3f(0, 0, 1); gl.Vertex3f(x+w, y+h, 0)
gl.color3f(0, 0, 1); gl.vertex3f(x+w, y+h, 0)
gl.color3f(1, 1, 0); gl.vertex3f(x, y+h, 0)
gl.color3f(1, 0, 0); gl.vertex3f(x, y, 0)
gl.Color3f(0, 0, 1); gl.Vertex3f(x+w, y+h, 0)
gl.Color3f(1, 1, 0); gl.Vertex3f(x, y+h, 0)
gl.Color3f(1, 0, 0); gl.Vertex3f(x, y, 0)
gl.end()
gl.End()
}
draw_rect(pos[0], pos[1], 50, 50)

View File

@@ -27,23 +27,23 @@ TEXTURE_MIN_FILTER :: 0x2801
TEXTURE_WRAP_S :: 0x2802
TEXTURE_WRAP_T :: 0x2803
clear :: proc(mask: u32) #foreign "glClear"
clear_color :: proc(r, g, b, a: f32) #foreign "glClearColor"
begin :: proc(mode: i32) #foreign "glBegin"
end :: proc() #foreign "glEnd"
color3f :: proc(r, g, b: f32) #foreign "glColor3f"
color4f :: proc(r, g, b, a: f32) #foreign "glColor4f"
vertex2f :: proc(x, y: f32) #foreign "glVertex2f"
vertex3f :: proc(x, y, z: f32) #foreign "glVertex3f"
tex_coord2f :: proc(u, v: f32) #foreign "glTexCoord2f"
load_identity :: proc() #foreign "glLoadIdentity"
ortho :: proc(left, right, bottom, top, near, far: f64) #foreign "glOrtho"
blend_func :: proc(sfactor, dfactor: i32) #foreign "glBlendFunc"
enable :: proc(cap: i32) #foreign "glEnable"
disable :: proc(cap: i32) #foreign "glDisable"
gen_textures :: proc(count: i32, result: ^u32) #foreign "glGenTextures"
tex_parameteri :: proc(target, pname, param: i32) #foreign "glTexParameteri"
tex_parameterf :: proc(target: i32, pname: i32, param: f32) #foreign "glTexParameterf"
bind_texture :: proc(target: i32, texture: u32) #foreign "glBindTexture"
tex_image2d :: proc(target, level, internal_format, width, height, border, format, _type: i32, pixels: rawptr) #foreign "glTexImage2D"
Clear :: proc(mask: u32) #foreign "glClear"
ClearColor :: proc(r, g, b, a: f32) #foreign "glClearColor"
Begin :: proc(mode: i32) #foreign "glBegin"
End :: proc() #foreign "glEnd"
Color3f :: proc(r, g, b: f32) #foreign "glColor3f"
Color4f :: proc(r, g, b, a: f32) #foreign "glColor4f"
Vertex2f :: proc(x, y: f32) #foreign "glVertex2f"
Vertex3f :: proc(x, y, z: f32) #foreign "glVertex3f"
TexCoord2f :: proc(u, v: f32) #foreign "glTexCoord2f"
LoadIdentity :: proc() #foreign "glLoadIdentity"
Ortho :: proc(left, right, bottom, top, near, far: f64) #foreign "glOrtho"
BlendFunc :: proc(sfactor, dfactor: i32) #foreign "glBlendFunc"
Enable :: proc(cap: i32) #foreign "glEnable"
Disable :: proc(cap: i32) #foreign "glDisable"
GenTextures :: proc(count: i32, result: ^u32) #foreign "glGenTextures"
TexParameteri :: proc(target, pname, param: i32) #foreign "glTexParameteri"
TexParameterf :: proc(target: i32, pname: i32, param: f32) #foreign "glTexParameterf"
BindTexture :: proc(target: i32, texture: u32) #foreign "glBindTexture"
TexImage2D :: proc(target, level, internal_format, width, height, border, format, _type: i32, pixels: rawptr) #foreign "glTexImage2D"