fix(ui): remove flickering on ui pause/timeout
This commit is contained in:
parent
2b9a479b96
commit
d9e09a9cbe
|
@ -12,6 +12,7 @@ const emu = @import("core/emu.zig");
|
||||||
const Gui = @import("platform.zig").Gui;
|
const Gui = @import("platform.zig").Gui;
|
||||||
const Arm7tdmi = @import("core/cpu.zig").Arm7tdmi;
|
const Arm7tdmi = @import("core/cpu.zig").Arm7tdmi;
|
||||||
const RingBuffer = @import("zba-util").RingBuffer;
|
const RingBuffer = @import("zba-util").RingBuffer;
|
||||||
|
const Dimensions = @import("platform.zig").Dimensions;
|
||||||
|
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const GLuint = gl.GLuint;
|
const GLuint = gl.GLuint;
|
||||||
|
@ -66,8 +67,10 @@ pub const State = struct {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn draw(state: *State, tex_id: GLuint, cpu: *Arm7tdmi) void {
|
pub fn draw(state: *State, win_dim: Dimensions, tex_id: GLuint, cpu: *Arm7tdmi) bool {
|
||||||
const win_scale = config.config().host.win_scale;
|
const scn_scale = config.config().host.win_scale;
|
||||||
|
|
||||||
|
zgui.backend.newFrame(@intToFloat(f32, win_dim.width), @intToFloat(f32, win_dim.height));
|
||||||
|
|
||||||
{
|
{
|
||||||
_ = zgui.beginMainMenuBar();
|
_ = zgui.beginMainMenuBar();
|
||||||
|
@ -142,8 +145,8 @@ pub fn draw(state: *State, tex_id: GLuint, cpu: *Arm7tdmi) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const w = @intToFloat(f32, gba_width * win_scale);
|
const w = @intToFloat(f32, gba_width * scn_scale);
|
||||||
const h = @intToFloat(f32, gba_height * win_scale);
|
const h = @intToFloat(f32, gba_height * scn_scale);
|
||||||
|
|
||||||
const window_title = std.mem.sliceTo(&state.title, 0);
|
const window_title = std.mem.sliceTo(&state.title, 0);
|
||||||
_ = zgui.begin(window_title, .{ .flags = .{ .no_resize = true, .always_auto_resize = true } });
|
_ = zgui.begin(window_title, .{ .flags = .{ .no_resize = true, .always_auto_resize = true } });
|
||||||
|
@ -318,6 +321,8 @@ pub fn draw(state: *State, tex_id: GLuint, cpu: *Arm7tdmi) void {
|
||||||
{
|
{
|
||||||
zgui.showDemoWindow(null);
|
zgui.showDemoWindow(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true; // request redraw
|
||||||
}
|
}
|
||||||
|
|
||||||
const widgets = struct {
|
const widgets = struct {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const GLsizei = gl.GLsizei;
|
||||||
const SDL_GLContext = *anyopaque;
|
const SDL_GLContext = *anyopaque;
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
|
|
||||||
const Dimensions = struct { width: u32, height: u32 };
|
pub const Dimensions = struct { width: u32, height: u32 };
|
||||||
const default_dim: Dimensions = .{ .width = 1280, .height = 720 };
|
const default_dim: Dimensions = .{ .width = 1280, .height = 720 };
|
||||||
|
|
||||||
pub const sample_rate = 1 << 15;
|
pub const sample_rate = 1 << 15;
|
||||||
|
@ -187,7 +187,7 @@ pub const Gui = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zgui.backend.newFrame(@intToFloat(f32, win_dim.width), @intToFloat(f32, win_dim.height));
|
var zgui_redraw: bool = false;
|
||||||
|
|
||||||
switch (self.state.emulation) {
|
switch (self.state.emulation) {
|
||||||
.Transition => |inner| switch (inner) {
|
.Transition => |inner| switch (inner) {
|
||||||
|
@ -249,11 +249,12 @@ pub const Gui = struct {
|
||||||
opengl_impl.drawScreenTexture(emu_tex, prog_id, objects, buf);
|
opengl_impl.drawScreenTexture(emu_tex, prog_id, objects, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
imgui.draw(&self.state, out_tex, cpu);
|
zgui_redraw = imgui.draw(&self.state, win_dim, out_tex, cpu);
|
||||||
},
|
},
|
||||||
.Inactive => imgui.draw(&self.state, out_tex, cpu),
|
.Inactive => zgui_redraw = imgui.draw(&self.state, win_dim, out_tex, cpu),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (zgui_redraw) {
|
||||||
// Background Colour
|
// Background Colour
|
||||||
const size = zgui.io.getDisplaySize();
|
const size = zgui.io.getDisplaySize();
|
||||||
gl.viewport(0, 0, @floatToInt(GLsizei, size[0]), @floatToInt(GLsizei, size[1]));
|
gl.viewport(0, 0, @floatToInt(GLsizei, size[0]), @floatToInt(GLsizei, size[1]));
|
||||||
|
@ -261,6 +262,7 @@ pub const Gui = struct {
|
||||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
zgui.backend.draw();
|
zgui.backend.draw();
|
||||||
|
}
|
||||||
|
|
||||||
SDL.SDL_GL_SwapWindow(self.window);
|
SDL.SDL_GL_SwapWindow(self.window);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue