diff --git a/vlib/freetype/freetype.v b/vlib/freetype/freetype.v index 8620709f60..11d137d52b 100644 --- a/vlib/freetype/freetype.v +++ b/vlib/freetype/freetype.v @@ -63,7 +63,9 @@ struct Character { } [typedef] -struct C.FT_Library {} +struct C.FT_Library { + _z int +} pub struct FreeType { shader gl.Shader @@ -77,7 +79,7 @@ pub struct FreeType { line_vbo u32 vbo u32 chars []Character - face &C.FT_FaceRec + face C.FT_Face scale int // retina = 2 , normal = 1 mut: utf_runes []string @@ -116,16 +118,15 @@ struct C.Glyph { } [typedef] -struct C.FT_FaceRec { +struct C.FT_Face { glyph &C.Glyph family_name charptr style_name charptr } -///type FT_Face &C.FT_FaceRec fn C.FT_Load_Char(voidptr, i64, int) int -fn ft_load_char(face &C.FT_FaceRec, code i64) Character { +fn ft_load_char(face C.FT_Face, code i64) Character { //println('\nftload_char( code=$code)') //C.printf('face=%p\n', face) //C.printf('cobj=%p\n', _face.cobj) @@ -140,10 +141,10 @@ fn ft_load_char(face &C.FT_FaceRec, code i64) Character { mut texture := 0 C.glGenTextures(1, &texture) C.glBindTexture(C.GL_TEXTURE_2D, texture) - fgwidth := (*face).glyph.bitmap.width - fgrows := (*face).glyph.bitmap.rows + fgwidth := face.glyph.bitmap.width + fgrows := face.glyph.bitmap.rows C.glTexImage2D(C.GL_TEXTURE_2D, 0, C.GL_RED, fgwidth, fgrows, - 0, C.GL_RED, C.GL_UNSIGNED_BYTE, (*face).glyph.bitmap.buffer) + 0, C.GL_RED, C.GL_UNSIGNED_BYTE, face.glyph.bitmap.buffer) // Set texture options C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_WRAP_S, C.GL_CLAMP_TO_EDGE) C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_WRAP_T, C.GL_CLAMP_TO_EDGE) @@ -157,11 +158,11 @@ fn ft_load_char(face &C.FT_FaceRec, code i64) Character { // Note: advance is number of 1/64 pixels // Bitshift by 6 to get value in pixels (2^6 = 64 (divide amount of 1/64th pixels by 64 to get amount of pixels)) - horizontal_bearing_px: gg.vec2((*face).glyph.metrics.horiBearingX >> 6, (*face).glyph.metrics.horiBearingY >> 6) - vertical_bearing_px: gg.vec2((*face).glyph.metrics.vertBearingX >> 6, (*face).glyph.metrics.vertBearingY >> 6) // not used for now + horizontal_bearing_px: gg.vec2(face.glyph.metrics.horiBearingX >> 6, face.glyph.metrics.horiBearingY >> 6) + vertical_bearing_px: gg.vec2(face.glyph.metrics.vertBearingX >> 6, face.glyph.metrics.vertBearingY >> 6) // not used for now - horizontal_advance_px: (*face).glyph.metrics.horiAdvance >> 6 - vertical_advance_px: (*face).glyph.metrics.vertAdvance >> 6 + horizontal_advance_px: face.glyph.metrics.horiAdvance >> 6 + vertical_advance_px: face.glyph.metrics.vertAdvance >> 6 } } @@ -192,7 +193,7 @@ pub fn new_context(cfg gg.Cfg) &FreeType { projection := glm.ortho(0, width, 0, height)// 0 at BOT shader.set_mat4('projection', projection) // FREETYPE - ft := C.FT_Library{} + ft := C.FT_Library{0} // All functions return a value different than 0 whenever // an error occurred mut ret := C.FT_Init_FreeType(&ft) @@ -214,7 +215,7 @@ pub fn new_context(cfg gg.Cfg) &FreeType { return 0 } println('Trying to load font from $font_path') - face := &C.FT_FaceRec{} + face := C.FT_Face{} ret = int(C.FT_New_Face(ft, font_path.str, 0, &face)) if ret != 0 { println('freetype: failed to load the font (error=$ret)') diff --git a/vlib/gl/gl.v b/vlib/gl/gl.v index 9906cd4578..0dd3267e19 100644 --- a/vlib/gl/gl.v +++ b/vlib/gl/gl.v @@ -11,8 +11,6 @@ module gl // joe-c: fix & remove pub enum TmpGlImportHack{ non_empty } -fn C.gladLoadGL() int - fn C.glDisable() fn C.glEnable() fn C.glScissor() @@ -46,6 +44,7 @@ fn C.glClear() fn C.glCreateShader() int fn C.glClearColor() fn C.glViewport() +fn C.gladLoadGL() fn C.glTexImage2D() fn C.glPixelStorei() fn C.glBlendFunc() @@ -53,9 +52,10 @@ fn C.glPolygonMode() fn C.glDeleteBuffers() + pub fn init_glad() { ok := C.gladLoadGL() - if ok == 0 { + if isnil(ok) { println('Failed to initialize glad OpenGL context') exit(1) } diff --git a/vlib/glfw/glfw.v b/vlib/glfw/glfw.v index a90077f53e..a4165a15f0 100644 --- a/vlib/glfw/glfw.v +++ b/vlib/glfw/glfw.v @@ -77,7 +77,7 @@ fn C.glfwSwapInterval() fn C.glfwMakeContextCurrent() fn C.glfwSetWindowTitle() fn C.glfwTerminate() -fn C.glfwCreateWindow(w int, h int, title charptr, m voidptr, sh voidptr) voidptr +fn C.glfwCreateWindow() fn C.glfwWindowHint() fn C.glfwDestroyWindow() fn C.glfwInit() diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 0ca257b7b1..f4de5c57d1 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -124,13 +124,8 @@ pub fn cgen(files []ast.File, table &table.Table, pref &pref.Preferences) string } // g.finish() - return g.hashes() + - '\n// V includes:\n' + g.includes.str() + - '\n// V typedefs:\n' + g.typedefs.str() + g.typedefs2.str() + - '\n// V definitions:\n' + g.definitions.str() + - '\n// V gowrappers:\n' + g.gowrappers.str() + - '\n// V stringliterals:\n' + g.stringliterals.str() + - '\n// V out\n' + g.out.str() + return g.hashes() + g.includes.str() + g.typedefs.str() + g.typedefs2.str() + g.definitions.str() + + g.gowrappers.str() + g.stringliterals.str() + g.out.str() } pub fn (g Gen) hashes() string { @@ -483,10 +478,7 @@ fn (g mut Gen) stmt(node ast.Stmt) { ast.HashStmt { // #include etc typ := it.val.all_before(' ') - if typ == 'include' { - g.includes.writeln('#$it.val') - } - if typ == 'define' { + if typ in ['include', 'define'] { g.definitions.writeln('#$it.val') } }