Ensure renderer calls aren't virtual

This commit is contained in:
bloeys
2024-05-13 04:57:16 +04:00
parent 5aa0f41085
commit 3795a7123f
5 changed files with 32 additions and 32 deletions

View File

@ -9,7 +9,6 @@ import (
"github.com/bloeys/nmage/assert"
"github.com/bloeys/nmage/assets"
"github.com/bloeys/nmage/input"
"github.com/bloeys/nmage/renderer"
"github.com/bloeys/nmage/timing"
nmageimgui "github.com/bloeys/nmage/ui/imgui"
"github.com/go-gl/gl/v4.1-core/gl"
@ -31,7 +30,6 @@ type Window struct {
SDLWin *sdl.Window
GlCtx sdl.GLContext
EventCallbacks []func(sdl.Event)
Rend renderer.Render
}
func (w *Window) handleInputs() {
@ -170,22 +168,21 @@ func initSDL() error {
return nil
}
func CreateOpenGLWindow(title string, x, y, width, height int32, flags WindowFlags, rend renderer.Render) (Window, error) {
return createWindow(title, x, y, width, height, WindowFlags_OPENGL|flags, rend)
func CreateOpenGLWindow(title string, x, y, width, height int32, flags WindowFlags) (Window, error) {
return createWindow(title, x, y, width, height, WindowFlags_OPENGL|flags)
}
func CreateOpenGLWindowCentered(title string, width, height int32, flags WindowFlags, rend renderer.Render) (Window, error) {
return createWindow(title, sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, width, height, WindowFlags_OPENGL|flags, rend)
func CreateOpenGLWindowCentered(title string, width, height int32, flags WindowFlags) (Window, error) {
return createWindow(title, sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, width, height, WindowFlags_OPENGL|flags)
}
func createWindow(title string, x, y, width, height int32, flags WindowFlags, rend renderer.Render) (Window, error) {
func createWindow(title string, x, y, width, height int32, flags WindowFlags) (Window, error) {
assert.T(isInited, "engine.Init() was not called!")
win := Window{
SDLWin: nil,
EventCallbacks: make([]func(sdl.Event), 0),
Rend: rend,
}
var err error

View File

@ -1,6 +1,7 @@
package engine
import (
"github.com/bloeys/nmage/renderer"
"github.com/bloeys/nmage/timing"
nmageimgui "github.com/bloeys/nmage/ui/imgui"
"github.com/go-gl/gl/v4.1-core/gl"
@ -20,7 +21,7 @@ type Game interface {
DeInit()
}
func Run(g Game, w *Window, ui nmageimgui.ImguiInfo) {
func Run(g Game, w *Window, rend renderer.Render, ui nmageimgui.ImguiInfo) {
isRunning = true
@ -56,7 +57,7 @@ func Run(g Game, w *Window, ui nmageimgui.ImguiInfo) {
w.SDLWin.GLSwap()
g.FrameEnd()
w.Rend.FrameEnd()
rend.FrameEnd()
timing.FrameEnded()
}