mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
remove old float
type entirely
This commit is contained in:
parent
a911146182
commit
f26e65a943
@ -110,7 +110,7 @@ string res = tos2("");
|
||||
|
||||
fn is_js_prim(typ string) bool {
|
||||
return typ == 'int' || typ == 'string' ||
|
||||
typ == 'bool' || typ == 'float' || typ == 'f32' || typ == 'f64' ||
|
||||
typ == 'bool' || typ == 'f32' || typ == 'f64' ||
|
||||
typ == 'i8' || typ == 'i16' || typ == 'i32' || typ == 'i64'
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ mut:
|
||||
is_so bool
|
||||
is_live bool // for hot code reloading
|
||||
is_prof bool // benchmark every function
|
||||
translated bool // `v translated doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
|
||||
translated bool // `v translate doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
|
||||
obfuscate bool // `v -obf program.v`, renames functions to "f_XXX"
|
||||
lang_dir string // "~/code/v"
|
||||
is_verbose bool // print extra information with `v.log()`
|
||||
|
@ -1924,23 +1924,16 @@ fn (p mut Parser) factor() string {
|
||||
tok := p.tok
|
||||
switch tok {
|
||||
case INT:
|
||||
p.gen(p.lit)
|
||||
p.fgen(p.lit)
|
||||
typ = 'int'
|
||||
// typ = 'number'
|
||||
if p.lit.starts_with('u') {
|
||||
typ = 'long'
|
||||
}
|
||||
if p.lit.contains('.') || p.lit.contains('e') {
|
||||
// typ = 'f64'
|
||||
typ = 'float'
|
||||
typ = 'f32'
|
||||
// typ = 'f64' // TODO
|
||||
}
|
||||
case FLOAT:
|
||||
// TODO remove float
|
||||
typ = 'float'
|
||||
// typ = 'f64'
|
||||
// p.gen('(f64)$p.lit')
|
||||
p.gen('$p.lit')
|
||||
p.gen(p.lit)
|
||||
p.fgen(p.lit)
|
||||
case MINUS:
|
||||
p.gen('-')
|
||||
@ -2101,8 +2094,7 @@ fn (p mut Parser) typ_to_fmt(typ string) string {
|
||||
case 'byte': return '%d'
|
||||
case 'bool': return '%d'
|
||||
case 'u32': return '%d'
|
||||
case 'float': return '%f'
|
||||
case 'double', 'f64': return '%f'
|
||||
case 'double', 'f64', 'f32': return '%f'
|
||||
case 'i64': return '%lld'
|
||||
case 'byte*': return '%s'
|
||||
// case 'array_string': return '%s'
|
||||
@ -3133,30 +3125,34 @@ fn is_compile_time_const(s string) bool {
|
||||
|
||||
// fmt helpers
|
||||
fn (scanner mut Scanner) fgen(s string) {
|
||||
/*
|
||||
if scanner.fmt_line_empty {
|
||||
s = repeat_char(`\t`, scanner.fmt_indent) + s
|
||||
}
|
||||
scanner.fmt_out.write(s)
|
||||
scanner.fmt_line_empty = false
|
||||
*/
|
||||
}
|
||||
|
||||
fn (scanner mut Scanner) fgenln(s string) {
|
||||
/*
|
||||
if scanner.fmt_line_empty {
|
||||
s = repeat_char(`\t`, scanner.fmt_indent) + s
|
||||
}
|
||||
scanner.fmt_out.writeln(s)
|
||||
scanner.fmt_line_empty = true
|
||||
*/
|
||||
}
|
||||
|
||||
fn (p mut Parser) fgen(s string) {
|
||||
p.scanner.fgen(s)
|
||||
//p.scanner.fgen(s)
|
||||
}
|
||||
|
||||
fn (p mut Parser) fspace() {
|
||||
p.fgen(' ')
|
||||
//p.fgen(' ')
|
||||
}
|
||||
|
||||
fn (p mut Parser) fgenln(s string) {
|
||||
p.scanner.fgenln(s)
|
||||
//p.scanner.fgenln(s)
|
||||
}
|
||||
|
||||
|
@ -97,8 +97,8 @@ fn (f Fn) str() string {
|
||||
// fn (types array_Type) print_to_file(f string) {
|
||||
// }
|
||||
const (
|
||||
NUMBER_TYPES = ['number', 'int', 'i8', 'u8', 'i16', 'u16', 'i32', 'u32', 'byte', 'i64', 'u64', 'long', 'double', 'float', 'f32', 'f64']
|
||||
FLOAT_TYPES = ['double', 'float', 'f32', 'f64']
|
||||
NUMBER_TYPES = ['number', 'int', 'i8', 'u8', 'i16', 'u16', 'i32', 'u32', 'byte', 'i64', 'u64', 'long', 'double', 'f32', 'f64']
|
||||
FLOAT_TYPES = ['double', 'f32', 'f64']
|
||||
)
|
||||
|
||||
fn is_number_type(typ string) bool {
|
||||
@ -130,7 +130,6 @@ fn new_table(obfuscate bool) *Table {
|
||||
t.register_type('byteptr')
|
||||
t.register_type('intptr')
|
||||
t.register_type('double')// TODO remove
|
||||
t.register_type('float')// TODO remove
|
||||
t.register_type('f32')
|
||||
t.register_type('f64')
|
||||
t.register_type('rune')
|
||||
@ -421,16 +420,16 @@ fn (p mut Parser) _check_types(got, expected string, throw bool) bool {
|
||||
return true
|
||||
}
|
||||
// Allow ints to be used as floats
|
||||
if got.eq('int') && expected.eq('float') {
|
||||
if got == 'int' && expected == 'f32' {
|
||||
return true
|
||||
}
|
||||
if got.eq('int') && expected.eq('f64') {
|
||||
if got == 'int' && expected == 'f64' {
|
||||
return true
|
||||
}
|
||||
if got == 'f64' && expected == 'float' {
|
||||
if got == 'f64' && expected == 'f32' {
|
||||
return true
|
||||
}
|
||||
if got == 'float' && expected == 'f64' {
|
||||
if got == 'f32' && expected == 'f64' {
|
||||
return true
|
||||
}
|
||||
// Allow ints to be used as longs
|
||||
|
@ -10,7 +10,6 @@ enum Token {
|
||||
INT
|
||||
STRING
|
||||
CHAR
|
||||
FLOAT
|
||||
PLUS
|
||||
MINUS
|
||||
MUL
|
||||
@ -129,7 +128,6 @@ fn build_token_str() []string {
|
||||
s[INT] = 'INT'
|
||||
s[STRING] = 'STR'
|
||||
s[CHAR] = 'CHAR'
|
||||
s[FLOAT] = 'FLOAT'
|
||||
s[PLUS] = '+'
|
||||
s[MINUS] = '-'
|
||||
s[MUL] = '*'
|
||||
|
32
gg/gg.v
32
gg/gg.v
@ -148,7 +148,7 @@ pub fn new_context(cfg Cfg) *GG {
|
||||
return ctx
|
||||
}
|
||||
|
||||
pub fn (ctx &GG) draw_triangle(x1, y1, x2, y2, x3, y3 float, c gx.Color) {
|
||||
pub fn (ctx &GG) draw_triangle(x1, y1, x2, y2, x3, y3 f32, c gx.Color) {
|
||||
// println('draw_triangle $x1,$y1 $x2,$y2 $x3,$y3')
|
||||
ctx.shader.use()
|
||||
ctx.shader.set_color('color', c)
|
||||
@ -173,7 +173,7 @@ pub fn (ctx &GG) draw_triangle(x1, y1, x2, y2, x3, y3 float, c gx.Color) {
|
||||
gl.draw_arrays(GL_TRIANGLES, 0, 3)
|
||||
}
|
||||
|
||||
pub fn (ctx &GG) draw_triangle_tex(x1, y1, x2, y2, x3, y3 float, c gx.Color) {
|
||||
pub fn (ctx &GG) draw_triangle_tex(x1, y1, x2, y2, x3, y3 f32, c gx.Color) {
|
||||
ctx.shader.use()
|
||||
ctx.shader.set_color('color', c)
|
||||
ctx.shader.set_int('has_texture', 1)
|
||||
@ -198,7 +198,7 @@ pub fn (ctx &GG) draw_triangle_tex(x1, y1, x2, y2, x3, y3 float, c gx.Color) {
|
||||
gl.draw_elements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0)
|
||||
}
|
||||
|
||||
fn (ctx &GG) draw_rect(x, y, w, h float, c gx.Color) {
|
||||
fn (ctx &GG) draw_rect(x, y, w, h f32, c gx.Color) {
|
||||
// println('gg.draw_rect($x,$y,$w,$h)')
|
||||
// wrong order
|
||||
// // ctx.draw_triangle(x, y, x + w, y, x + w, y + h, c)
|
||||
@ -231,7 +231,7 @@ fn (ctx mut GG) init_rect_vao() {
|
||||
gl.set_ebo(ebo, indices, GL_STATIC_DRAW)
|
||||
}
|
||||
*/
|
||||
fn (ctx &GG) draw_rect2(x, y, w, h float, c gx.Color) {
|
||||
fn (ctx &GG) draw_rect2(x, y, w, h f32, c gx.Color) {
|
||||
C.glDeleteBuffers(1, &ctx.VAO)
|
||||
C.glDeleteBuffers(1, &ctx.VBO)
|
||||
ctx.shader.use()
|
||||
@ -396,10 +396,10 @@ fn new_context_text(cfg Cfg, scale int) *GG {
|
||||
VBO := gl.gen_buffer()
|
||||
gl.bind_vao(VAO)
|
||||
gl.bind_buffer(GL_ARRAY_BUFFER, VBO)
|
||||
// # glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 4, NULL, GL_DYNAMIC_DRAW);
|
||||
// # glBufferData(GL_ARRAY_BUFFER, sizeof(GLf32) * 6 * 4, NULL, GL_DYNAMIC_DRAW);
|
||||
gl.enable_vertex_attrib_array(0)
|
||||
gl.vertex_attrib_pointer(0, 4, GL_FLOAT, false, 4, 0)
|
||||
// # glVertexAttribPointer(0, 4, GL_FLOAT,false, 4 * sizeof(GLfloat), 0);
|
||||
// # glVertexAttribPointer(0, 4, GL_FLOAT,false, 4 * sizeof(GLf32), 0);
|
||||
// gl.bind_buffer(GL_ARRAY_BUFFER, uint(0))
|
||||
// # glBindVertexArray(0);
|
||||
mut ctx := &GG {
|
||||
@ -432,7 +432,7 @@ fn (ctx mut GG) init_utf8_runes() {
|
||||
}
|
||||
}
|
||||
|
||||
// fn (ctx &GG) render_text(text string, x, y, scale float, color gx.Color) {
|
||||
// fn (ctx &GG) render_text(text string, x, y, scale f32, color gx.Color) {
|
||||
pub fn (ctx &GG) draw_text(_x, _y int, text string, cfg gx.TextCfg) {
|
||||
// dont draw non ascii for now
|
||||
/*
|
||||
@ -477,11 +477,11 @@ fn (ctx &GG) _draw_text(_x, _y int, utext ustring, cfg gx.TextCfg) {
|
||||
width := utext.len * 7
|
||||
_x -= width + 10
|
||||
}
|
||||
x := float(_x) * ctx.scale// float(2)
|
||||
x := f32(_x) * ctx.scale// f32(2)
|
||||
// println('y=$_y height=$ctx.height')
|
||||
// _y = _y * int(ctx.scale) //+ 26
|
||||
_y = _y * int(ctx.scale) + ((cfg.size * ctx.scale) / 2) + 5 * ctx.scale
|
||||
y := float(ctx.height - _y)
|
||||
y := f32(ctx.height - _y)
|
||||
color := cfg.color
|
||||
// Activate corresponding render state
|
||||
ctx.shader.use()
|
||||
@ -521,10 +521,10 @@ fn (ctx &GG) _draw_text(_x, _y int, utext ustring, cfg gx.TextCfg) {
|
||||
// s := 'A'
|
||||
// c := int(s[0])
|
||||
// ch := ctx.chars[c]
|
||||
xpos := x + float(ch.bearing.x) * 1
|
||||
ypos := y - float(ch.size.y - ch.bearing.y) * 1
|
||||
w := float(ch.size.x) * 1
|
||||
h := float(ch.size.y) * 1
|
||||
xpos := x + f32(ch.bearing.x) * 1
|
||||
ypos := y - f32(ch.size.y - ch.bearing.y) * 1
|
||||
w := f32(ch.size.x) * 1
|
||||
h := f32(ch.size.y) * 1
|
||||
// Update VBO for each character
|
||||
# GLfloat vertices[6][4] = {
|
||||
# { xpos, ypos + h, 0.0, 0.0 },
|
||||
@ -656,7 +656,7 @@ pub fn (ctx &GG) draw_line_c(x, y, x2, y2 int, color gx.Color) {
|
||||
C.glDeleteBuffers(1, &ctx.VBO)
|
||||
ctx.shader.use()
|
||||
ctx.shader.set_color('color', color)
|
||||
vertices := [float(x), float(y), float(x2), float(y2)] !
|
||||
vertices := [f32(x), f32(y), f32(x2), f32(y2)] !
|
||||
gl.bind_vao(ctx.VAO)
|
||||
gl.set_vbo(ctx.VBO, vertices, GL_STATIC_DRAW)
|
||||
gl.vertex_attrib_pointer(0, 2, GL_FLOAT, false, 2, 0)
|
||||
@ -673,8 +673,8 @@ pub fn (c &GG) draw_vertical(x, y, height int) {
|
||||
c.draw_line(x, y, x, y + height)
|
||||
}
|
||||
|
||||
// fn (ctx &GG) draw_image(x, y, w, h float, img stbi.Image) {
|
||||
pub fn (ctx &GG) draw_image(x, y, w, h float, tex_id u32) {
|
||||
// fn (ctx &GG) draw_image(x, y, w, h f32, img stbi.Image) {
|
||||
pub fn (ctx &GG) draw_image(x, y, w, h f32, tex_id u32) {
|
||||
// println('DRAW IMAGE $x $y $w $h $tex_id')
|
||||
ctx.shader.use()
|
||||
// ctx.shader.set_color('color', c)
|
||||
|
@ -166,7 +166,7 @@ pub fn (s Shader) uni_location(key string) int {
|
||||
return C.glGetUniformLocation(s.program_id, key.str)
|
||||
}
|
||||
|
||||
// fn (s Shader) set_mat4(str string, f *float) {
|
||||
// fn (s Shader) set_mat4(str string, f *f32) {
|
||||
pub fn (s Shader) set_mat4(str string, m glm.Mat4) {
|
||||
// TODO cache uniform location
|
||||
C.glUniformMatrix4fv(s.uni_location(str), 1, false, m.data)
|
||||
@ -177,6 +177,6 @@ pub fn (s Shader) set_int(str string, n int) {
|
||||
}
|
||||
|
||||
pub fn (s Shader) set_color(str string, c gx.Color) {
|
||||
C.glUniform3f(s.uni_location(str), float(c.r) / 255.0, float(c.g) / 255.0, float(c.b) / 255.0)
|
||||
C.glUniform3f(s.uni_location(str), f32(c.r) / 255.0, f32(c.g) / 255.0, f32(c.b) / 255.0)
|
||||
}
|
||||
|
||||
|
14
gl/gl.v
14
gl/gl.v
@ -33,7 +33,7 @@ pub fn viewport(a int, b int, c int, d int) {
|
||||
}
|
||||
|
||||
pub fn clear_color(r, g, b, a int) {
|
||||
# glClearColor(((float)r)/255.0,((float)g)/255.0,b/255.0, a/255.0);
|
||||
# glClearColor(((f32)r)/255.0,((f32)g)/255.0,b/255.0, a/255.0);
|
||||
}
|
||||
|
||||
pub fn clear() {
|
||||
@ -132,14 +132,14 @@ pub fn buffer_data_int(typ int, vertices[]int, draw_typ int) {
|
||||
C.glBufferData(typ, size, vertices.data, draw_typ)
|
||||
}
|
||||
|
||||
pub fn buffer_data_float(typ int, vertices[]float, draw_typ int) {
|
||||
size := sizeof(float) * vertices.len
|
||||
pub fn buffer_data_f32(typ int, vertices[]f32, draw_typ int) {
|
||||
size := sizeof(f32) * vertices.len
|
||||
C.glBufferData(typ, size, vertices.data, draw_typ)
|
||||
}
|
||||
|
||||
pub fn set_vbo(vbo u32, vertices[]float, draw_typ int) {
|
||||
pub fn set_vbo(vbo u32, vertices[]f32, draw_typ int) {
|
||||
gl.bind_buffer(GL_ARRAY_BUFFER, vbo)
|
||||
gl.buffer_data_float(GL_ARRAY_BUFFER, vertices, draw_typ)
|
||||
gl.buffer_data_f32(GL_ARRAY_BUFFER, vertices, draw_typ)
|
||||
}
|
||||
|
||||
pub fn set_ebo(ebo u32, indices[]int, draw_typ int) {
|
||||
@ -182,8 +182,8 @@ pub fn gen_buffer() u32 {
|
||||
|
||||
pub fn vertex_attrib_pointer(index, size int, typ int, normalized bool, stride int, ptr int) {
|
||||
if typ == GL_FLOAT {
|
||||
stride *= sizeof(float)
|
||||
ptr *= sizeof(float)
|
||||
stride *= sizeof(f32)
|
||||
ptr *= sizeof(f32)
|
||||
}
|
||||
C.glVertexAttribPointer(index, size, typ, normalized, stride, ptr)
|
||||
}
|
||||
|
70
glm/glm.v
70
glm/glm.v
@ -8,32 +8,32 @@ import math
|
||||
|
||||
/*
|
||||
#flag -lmyglm
|
||||
# float* myglm_ortho(float, float, float, float);
|
||||
# float* myglm_translate(float, float, float);
|
||||
# f32* myglm_ortho(f32, f32, f32, f32);
|
||||
# f32* myglm_translate(f32, f32, f32);
|
||||
*/
|
||||
// # float* myglm_rotate(float *m, float angle, float, float, float);
|
||||
// # float* myglm_perspective(float, float, float, float);
|
||||
// # float* myglm_look_at(glm__Vec3, glm__Vec3, glm__Vec3);
|
||||
// # f32* myglm_rotate(f32 *m, f32 angle, f32, f32, f32);
|
||||
// # f32* myglm_perspective(f32, f32, f32, f32);
|
||||
// # f32* myglm_look_at(glm__Vec3, glm__Vec3, glm__Vec3);
|
||||
// # glm__Vec3 myglm_mult(glm__Vec3, glm__Vec3);
|
||||
// # glm__Vec3 myglm_cross(glm__Vec3, glm__Vec3);
|
||||
// # glm__Vec3 myglm_normalize(glm__Vec3);
|
||||
struct Mat4 {
|
||||
pub:
|
||||
data *float
|
||||
data *f32
|
||||
}
|
||||
|
||||
struct Vec2 {
|
||||
x float
|
||||
y float
|
||||
x f32
|
||||
y f32
|
||||
}
|
||||
|
||||
struct Vec3 {
|
||||
x float
|
||||
y float
|
||||
z float
|
||||
x f32
|
||||
y f32
|
||||
z f32
|
||||
}
|
||||
|
||||
fn vec3(x, y, z float) Vec3 {
|
||||
fn vec3(x, y, z f32) Vec3 {
|
||||
res := Vec3 {
|
||||
x: x,
|
||||
y: y,
|
||||
@ -42,7 +42,7 @@ fn vec3(x, y, z float) Vec3 {
|
||||
return res
|
||||
}
|
||||
|
||||
fn mat4(f *float) Mat4 {
|
||||
fn mat4(f *f32) Mat4 {
|
||||
res := Mat4 {
|
||||
data: f
|
||||
}
|
||||
@ -104,7 +104,7 @@ fn (a Vec3) sub(b Vec3) Vec3 {
|
||||
// fn (a Vec3) mult(b Vec3) Vec3 {
|
||||
// # return myglm_mult(a,b);
|
||||
// }
|
||||
fn (a Vec3) mult_scalar(b float) Vec3 {
|
||||
fn (a Vec3) mult_scalar(b f32) Vec3 {
|
||||
res := Vec3 {
|
||||
x: a.x * b,
|
||||
y: a.y * b,
|
||||
@ -122,7 +122,7 @@ fn (a Vec3) print() {
|
||||
}
|
||||
|
||||
/*
|
||||
fn rotate(m Mat4, angle float, vec Vec3) Mat4 {
|
||||
fn rotate(m Mat4, angle f32, vec Vec3) Mat4 {
|
||||
// # t_mat4 m;
|
||||
// println('rotate done')
|
||||
# return glm__mat4( myglm_rotate(m.data, angle, vec.x,vec.y,vec.z) );
|
||||
@ -130,14 +130,14 @@ fn rotate(m Mat4, angle float, vec Vec3) Mat4 {
|
||||
}
|
||||
*/
|
||||
|
||||
fn float_calloc(n int) *float {
|
||||
return *float(calloc(n * sizeof(float)))
|
||||
fn f32_calloc(n int) *f32 {
|
||||
return *f32(calloc(n * sizeof(f32)))
|
||||
}
|
||||
// fn translate(vec Vec3) *float {
|
||||
// fn translate(vec Vec3) *f32 {
|
||||
fn translate(m Mat4, v Vec3) Mat4 {
|
||||
// # return glm__mat4(myglm_translate(vec.x,vec.y,vec.z) );
|
||||
a := m.data
|
||||
mut out := float_calloc(16)
|
||||
mut out := f32_calloc(16)
|
||||
x := v.x
|
||||
y := v.y
|
||||
z := v.z
|
||||
@ -161,11 +161,11 @@ fn normalize(vec Vec3) Vec3 {
|
||||
}
|
||||
*/
|
||||
// https://github.com/g-truc/glm/blob/0ceb2b755fb155d593854aefe3e45d416ce153a4/glm/ext/matrix_clip_space.inl
|
||||
fn ortho(left, right, bottom, top float) Mat4 {
|
||||
fn ortho(left, right, bottom, top f32) Mat4 {
|
||||
println('glm ortho($left, $right, $bottom, $top)')
|
||||
// mat<4, 4, T, defaultp> Result(static_cast<T>(1));
|
||||
n := 16
|
||||
mut res := float_calloc(n)
|
||||
mut res := f32_calloc(n)
|
||||
# res[0] = 2 / (right - left) ;
|
||||
# res[5] = 2.0 / (top - bottom);
|
||||
# res[10] = (1);
|
||||
@ -175,10 +175,10 @@ fn ortho(left, right, bottom, top float) Mat4 {
|
||||
return mat4(res)
|
||||
}
|
||||
|
||||
// fn scale(a *float, v Vec3) *float {
|
||||
// fn scale(a *f32, v Vec3) *f32 {
|
||||
fn scale(m Mat4, v Vec3) Mat4 {
|
||||
a := m.data
|
||||
mut out := float_calloc(16)
|
||||
mut out := f32_calloc(16)
|
||||
x := v.x
|
||||
y := v.y
|
||||
z := v.z
|
||||
@ -201,10 +201,10 @@ fn scale(m Mat4, v Vec3) Mat4 {
|
||||
return mat4(out)
|
||||
}
|
||||
|
||||
// fn rotate_z(a *float, rad float) *float {
|
||||
fn rotate_z(m Mat4, rad float) Mat4 {
|
||||
// fn rotate_z(a *f32, rad f32) *f32 {
|
||||
fn rotate_z(m Mat4, rad f32) Mat4 {
|
||||
a := m.data
|
||||
mut out := float_calloc(16)
|
||||
mut out := f32_calloc(16)
|
||||
s := math.sin(rad)
|
||||
c := math.cos(rad)
|
||||
a00 := a[0]
|
||||
@ -241,7 +241,7 @@ fn identity() Mat4 {
|
||||
// 0 0 1 0
|
||||
// 0 0 0 1
|
||||
n := 16
|
||||
mut res := float_calloc(sizeof(float) * n)
|
||||
mut res := f32_calloc(sizeof(f32) * n)
|
||||
res[0] = 1
|
||||
res[5] = 1
|
||||
res[10] = 1
|
||||
@ -249,19 +249,19 @@ fn identity() Mat4 {
|
||||
return mat4(res)
|
||||
}
|
||||
|
||||
// returns *float without allocation
|
||||
fn identity2(res *float) {
|
||||
// returns *f32 without allocation
|
||||
fn identity2(res *f32) {
|
||||
res[0] = 1
|
||||
res[5] = 1
|
||||
res[10] = 1
|
||||
res[15] = 1
|
||||
// # float f[16]={0};// for (int i =0;i<16;i++)
|
||||
// # f32 f[16]={0};// for (int i =0;i<16;i++)
|
||||
// # printf("!!%d\n", f[0]);
|
||||
// # glm__identity2(&f);
|
||||
// # gl__Shader_set_mat4(shader, tos2("projection"), f) ;
|
||||
}
|
||||
|
||||
fn identity3() []float {
|
||||
fn identity3() []f32 {
|
||||
res := [1.0, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
@ -271,13 +271,13 @@ fn identity3() []float {
|
||||
}
|
||||
|
||||
// https://github.com/toji/gl-matrix/blob/1549cf21dfa14a2bc845993485343d519cf064fe/src/gl-matrix/mat4.js
|
||||
fn ortho_js(left, right, bottom, top float) *float {
|
||||
fn ortho_js(left, right, bottom, top f32) *f32 {
|
||||
mynear := 1
|
||||
myfar := 1
|
||||
lr := 1.0 / (left - right)
|
||||
bt := 1.0 / (bottom - top)
|
||||
nf := 1.0 / 1.0// (mynear -myfar)
|
||||
# float* out = malloc (sizeof(float) * 16);
|
||||
# f32* out = malloc (sizeof(f32) * 16);
|
||||
# out[0] = -2 * lr;
|
||||
# out[1] = 0;
|
||||
# out[2] = 0;
|
||||
@ -299,7 +299,7 @@ fn ortho_js(left, right, bottom, top float) *float {
|
||||
return &f
|
||||
}
|
||||
|
||||
// fn ortho_old(a, b, c, d float) *float {
|
||||
// fn ortho_old(a, b, c, d f32) *f32 {
|
||||
// # return myglm_ortho(a,b,c,d);
|
||||
// }
|
||||
fn cross(a, b Vec3) Vec3 {
|
||||
@ -308,7 +308,7 @@ fn cross(a, b Vec3) Vec3 {
|
||||
}
|
||||
|
||||
/*
|
||||
fn perspective(degrees float, ratio float, a, b float) Mat4 {
|
||||
fn perspective(degrees f32, ratio f32, a, b f32) Mat4 {
|
||||
// println('lang per degrees=$degrees ratio=$ratio a=$a b=$b')
|
||||
// # printf("lang pers degrees=%f ratio=%f a=%f b=%f\n", degrees, ratio, a,b);
|
||||
# return glm__mat4( myglm_perspective(degrees, ratio, a,b) ) ;
|
||||
|
@ -13,7 +13,7 @@ module json
|
||||
#include "cJSON.h"
|
||||
struct C.cJSON {
|
||||
valueint int
|
||||
valuedouble float
|
||||
valuedouble f32
|
||||
valuestring byteptr
|
||||
}
|
||||
|
||||
@ -54,13 +54,6 @@ fn jsdecode_i64(root *C.cJSON) i64 {
|
||||
return i64(root.valuedouble) //i64 is double in C
|
||||
}
|
||||
|
||||
fn jsdecode_float(root *C.cJSON) float {
|
||||
if isnil(root) {
|
||||
return 0
|
||||
}
|
||||
return root.valuedouble
|
||||
}
|
||||
|
||||
fn jsdecode_f32(root *C.cJSON) f32 {
|
||||
if isnil(root) {
|
||||
return f32(0)
|
||||
@ -116,10 +109,6 @@ fn jsencode_i64(val i64) *C.cJSON {
|
||||
return C.cJSON_CreateNumber(val)
|
||||
}
|
||||
|
||||
fn jsencode_float(val float) *C.cJSON {
|
||||
return C.cJSON_CreateNumber(val)
|
||||
}
|
||||
|
||||
fn jsencode_f32(val f32) *C.cJSON {
|
||||
return C.cJSON_CreateNumber(val)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user