examples: simplify gg/rectangles.v
parent
c6ae322f85
commit
79b70006e6
|
@ -12,10 +12,13 @@ const (
|
||||||
struct App {
|
struct App {
|
||||||
mut:
|
mut:
|
||||||
gg &gg.Context
|
gg &gg.Context
|
||||||
|
image gg.Image
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut app := &App{}
|
mut app := &App{
|
||||||
|
//image: gg.create_image2('logo.png')
|
||||||
|
}
|
||||||
app.gg = gg.new_context(
|
app.gg = gg.new_context(
|
||||||
bg_color: gx.white
|
bg_color: gx.white
|
||||||
width: win_width
|
width: win_width
|
||||||
|
@ -30,23 +33,16 @@ fn main() {
|
||||||
app.gg.run()
|
app.gg.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame(user_data voidptr) {
|
fn frame(app &App) {
|
||||||
mut app := &App(user_data)
|
app.gg.begin()
|
||||||
mut gg := app.gg
|
|
||||||
gg.begin()
|
|
||||||
/*
|
|
||||||
if gg.fons == 0 {
|
|
||||||
gg.init_font()
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
app.draw()
|
app.draw()
|
||||||
//C.sfons_flush(gg.fons)
|
app.gg.end()
|
||||||
gg.end()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (app &App) draw() {
|
fn (app &App) draw() {
|
||||||
//app.gg.draw_text_def(200,20, 'hello world!')
|
//app.gg.draw_text_def(200,20, 'hello world!')
|
||||||
//app.gg.draw_text_def(300,300, 'привет')
|
//app.gg.draw_text_def(300,300, 'привет')
|
||||||
app.gg.draw_rect(10, 10, 100, 30, gx.blue)
|
app.gg.draw_rect(10, 10, 100, 30, gx.blue)
|
||||||
app.gg.draw_empty_rect(10, 150, 80, 40, gx.green)
|
app.gg.draw_empty_rect(110, 150, 80, 40, gx.black)
|
||||||
|
//app.gg.draw_image2(30,30,100,30, app.image)
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,8 +283,7 @@ pub fn create_image2(file string) Image {
|
||||||
ptr: img.data
|
ptr: img.data
|
||||||
size: img.nr_channels * img.width * img.height
|
size: img.nr_channels * img.width * img.height
|
||||||
}
|
}
|
||||||
the_sokol_image := C.sg_make_image(&img_desc)
|
img.sokol_img = C.sg_make_image(&img_desc)
|
||||||
img.sokol_img = the_sokol_image
|
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue