From f18265e6a84bd97795b9206108b372f3a8aa9a5b Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 24 Jun 2021 11:07:09 +0300 Subject: [PATCH] gg: remove obsolete usages of `use_ortho: true` --- examples/fireworks/fireworks.v | 1 - examples/flappylearning/game.v | 1 - examples/game_of_life/life_gg.v | 1 - examples/gg/raven_text_rendering.v | 1 - examples/gg/rectangles.v | 1 - examples/gg/worker_thread.v | 1 - examples/hot_reload/bounce.v | 1 - examples/hot_reload/graph.v | 1 - examples/snek/snek.v | 1 - examples/sokol/01_cubes/cube.v | 1 - examples/sokol/02_cubes_glsl/cube_glsl.v | 1 - .../sokol/03_march_tracing_glsl/rt_glsl.v | 1 - examples/sokol/04_multi_shader_glsl/rt_glsl.v | 1 - examples/sokol/05_instancing_glsl/rt_glsl.v | 1 - examples/sokol/06_obj_viewer/show_obj.v | 3 +- examples/sokol/sounds/melody.v | 1 - examples/tetris/tetris.v | 1 - examples/ttf_font/example_ttf.v | 1 - vlib/x/ttf/README.md | 33 +++++++++---------- 19 files changed, 17 insertions(+), 36 deletions(-) diff --git a/examples/fireworks/fireworks.v b/examples/fireworks/fireworks.v index 361dff026b..9581cc54ab 100644 --- a/examples/fireworks/fireworks.v +++ b/examples/fireworks/fireworks.v @@ -109,7 +109,6 @@ fn main() { height: app.ui.height window_title: 'Fireworks!' bg_color: gx.black - use_ortho: true user_data: app frame_fn: on_frame event_fn: on_event diff --git a/examples/flappylearning/game.v b/examples/flappylearning/game.v index 5b1ef094dc..15cdc28ced 100644 --- a/examples/flappylearning/game.v +++ b/examples/flappylearning/game.v @@ -185,7 +185,6 @@ fn main() { bg_color: gx.white width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: 'flappylearning-v' frame_fn: frame diff --git a/examples/game_of_life/life_gg.v b/examples/game_of_life/life_gg.v index 2b202f9c2e..2f45017c43 100644 --- a/examples/game_of_life/life_gg.v +++ b/examples/game_of_life/life_gg.v @@ -48,7 +48,6 @@ fn main() { user_data: &app width: screen_width height: screen_height - use_ortho: true create_window: true resizable: false window_title: 'v life (with gg, gx)' diff --git a/examples/gg/raven_text_rendering.v b/examples/gg/raven_text_rendering.v index 5d14e46ed1..2007787934 100644 --- a/examples/gg/raven_text_rendering.v +++ b/examples/gg/raven_text_rendering.v @@ -74,7 +74,6 @@ fn main() { app.gg = gg.new_context( width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: 'Empty window' user_data: app diff --git a/examples/gg/rectangles.v b/examples/gg/rectangles.v index ae8e2afc61..73229fd532 100644 --- a/examples/gg/rectangles.v +++ b/examples/gg/rectangles.v @@ -23,7 +23,6 @@ fn main() { bg_color: gx.white width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: 'Rectangles' frame_fn: frame diff --git a/examples/gg/worker_thread.v b/examples/gg/worker_thread.v index dfb4c8f593..b1bd454032 100644 --- a/examples/gg/worker_thread.v +++ b/examples/gg/worker_thread.v @@ -30,7 +30,6 @@ fn main() { app.gg = gg.new_context( width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: 'Counter' user_data: app diff --git a/examples/hot_reload/bounce.v b/examples/hot_reload/bounce.v index e9d17a0fa1..135ad52b29 100644 --- a/examples/hot_reload/bounce.v +++ b/examples/hot_reload/bounce.v @@ -37,7 +37,6 @@ fn main() { width: window_width height: window_height font_size: 20 - use_ortho: true user_data: game window_title: 'Hot code reloading demo' create_window: true diff --git a/examples/hot_reload/graph.v b/examples/hot_reload/graph.v index 9cfa8545fb..53228f1339 100644 --- a/examples/hot_reload/graph.v +++ b/examples/hot_reload/graph.v @@ -23,7 +23,6 @@ fn main() { width: size height: size font_size: 20 - use_ortho: true user_data: context window_title: 'Graph builder' create_window: true diff --git a/examples/snek/snek.v b/examples/snek/snek.v index 02659289f1..1d66fb1fcc 100644 --- a/examples/snek/snek.v +++ b/examples/snek/snek.v @@ -211,7 +211,6 @@ fn main() { user_data: &app width: canvas_size height: top_height + canvas_size - use_ortho: true create_window: true resizable: false window_title: 'snek' diff --git a/examples/sokol/01_cubes/cube.v b/examples/sokol/01_cubes/cube.v index 8a54421526..c933dbfefd 100644 --- a/examples/sokol/01_cubes/cube.v +++ b/examples/sokol/01_cubes/cube.v @@ -418,7 +418,6 @@ fn main() { app.gg = gg.new_context( width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: '3D Cube Demo' user_data: app diff --git a/examples/sokol/02_cubes_glsl/cube_glsl.v b/examples/sokol/02_cubes_glsl/cube_glsl.v index 3b7c1d7073..0be09a4a14 100644 --- a/examples/sokol/02_cubes_glsl/cube_glsl.v +++ b/examples/sokol/02_cubes_glsl/cube_glsl.v @@ -612,7 +612,6 @@ fn main() { app.gg = gg.new_context( width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: '3D Cube Demo' user_data: app diff --git a/examples/sokol/03_march_tracing_glsl/rt_glsl.v b/examples/sokol/03_march_tracing_glsl/rt_glsl.v index 50b62ed2cf..73a85a31aa 100644 --- a/examples/sokol/03_march_tracing_glsl/rt_glsl.v +++ b/examples/sokol/03_march_tracing_glsl/rt_glsl.v @@ -423,7 +423,6 @@ fn main() { app.gg = gg.new_context( width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: '3D Ray Marching Cube' user_data: app diff --git a/examples/sokol/04_multi_shader_glsl/rt_glsl.v b/examples/sokol/04_multi_shader_glsl/rt_glsl.v index 059ad0e207..d19d1994da 100644 --- a/examples/sokol/04_multi_shader_glsl/rt_glsl.v +++ b/examples/sokol/04_multi_shader_glsl/rt_glsl.v @@ -619,7 +619,6 @@ fn main() { app.gg = gg.new_context( width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: '3D Dual shader Cube - click and rotate with the mouse' user_data: app diff --git a/examples/sokol/05_instancing_glsl/rt_glsl.v b/examples/sokol/05_instancing_glsl/rt_glsl.v index 57b0b606f1..f06a8e3aa9 100644 --- a/examples/sokol/05_instancing_glsl/rt_glsl.v +++ b/examples/sokol/05_instancing_glsl/rt_glsl.v @@ -506,7 +506,6 @@ fn main(){ app.gg = gg.new_context({ width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: 'Instancing Cube' user_data: app diff --git a/examples/sokol/06_obj_viewer/show_obj.v b/examples/sokol/06_obj_viewer/show_obj.v index 18f0258a60..e2e0be390f 100644 --- a/examples/sokol/06_obj_viewer/show_obj.v +++ b/examples/sokol/06_obj_viewer/show_obj.v @@ -323,7 +323,6 @@ fn main() { app.gg = gg.new_context( width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: 'V Wavefront OBJ viewer - Use the mouse wheel to zoom' user_data: app @@ -336,4 +335,4 @@ fn main() { app.ticks = time.ticks() app.gg.run() -} \ No newline at end of file +} diff --git a/examples/sokol/sounds/melody.v b/examples/sokol/sounds/melody.v index b5f230caed..aa5ebc4025 100644 --- a/examples/sokol/sounds/melody.v +++ b/examples/sokol/sounds/melody.v @@ -44,7 +44,6 @@ fn main() { bg_color: gx.rgb(50, 50, 50) width: 1024 height: 400 - use_ortho: true create_window: true window_title: 'ByteBeat Music' frame_fn: graphics_frame diff --git a/examples/tetris/tetris.v b/examples/tetris/tetris.v index fdc909d124..85a6a3eac8 100644 --- a/examples/tetris/tetris.v +++ b/examples/tetris/tetris.v @@ -167,7 +167,6 @@ fn main() { bg_color: gx.white width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: 'V Tetris' // user_data: game diff --git a/examples/ttf_font/example_ttf.v b/examples/ttf_font/example_ttf.v index 1a7b04bcc6..02e43cd60b 100644 --- a/examples/ttf_font/example_ttf.v +++ b/examples/ttf_font/example_ttf.v @@ -123,7 +123,6 @@ fn main() { app.gg = gg.new_context( width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: 'Test TTF module' user_data: app diff --git a/vlib/x/ttf/README.md b/vlib/x/ttf/README.md index 6594b5c916..a53b83685e 100644 --- a/vlib/x/ttf/README.md +++ b/vlib/x/ttf/README.md @@ -1,7 +1,7 @@ # TTF font utility ## introduction This module is designed to perform two main task -- Load the font file +- Load the font file - Render text using a TTF font The render system can be single or multiple, for example it is possible to have a bitmap @@ -18,7 +18,7 @@ ttf_font.buf = os.read_bytes("arial.ttf") or { panic(err) } ttf_font.init() ``` *Note: the font must be passed to the `TTF_file` as RAM buffer.* -At this point the font "arial" is loaded and parsed and if it is a valid TTF font it is +At this point the font "arial" is loaded and parsed and if it is a valid TTF font it is ready for the rendering. We can get some quick info on the font as string using the `get_info_string` function: @@ -53,7 +53,7 @@ In this modue it is possible to have different renders running at the same time. At the present time all the rendering are made on the CPU, sokol is used only to draw the rendered text to the screen. Let's start with a simple snippet of code: -```v ignore +```v oksyntax import os import x.ttf [console] @@ -70,7 +70,7 @@ This simple code load a TTF font and display its basic informations. ### draw_text The draw text function draw simple strings without indentation or other imagination tasks. At this point we can render a simple text: -```v ignore +```v oksyntax import os import x.ttf @@ -81,7 +81,7 @@ fn main(){ ttf_font.init() // print font info println(ttf_font.get_info_string()) - + bmp_width := 200 bmp_heigth := 64 bmp_layers := 4 // number of planes for an RGBA buffer @@ -122,7 +122,7 @@ Using the low level rendering you need to manage all the amenities like allocate memory and other tasks like calc the character dimensions. You can specify the style for the text rendering in the `BitMap` struct:: -```v ignore +```v enum Style { outline outline_aliased @@ -134,7 +134,7 @@ Use this level only if you want achieve particular result on text rendering. ### draw_text_block Draw text block draw a justified and indented block of multiline text in the bitmap. -```v ignore +```v oksyntax import os import x.ttf @@ -145,7 +145,7 @@ fn main(){ ttf_font.init() // print font info println(ttf_font.get_info_string()) - + bmp_width := 200 bmp_heigth := 200 bmp_layers := 4 // number of planes for an RGBA buffer @@ -186,7 +186,7 @@ But Vwill prevail for sure, V is the way!! ``` This is the low level render that draw text block on the bitmap. A text block is defined from a `Text_block` struct: -```v ignore +```v struct Text_block { x int // x postion of the left high corner y int // y postion of the left high corner @@ -196,7 +196,7 @@ struct Text_block { } ``` and use the following bitmap fields: -```v ignore +```v oksyntax style Style = .filled // default syle align Text_align = .left // default text align justify bool // justify text flag, default deactivated @@ -211,7 +211,7 @@ the text to the screen. It is mor esimpel to use in a `gg app` that the raw bitmap render. Each single text rendered need its own reder to be declared, after you can modify it. Here a simple example of the usage: -```v ignore +```v oksyntax import gg import gx import sokol.sapp @@ -235,7 +235,7 @@ pub mut: sg_img C.sg_image init_flag bool frame_c int - + tf []ttf.TTF_File ttf_render []ttf.TTF_render_Sokol } @@ -246,7 +246,7 @@ fn my_init(mut app App_data) { fn draw_frame(mut app &App_data) { cframe_txt := "Current Frame: $app.frame_c" - + app.gg.begin() sgl.defaults() @@ -267,7 +267,7 @@ fn draw_frame(mut app &App_data) { } [console] -fn main(){ +fn main(){ mut app := &App_data{ gg: 0 } @@ -275,7 +275,6 @@ fn main(){ app.gg = gg.new_context({ width: win_width height: win_height - use_ortho: true // This is needed for 2D drawing create_window: true window_title: 'Test TTF module' user_data: app @@ -293,7 +292,7 @@ fn main(){ println(tf.get_info_string()) app.tf << tf } - + // TTF render 0 Frame counter app.ttf_render << &ttf.TTF_render_Sokol { bmp: &ttf.BitMap{ @@ -304,7 +303,7 @@ fn main(){ //style: .raw } } - + app.gg.run() } ```