mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
Add package internal/opengl
This commit is contained in:
parent
450a8da267
commit
efb759d23c
@ -24,11 +24,3 @@ const (
|
||||
FilterNearest Filter = gl.NEAREST
|
||||
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"
|
||||
glfw "github.com/go-gl/glfw3"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||
"image"
|
||||
"runtime"
|
||||
)
|
||||
@ -47,7 +48,7 @@ func init() {
|
||||
}
|
||||
currentUI.run()
|
||||
currentUI.use(func() {
|
||||
graphics.Init()
|
||||
currentUI.glContext = opengl.NewContext()
|
||||
glfw.SwapInterval(1)
|
||||
})
|
||||
}
|
||||
@ -55,6 +56,7 @@ func init() {
|
||||
type ui struct {
|
||||
window *glfw.Window
|
||||
scale int
|
||||
glContext *opengl.Context
|
||||
graphicsContext *graphicsContext
|
||||
input input
|
||||
funcs chan func()
|
||||
|
Loading…
Reference in New Issue
Block a user