Refactoring #3
@@ -1 +1,2 @@
|
||||
build
|
||||
imgui.ini
|
||||
|
||||
+18
-15
@@ -614,6 +614,10 @@ func main() {
|
||||
sdl.SetWindowFullscreen(windowHandler, true)
|
||||
}
|
||||
var (
|
||||
displayedVideoWidth uint32
|
||||
displayedVideoHeight uint32
|
||||
displayedVideoStride uint32
|
||||
|
||||
fps float64
|
||||
lastIndex uint64
|
||||
dropped uint64
|
||||
@@ -692,6 +696,9 @@ func main() {
|
||||
}
|
||||
|
||||
shownIndex = pendingFrame.Frame.Index
|
||||
displayedVideoWidth = pendingFrame.Frame.Width
|
||||
displayedVideoHeight = pendingFrame.Frame.Height
|
||||
displayedVideoStride = pendingFrame.Frame.Stride
|
||||
hasFrame = true
|
||||
} else if frameErr != nil &&
|
||||
!errors.Is(frameErr, context.DeadlineExceeded) &&
|
||||
@@ -731,14 +738,12 @@ func main() {
|
||||
cimgui.Text(fmt.Sprintf("FPS: %.1f", fps))
|
||||
cimgui.Text(fmt.Sprintf("Dropped: %d", dropped))
|
||||
cimgui.Text(fmt.Sprintf("Index: %d", shownIndex))
|
||||
if videoSrc != nil {
|
||||
cimgui.Text(fmt.Sprintf("Video: %dx%d %.2fp", videoSrc.Width(), videoSrc.Height(),
|
||||
float32(videoSrc.Rate().Num/videoSrc.Rate().Den)))
|
||||
}
|
||||
if syncSrc != nil {
|
||||
cimgui.Text(fmt.Sprintf("Video: %dx%d %.2fp", syncSrc.Width(), syncSrc.Height(),
|
||||
float32(syncSrc.Rate().Num/syncSrc.Rate().Den)))
|
||||
cimgui.Text(fmt.Sprintf("Audio: %dch %dkHz", syncSrc.Channels(), syncSrc.AudioRate().Num))
|
||||
if displayedVideoWidth != 0 && displayedVideoHeight != 0 {
|
||||
cimgui.Text(fmt.Sprintf(
|
||||
"Video: %dx%d",
|
||||
displayedVideoWidth,
|
||||
displayedVideoHeight,
|
||||
))
|
||||
}
|
||||
cimgui.Text("\nPress F1 to hide stats")
|
||||
cimgui.Text("Q or Esc to quit")
|
||||
@@ -757,13 +762,11 @@ func main() {
|
||||
gui.EndFrame()
|
||||
lastFrame = time.Now()
|
||||
// end of test widget
|
||||
var w, h, stride uint32
|
||||
if syncSrc != nil {
|
||||
w, h, stride = syncSrc.Width(), syncSrc.Height(), syncSrc.Stride()
|
||||
} else if videoSrc != nil {
|
||||
w, h, stride = videoSrc.Width(), videoSrc.Height(), videoSrc.Stride()
|
||||
}
|
||||
err := r.DrawFrame(w, h, stride)
|
||||
err := r.DrawFrame(
|
||||
displayedVideoWidth,
|
||||
displayedVideoHeight,
|
||||
displayedVideoStride,
|
||||
)
|
||||
if errors.Is(err, renderer.ErrOutOfDate) {
|
||||
if rerr := r.RecreateSwapchain(); rerr != nil {
|
||||
if errors.Is(rerr, renderer.ErrMinimized) {
|
||||
|
||||
Reference in New Issue
Block a user