Add multi monitor multiplayer
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
||||
func profileSection(section func()) uint64 {
|
||||
start := sdl.GetTicks64()
|
||||
section()
|
||||
end := sdl.GetTicks64()
|
||||
return end - start
|
||||
}
|
||||
|
||||
func logProfilingInfo(handleEventsTime, renderTime, scaleTime, frameTime, frameCount uint64) {
|
||||
floatFrame := float64(frameCount)
|
||||
fmt.Printf("Average handleEvents time: %f ms\n", float64(handleEventsTime)/floatFrame)
|
||||
fmt.Printf("Average render time: %f ms\n", float64(renderTime)/floatFrame)
|
||||
fmt.Printf("Average scaling time: %f ms\n", float64(scaleTime)/floatFrame)
|
||||
fmt.Printf("Average frame time: %f ms\n", float64(frameTime)/floatFrame)
|
||||
fmt.Print("\n")
|
||||
}
|
||||
|
||||
func resetProfilingCounters(handleEventsTime, renderTime, scaleTime, frameTime *uint64, frameCount *uint64) {
|
||||
*handleEventsTime = 0
|
||||
*renderTime = 0
|
||||
*scaleTime = 0
|
||||
*frameTime = 0
|
||||
*frameCount = 0
|
||||
}
|
||||
|
||||
func enforceFrameRate(frameStart uint64, targetFPS int) {
|
||||
frameDuration := 1000 / targetFPS
|
||||
elapsed := sdl.GetTicks64() - frameStart
|
||||
if delay := frameDuration - int(elapsed); delay > 0 {
|
||||
sdl.Delay(uint32(delay))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user