fix Tetris example

pull/441/head
Alexander Medvednikov 2019-06-23 13:17:33 +02:00
parent f72de84e9c
commit c619243067
3 changed files with 13 additions and 4 deletions

View File

@ -2287,8 +2287,8 @@ fn (p mut Parser) array_init() string {
// println('GOT TYP after [] $typ')
}
// ! after array => no malloc and no copy
no_copy := p.tok == NOT
if no_copy {
no_alloc := p.tok == NOT
if no_alloc {
p.next()
}
// [1,2,3]!! => [3]int{1,2,3}
@ -2312,8 +2312,8 @@ fn (p mut Parser) array_init() string {
// typ += '_ptr"
// }
mut new_arr := 'new_array_from_c_array'
if no_copy {
new_arr += '_no_copy'
if no_alloc {
new_arr += '_no_alloc'
}
p.gen(' })')
// p.gen('$new_arr($vals.len, $vals.len, sizeof($typ), ($typ[]) $c_arr );')

View File

@ -13,8 +13,13 @@ import const (
GL_DEPTH_TEST
)
// TODO: windows support
#flag linux -I$HOME/code/v/thirdparty/glad
#flag darwin -I$HOME/code/v/thirdparty/glad
#include "glad.h"
#include "glad.c"
fn init_glad() {
ok := C.gladLoadGL()
if !ok {

View File

@ -129,6 +129,10 @@ fn rotate(m Mat4, angle float, vec Vec3) Mat4 {
return Mat4{}
}
*/
fn float_calloc(n int) *float {
return *float(calloc(n * sizeof(float)))
}
// fn translate(vec Vec3) *float {
fn translate(m Mat4, v Vec3) Mat4 {
// # return glm__mat4(myglm_translate(vec.x,vec.y,vec.z) );