Direct draw calls are recorded into a per-frame plan. When both the widget paint and the plan match the previous frame, the native host presents the retained frame instead of repainting it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
42 lines
1.3 KiB
Ziran
42 lines
1.3 KiB
Ziran
#import, file "../src/app/direct_draw_plan.zi";
|
|
#import "drawing_props"
|
|
#import "geometry"
|
|
|
|
#program_export
|
|
Answer :: () -> s32 {
|
|
viewport := Rectangle.{0.0, 0.0, 320.0, 240.0}
|
|
camera := Camera.{Vector2.{0.0, 0.0}, Vector2.{0.0, 0.0}, 0.0, 1.0}
|
|
|
|
DirectDrawFrameBegin(viewport)
|
|
DirectDrawTransform(camera)
|
|
DirectDrawRecordCircleV(Vector2.{40.0, 50.0}, 12.0,
|
|
Color.{10, 20, 30, 255})
|
|
if DirectDrawFrameFinish() { return 1 }
|
|
|
|
DirectDrawFrameBegin(viewport)
|
|
DirectDrawTransform(camera)
|
|
DirectDrawRecordCircleV(Vector2.{40.0, 50.0}, 12.0,
|
|
Color.{10, 20, 30, 255})
|
|
if !DirectDrawFrameFinish() || !DirectDrawFrameUnchanged() { return 2 }
|
|
|
|
DirectDrawFrameBegin(viewport)
|
|
DirectDrawTransform(camera)
|
|
DirectDrawRecordCircleV(Vector2.{40.0, 50.0}, 13.0,
|
|
Color.{10, 20, 30, 255})
|
|
if DirectDrawFrameFinish() { return 3 }
|
|
|
|
camera.zoom = 2.0
|
|
DirectDrawFrameBegin(viewport)
|
|
DirectDrawTransform(camera)
|
|
DirectDrawRecordCircleV(Vector2.{40.0, 50.0}, 13.0,
|
|
Color.{10, 20, 30, 255})
|
|
if DirectDrawFrameFinish() { return 4 }
|
|
|
|
DirectDrawFrameBegin(Rectangle.{0.0, 0.0, 321.0, 240.0})
|
|
DirectDrawTransform(camera)
|
|
DirectDrawRecordCircleV(Vector2.{40.0, 50.0}, 13.0,
|
|
Color.{10, 20, 30, 255})
|
|
if DirectDrawFrameFinish() { return 5 }
|
|
return 0
|
|
}
|