mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
Add package internal/opengl
This commit is contained in:
parent
450a8da267
commit
efb759d23c
@ -24,11 +24,3 @@ const (
|
|||||||
FilterNearest Filter = gl.NEAREST
|
FilterNearest Filter = gl.NEAREST
|
||||||
FilterLinear = gl.LINEAR
|
FilterLinear = gl.LINEAR
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
|
||||||
gl.Init()
|
|
||||||
gl.Enable(gl.TEXTURE_2D)
|
|
||||||
// Textures' pixel formats are alpha premultiplied.
|
|
||||||
gl.Enable(gl.BLEND)
|
|
||||||
gl.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)
|
|
||||||
}
|
|
||||||
|
36
internal/opengl/context.go
Normal file
36
internal/opengl/context.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright 2014 Hajime Hoshi
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package opengl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-gl/gl"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Context struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewContext() *Context {
|
||||||
|
c := &Context{}
|
||||||
|
c.init()
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Context) init() {
|
||||||
|
gl.Init()
|
||||||
|
gl.Enable(gl.TEXTURE_2D)
|
||||||
|
// Textures' pixel formats are alpha premultiplied.
|
||||||
|
gl.Enable(gl.BLEND)
|
||||||
|
gl.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)
|
||||||
|
}
|
4
ui.go
4
ui.go
@ -18,6 +18,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
glfw "github.com/go-gl/glfw3"
|
glfw "github.com/go-gl/glfw3"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||||
"image"
|
"image"
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
@ -47,7 +48,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
currentUI.run()
|
currentUI.run()
|
||||||
currentUI.use(func() {
|
currentUI.use(func() {
|
||||||
graphics.Init()
|
currentUI.glContext = opengl.NewContext()
|
||||||
glfw.SwapInterval(1)
|
glfw.SwapInterval(1)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -55,6 +56,7 @@ func init() {
|
|||||||
type ui struct {
|
type ui struct {
|
||||||
window *glfw.Window
|
window *glfw.Window
|
||||||
scale int
|
scale int
|
||||||
|
glContext *opengl.Context
|
||||||
graphicsContext *graphicsContext
|
graphicsContext *graphicsContext
|
||||||
input input
|
input input
|
||||||
funcs chan func()
|
funcs chan func()
|
||||||
|
Loading…
Reference in New Issue
Block a user