gl, glfw, freetype fixes
							parent
							
								
									1cfe44d9c6
								
							
						
					
					
						commit
						88d15c6611
					
				| 
						 | 
				
			
			@ -26,12 +26,12 @@ const (
 | 
			
		|||
 | 
			
		||||
const (
 | 
			
		||||
	text_cfg = gx.TextCfg{
 | 
			
		||||
		align:gx.ALIGN_LEFT
 | 
			
		||||
		align:gx.align_left
 | 
			
		||||
		size:TextSize
 | 
			
		||||
		color:gx.rgb(0, 0, 0)
 | 
			
		||||
	}
 | 
			
		||||
	over_cfg = gx.TextCfg{
 | 
			
		||||
		align:gx.ALIGN_LEFT
 | 
			
		||||
		align:gx.align_left
 | 
			
		||||
		size:TextSize
 | 
			
		||||
		color:gx.White
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -110,16 +110,16 @@ struct C.FT_Glyph_Metrics {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
struct C.Glyph {
 | 
			
		||||
	bitmap Bitmap
 | 
			
		||||
	bitmap C.Bitmap
 | 
			
		||||
	bitmap_left int
 | 
			
		||||
	bitmap_top int
 | 
			
		||||
	advance Advance
 | 
			
		||||
	metrics FT_Glyph_Metrics
 | 
			
		||||
	metrics C.FT_Glyph_Metrics
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[typedef]
 | 
			
		||||
struct C.FT_Face {
 | 
			
		||||
	glyph &Glyph
 | 
			
		||||
	glyph &C.Glyph
 | 
			
		||||
	family_name charptr
 | 
			
		||||
	style_name charptr
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -193,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 := FT_Library{0}
 | 
			
		||||
	ft := C.FT_Library{0}
 | 
			
		||||
	// All functions return a value different than 0 whenever
 | 
			
		||||
	// an error occurred
 | 
			
		||||
	mut ret := C.FT_Init_FreeType(&ft)
 | 
			
		||||
| 
						 | 
				
			
			@ -386,7 +386,7 @@ pub fn (ctx mut FreeType) draw_text_def(x, y int, text string) {
 | 
			
		|||
	cfg := gx.TextCfg {
 | 
			
		||||
		color: gx.Black
 | 
			
		||||
		size: default_font_size
 | 
			
		||||
		align: gx.ALIGN_LEFT
 | 
			
		||||
		align: gx.align_left
 | 
			
		||||
	}
 | 
			
		||||
	ctx.draw_text(x, y, text, cfg)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -451,9 +451,12 @@ pub fn (ctx mut FreeType) text_size(s string) (int, int) {
 | 
			
		|||
	return scaled_x, scaled_y
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
pub fn (f FT_Face) str() string {
 | 
			
		||||
	return 'FT_Face{ style_name: ${ptr_str(f.style_name)} family_name: ${ptr_str(f.family_name)} }'
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
pub fn (ac []Character) str() string {
 | 
			
		||||
	mut res := []string
 | 
			
		||||
	for c in ac {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -120,7 +120,7 @@ pub fn (ctx &GG) draw_text_def(x, y int, text string) {
 | 
			
		|||
	cfg := gx.TextCfg {
 | 
			
		||||
		color: gx.Black
 | 
			
		||||
		size: default_font_size
 | 
			
		||||
		align: gx.ALIGN_LEFT
 | 
			
		||||
		align: gx.align_left
 | 
			
		||||
	}
 | 
			
		||||
	ctx.draw_text(x, y, text, cfg)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										40
									
								
								vlib/gl/gl.v
								
								
								
								
							
							
						
						
									
										40
									
								
								vlib/gl/gl.v
								
								
								
								
							| 
						 | 
				
			
			@ -11,6 +11,46 @@ module gl
 | 
			
		|||
// joe-c: fix & remove
 | 
			
		||||
pub enum TmpGlImportHack{ non_empty }
 | 
			
		||||
 | 
			
		||||
fn C.glDisable()
 | 
			
		||||
fn C.glEnable()
 | 
			
		||||
fn C.glScissor()
 | 
			
		||||
fn C.glVertexAttribPointer()
 | 
			
		||||
fn C.glGenBuffers()
 | 
			
		||||
fn C.glEnableVertexAttribArray()
 | 
			
		||||
fn C.glGenVertexArrays()
 | 
			
		||||
fn C.glDrawElements()
 | 
			
		||||
fn C.glUseProgram()
 | 
			
		||||
fn C.glDrawArrays()
 | 
			
		||||
fn C.glBufferData()
 | 
			
		||||
fn C.glGenerateMipmap()
 | 
			
		||||
fn C.glTexParameteri()
 | 
			
		||||
fn C.glDeleteTextures()
 | 
			
		||||
fn C.glBindTexture()
 | 
			
		||||
fn C.glActiveTexture()
 | 
			
		||||
fn C.glGenTextures()
 | 
			
		||||
fn C.glBindBuffer()
 | 
			
		||||
fn C.glBindVertexArray()
 | 
			
		||||
fn C.glGetProgramInfoLog()
 | 
			
		||||
fn C.glGetShaderInfoLog()
 | 
			
		||||
fn C.glDeleteShader()
 | 
			
		||||
fn C.glGetProgramiv()
 | 
			
		||||
fn C.glLinkProgram()
 | 
			
		||||
fn C.glAttachShader()
 | 
			
		||||
fn C.glGetShaderiv()
 | 
			
		||||
fn C.glCompileShader()
 | 
			
		||||
fn C.glShaderSource()
 | 
			
		||||
fn C.glCreateProgram()
 | 
			
		||||
fn C.glClear()
 | 
			
		||||
fn C.glCreateShader()
 | 
			
		||||
fn C.glClearColor()
 | 
			
		||||
fn C.glViewport()
 | 
			
		||||
fn C.gladLoadGL()
 | 
			
		||||
fn C.glTexImage2D()
 | 
			
		||||
fn C.glPixelStorei()
 | 
			
		||||
fn C.glBlendFunc()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
pub fn init_glad() {
 | 
			
		||||
	ok := C.gladLoadGL()
 | 
			
		||||
	if isnil(ok) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,6 +51,25 @@ pub const (
 | 
			
		|||
	KeyDown  = 264
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
fn C.glfwGetWindowUserPointer() voidptr
 | 
			
		||||
fn C.glfwGetPrimaryMonitor() voidptr
 | 
			
		||||
fn C.glfwSetWindowUserPointer()
 | 
			
		||||
fn C.glfwSetCursor()
 | 
			
		||||
fn C.glfwGetCursorPos()
 | 
			
		||||
fn C.glfwSetClipboardString()
 | 
			
		||||
fn C.glfwGetWindowContentScale()
 | 
			
		||||
fn C.glfwGetClipboardString()
 | 
			
		||||
fn C.glfwGetKey()
 | 
			
		||||
fn C.glfwGetTime()
 | 
			
		||||
fn C.glfwSetCharModsCallback()
 | 
			
		||||
fn C.glfwSetKeyCallback()
 | 
			
		||||
fn C.glfwPostEmptyEvent()
 | 
			
		||||
fn C.glfwSetScrollCallback()
 | 
			
		||||
fn C.glfwSetWindowSizeCallback()
 | 
			
		||||
fn C.glfwSetMouseButtonCallback()
 | 
			
		||||
fn C.glfwSetCursorPosCallback()
 | 
			
		||||
fn C.glfwSwapBuffers()
 | 
			
		||||
 | 
			
		||||
// joe-c: fix & remove
 | 
			
		||||
struct TmpGlImportHack {
 | 
			
		||||
	hack gl.TmpGlImportHack
 | 
			
		||||
| 
						 | 
				
			
			@ -341,3 +360,4 @@ pub fn (size Size) str() string {
 | 
			
		|||
pub fn get_window_user_pointer(gwnd voidptr) voidptr {
 | 
			
		||||
	return C.glfwGetWindowUserPointer(gwnd)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -262,7 +262,7 @@ pub fn identity2(res mut &f32) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
pub fn identity3() []f32 {
 | 
			
		||||
	res := [1.0, 0, 0, 0,
 | 
			
		||||
	res := [f32(1.0), 0, 0, 0,
 | 
			
		||||
	0, 1, 0, 0,
 | 
			
		||||
	0, 0, 1, 0,
 | 
			
		||||
	0, 0, 0, 1,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,7 +48,7 @@ pub const (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
pub const (
 | 
			
		||||
	ALIGN_LEFT  = 1
 | 
			
		||||
	align_left  = 1
 | 
			
		||||
	ALIGN_RIGHT = 4
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,7 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	max_nr_errors = 100
 | 
			
		||||
	max_nr_errors = 300
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
pub struct Checker {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -790,9 +790,9 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) {
 | 
			
		|||
				g.writeln('free(_const_os__args.data); // empty, inited in _vinit()')
 | 
			
		||||
			}
 | 
			
		||||
			$if windows {
 | 
			
		||||
				g.writeln('_const_os__args = os__init_os_args(argc, (byteptr*)argv);')
 | 
			
		||||
			}	$else {
 | 
			
		||||
				g.writeln('_const_os__args = os__init_os_args_wide(argc, (byteptr*)argv);')
 | 
			
		||||
			}	$else {
 | 
			
		||||
				g.writeln('_const_os__args = os__init_os_args(argc, (byteptr*)argv);')
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue