mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/graphicslibrary: refactoring: remove IsGL and IsDirectX
This commit is contained in:
parent
48054ec9c8
commit
8274b32301
@ -66,5 +66,5 @@ type DebugInfo struct {
|
||||
|
||||
// ReadDebugInfo writes debug info (e.g. current graphics library) into a provided struct.
|
||||
func ReadDebugInfo(d *DebugInfo) {
|
||||
d.GraphicsLibrary = GraphicsLibrary(ui.Get().GetGraphicsLibrary())
|
||||
d.GraphicsLibrary = GraphicsLibrary(ui.Get().GraphicsLibrary())
|
||||
}
|
||||
|
@ -472,14 +472,6 @@ func (g *graphics11) NeedsClearingScreen() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (g *graphics11) IsGL() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (g *graphics11) IsDirectX() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (g *graphics11) MaxImageSize() int {
|
||||
switch g.featureLevel {
|
||||
case _D3D_FEATURE_LEVEL_10_0:
|
||||
|
@ -1063,14 +1063,6 @@ func (g *graphics12) NeedsClearingScreen() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (g *graphics12) IsGL() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (g *graphics12) IsDirectX() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (g *graphics12) MaxImageSize() int {
|
||||
return _D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION
|
||||
}
|
||||
|
@ -42,8 +42,6 @@ type Graphics interface {
|
||||
SetVsyncEnabled(enabled bool)
|
||||
NeedsRestoring() bool
|
||||
NeedsClearingScreen() bool
|
||||
IsGL() bool
|
||||
IsDirectX() bool
|
||||
MaxImageSize() int
|
||||
|
||||
NewShader(program *shaderir.Program) (Shader, error)
|
||||
|
@ -686,14 +686,6 @@ func (g *Graphics) NeedsClearingScreen() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (g *Graphics) IsGL() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (g *Graphics) IsDirectX() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (g *Graphics) MaxImageSize() int {
|
||||
if g.maxImageSize != 0 {
|
||||
return g.maxImageSize
|
||||
|
@ -295,14 +295,6 @@ func (g *Graphics) NeedsClearingScreen() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (g *Graphics) IsGL() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (g *Graphics) IsDirectX() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (g *Graphics) MaxImageSize() int {
|
||||
return g.context.getMaxTextureSize()
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func (c *context) updateFrame(graphicsDriver graphicsdriver.Graphics, outsideWid
|
||||
|
||||
func (c *context) forceUpdateFrame(graphicsDriver graphicsdriver.Graphics, outsideWidth, outsideHeight float64, deviceScaleFactor float64, ui *UserInterface, swapBuffersForGL func()) error {
|
||||
n := 1
|
||||
if graphicsDriver.IsDirectX() {
|
||||
if ui.GraphicsLibrary() == GraphicsLibraryDirectX {
|
||||
// On DirectX, both framebuffers in the swap chain should be updated.
|
||||
// Or, the rendering result becomes unexpected when the window is resized.
|
||||
n = 2
|
||||
|
@ -173,6 +173,6 @@ func (u *UserInterface) setGraphicsLibrary(library GraphicsLibrary) {
|
||||
atomic.StoreInt32(&u.graphicsLibrary, int32(library))
|
||||
}
|
||||
|
||||
func (u *UserInterface) GetGraphicsLibrary() GraphicsLibrary {
|
||||
func (u *UserInterface) GraphicsLibrary() GraphicsLibrary {
|
||||
return GraphicsLibrary(atomic.LoadInt32(&u.graphicsLibrary))
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ func (u *UserInterface) setNativeFullscreen(fullscreen bool) error {
|
||||
}
|
||||
|
||||
func (u *UserInterface) adjustViewSizeAfterFullscreen() error {
|
||||
if u.graphicsDriver.IsGL() {
|
||||
if u.GraphicsLibrary() == GraphicsLibraryOpenGL {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -1137,7 +1137,7 @@ func (u *UserInterface) initOnMainThread(options *RunOptions) error {
|
||||
u.setGraphicsLibrary(lib)
|
||||
u.graphicsDriver.SetTransparent(options.ScreenTransparent)
|
||||
|
||||
if u.graphicsDriver.IsGL() {
|
||||
if u.GraphicsLibrary() == GraphicsLibraryOpenGL {
|
||||
if err := u.graphicsDriver.(interface{ SetGLFWClientAPI() error }).SetGLFWClientAPI(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1427,7 +1427,7 @@ func (u *UserInterface) loopGame() (ferr error) {
|
||||
}()
|
||||
|
||||
u.renderThread.Call(func() {
|
||||
if u.graphicsDriver.IsGL() {
|
||||
if u.GraphicsLibrary() == GraphicsLibraryOpenGL {
|
||||
if err := u.window.MakeContextCurrent(); err != nil {
|
||||
u.setError(err)
|
||||
return
|
||||
@ -1572,7 +1572,7 @@ func (u *UserInterface) updateIconIfNeeded() error {
|
||||
}
|
||||
|
||||
func (u *UserInterface) swapBuffersOnRenderThread() error {
|
||||
if u.graphicsDriver.IsGL() {
|
||||
if u.GraphicsLibrary() == GraphicsLibraryOpenGL {
|
||||
if err := u.window.SwapBuffers(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1876,7 +1876,7 @@ func (u *UserInterface) minimumWindowWidth() (int, error) {
|
||||
}
|
||||
|
||||
func (u *UserInterface) updateVsyncOnRenderThread() error {
|
||||
if u.graphicsDriver.IsGL() {
|
||||
if u.GraphicsLibrary() == GraphicsLibraryOpenGL {
|
||||
// SwapInterval is affected by the current monitor of the window.
|
||||
// This needs to be called at least after SetMonitor.
|
||||
// Without SwapInterval after SetMonitor, vsynch doesn't work (#375).
|
||||
|
@ -77,7 +77,7 @@ func (u *UserInterface) setUIView(uiview uintptr) error {
|
||||
select {
|
||||
case err := <-u.errCh:
|
||||
return err
|
||||
case <-u.graphicsDriverInitCh:
|
||||
case <-u.graphicsLibraryInitCh:
|
||||
}
|
||||
|
||||
// This function should be called only when the graphics library is Metal.
|
||||
@ -91,10 +91,10 @@ func (u *UserInterface) isGL() (bool, error) {
|
||||
select {
|
||||
case err := <-u.errCh:
|
||||
return false, err
|
||||
case <-u.graphicsDriverInitCh:
|
||||
case <-u.graphicsLibraryInitCh:
|
||||
}
|
||||
|
||||
return u.graphicsDriver.IsGL(), nil
|
||||
return u.GraphicsLibrary() == GraphicsLibraryOpenGL, nil
|
||||
}
|
||||
|
||||
func deviceScaleFactorImpl() float64 {
|
||||
|
@ -54,7 +54,7 @@ var (
|
||||
func (u *UserInterface) init() error {
|
||||
u.userInterfaceImpl = userInterfaceImpl{
|
||||
foreground: 1,
|
||||
graphicsDriverInitCh: make(chan struct{}),
|
||||
graphicsLibraryInitCh: make(chan struct{}),
|
||||
errCh: make(chan error),
|
||||
|
||||
// Give a default outside size so that the game can start without initializing them.
|
||||
@ -97,7 +97,7 @@ func (u *UserInterface) Update() error {
|
||||
|
||||
type userInterfaceImpl struct {
|
||||
graphicsDriver graphicsdriver.Graphics
|
||||
graphicsDriverInitCh chan struct{}
|
||||
graphicsLibraryInitCh chan struct{}
|
||||
|
||||
outsideWidth float64
|
||||
outsideHeight float64
|
||||
@ -289,7 +289,7 @@ func (u *UserInterface) run(game Game, mainloop bool, options *RunOptions) (err
|
||||
}
|
||||
u.graphicsDriver = g
|
||||
u.setGraphicsLibrary(lib)
|
||||
close(u.graphicsDriverInitCh)
|
||||
close(u.graphicsLibraryInitCh)
|
||||
|
||||
// If gomobile-build is used, wait for the outside size fixed.
|
||||
if u.setGBuildSizeCh != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user