mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: support better placment and scaling on nonsquare viewports in cube.v (#8513)
This commit is contained in:
parent
17062dc5c8
commit
975206f38e
@ -270,14 +270,16 @@ fn cube_field(app App){
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn frame(mut app App) {
|
fn frame(mut app App) {
|
||||||
dw := app.gg.width
|
ws := gg.window_size()
|
||||||
dh := app.gg.height
|
ratio := f32(ws.width)/ws.height
|
||||||
ww := dh/2 /* not a bug */
|
dw := ws.width
|
||||||
hh := dh/2
|
dh := ws.height
|
||||||
x0 := dw/2 - hh
|
ww := int(dh/3) /* not a bug */
|
||||||
|
hh := int(dh/3)
|
||||||
|
x0 := int(f32(dw) * 0.05)
|
||||||
//x1 := dw/2
|
//x1 := dw/2
|
||||||
y0 := 0
|
y0 := 0
|
||||||
y1 := dh/2
|
y1 := int(f32(dh) * 0.5)
|
||||||
|
|
||||||
app.gg.begin()
|
app.gg.begin()
|
||||||
//sgl.defaults()
|
//sgl.defaults()
|
||||||
@ -291,11 +293,11 @@ fn frame(mut app App) {
|
|||||||
draw_cubes(app)
|
draw_cubes(app)
|
||||||
|
|
||||||
// textured cubed with viewport
|
// textured cubed with viewport
|
||||||
sgl.viewport(0, 0, dw, dh, true)
|
sgl.viewport(0, int(dh/5), dw, int(dh*ratio), true)
|
||||||
draw_texture_cubes(app)
|
draw_texture_cubes(app)
|
||||||
|
|
||||||
// textured field of cubes with viewport
|
// textured field of cubes with viewport
|
||||||
sgl.viewport(0, 0, dw, dh, true)
|
sgl.viewport(0, int(dh/5), dw, int(dh*ratio), true)
|
||||||
cube_field(app)
|
cube_field(app)
|
||||||
|
|
||||||
app.frame_count++
|
app.frame_count++
|
||||||
@ -386,6 +388,13 @@ fn my_event_manager(mut ev sapp.Event, mut app App) {
|
|||||||
app.mouse_x = int(ev.mouse_x)
|
app.mouse_x = int(ev.mouse_x)
|
||||||
app.mouse_y = int(ev.mouse_y)
|
app.mouse_y = int(ev.mouse_y)
|
||||||
}
|
}
|
||||||
|
if ev.typ == .touches_began || ev.typ == .touches_moved {
|
||||||
|
if ev.num_touches > 0 {
|
||||||
|
touch_point := ev.touches[0]
|
||||||
|
app.mouse_x = int(touch_point.pos_x)
|
||||||
|
app.mouse_y = int(touch_point.pos_y)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user