mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
internal/graphicsdriver/opengl: refactoring: hide SetGLFWClientAPI
Updates #2714
This commit is contained in:
parent
f6f0cf05e6
commit
4ef7b5c166
@ -38,36 +38,13 @@ func NewGraphics() (graphicsdriver.Graphics, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
setGLFWClientAPI(ctx.IsES())
|
||||
|
||||
return newGraphics(ctx), nil
|
||||
}
|
||||
|
||||
func (g *Graphics) makeContextCurrent() {
|
||||
// TODO: Implement this (#2714).
|
||||
}
|
||||
|
||||
func (g *Graphics) swapBuffers() error {
|
||||
// Call SwapIntervals even though vsync is not changed.
|
||||
// When toggling to fullscreen, vsync state might be reset unexpectedly (#1787).
|
||||
|
||||
// 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).
|
||||
if g.vsync {
|
||||
if err := glfw.SwapInterval(1); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := glfw.SwapInterval(0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Implement this (#2714).
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Graphics) SetGLFWClientAPI() error {
|
||||
if g.context.ctx.IsES() {
|
||||
func setGLFWClientAPI(isES bool) error {
|
||||
if isES {
|
||||
if err := glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLESAPI); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -103,3 +80,28 @@ func (g *Graphics) SetGLFWClientAPI() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Graphics) makeContextCurrent() {
|
||||
// TODO: Implement this (#2714).
|
||||
}
|
||||
|
||||
func (g *Graphics) swapBuffers() error {
|
||||
// Call SwapIntervals even though vsync is not changed.
|
||||
// When toggling to fullscreen, vsync state might be reset unexpectedly (#1787).
|
||||
|
||||
// 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).
|
||||
if g.vsync {
|
||||
if err := glfw.SwapInterval(1); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := glfw.SwapInterval(0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Implement this (#2714).
|
||||
return nil
|
||||
}
|
||||
|
@ -1106,11 +1106,7 @@ func (u *UserInterface) initOnMainThread(options *RunOptions) error {
|
||||
u.setGraphicsLibrary(lib)
|
||||
u.graphicsDriver.SetTransparent(options.ScreenTransparent)
|
||||
|
||||
if u.GraphicsLibrary() == GraphicsLibraryOpenGL {
|
||||
if err := u.graphicsDriver.(interface{ SetGLFWClientAPI() error }).SetGLFWClientAPI(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if u.GraphicsLibrary() != GraphicsLibraryOpenGL {
|
||||
if err := glfw.WindowHint(glfw.ClientAPI, glfw.NoAPI); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user