-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gg,sokol,examples: add example of overriding _SGL_DEFAULT_MAX_VERTICE…
…S in code
- Loading branch information
Showing
3 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
examples/gg/many_thousands_of_circles_overriding_max_vertices.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import gg | ||
import rand | ||
|
||
// The flags here override the default limits for Sokol | ||
#flag -D_SGL_DEFAULT_MAX_VERTICES=4194304 | ||
#flag -D_SGL_DEFAULT_MAX_COMMANDS=65536 | ||
|
||
// Without the flags, `max_circles` > 5040, will just show | ||
// a blue screen without *any circles* drawn. | ||
const max_circles = 10_000 | ||
|
||
fn main() { | ||
gg.start( | ||
window_title: 'Hello' | ||
bg_color: gg.Color{50, 50, 150, 255} | ||
width: 800 | ||
height: 600 | ||
frame_fn: fn (ctx &gg.Context) { | ||
wsize := gg.window_size() | ||
ctx.begin() | ||
for _ in 0 .. max_circles { | ||
rx := rand.int_in_range(0, wsize.width) or { 0 } | ||
ry := rand.int_in_range(0, wsize.height) or { 0 } | ||
cr := rand.u8() | ||
cg := rand.u8() | ||
cb := rand.u8() | ||
ctx.draw_circle_filled(rx, ry, 10, gg.Color{cr, cg, cb, 255}) | ||
} | ||
ctx.show_fps() | ||
ctx.end() | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters