mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
Remove gl.go
This commit is contained in:
parent
de7d980289
commit
26122aa120
@ -34,7 +34,11 @@ func NewTextures(textureFactory graphics.TextureFactory) *Textures {
|
|||||||
textures: map[string]graphics.TextureId{},
|
textures: map[string]graphics.TextureId{},
|
||||||
renderTargets: map[string]graphics.RenderTargetId{},
|
renderTargets: map[string]graphics.RenderTargetId{},
|
||||||
}
|
}
|
||||||
go textures.loop()
|
go func() {
|
||||||
|
for {
|
||||||
|
textures.loopMain()
|
||||||
|
}
|
||||||
|
}()
|
||||||
return textures
|
return textures
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,43 +56,41 @@ func loadImage(path string) (image.Image, error) {
|
|||||||
return img, nil
|
return img, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Textures) loop() {
|
func (t *Textures) loopMain() {
|
||||||
for {
|
select {
|
||||||
select {
|
case p := <-t.texturePaths:
|
||||||
case p := <-t.texturePaths:
|
name := p.name
|
||||||
name := p.name
|
path := p.path
|
||||||
path := p.path
|
go func() {
|
||||||
go func() {
|
img, err := loadImage(path)
|
||||||
img, err := loadImage(path)
|
if err != nil {
|
||||||
if err != nil {
|
panic(err)
|
||||||
panic(err)
|
}
|
||||||
}
|
id, err := t.textureFactory.CreateTexture(
|
||||||
id, err := t.textureFactory.CreateTexture(
|
img,
|
||||||
img,
|
graphics.FilterNearest)
|
||||||
graphics.FilterNearest)
|
if err != nil {
|
||||||
if err != nil {
|
panic(err)
|
||||||
panic(err)
|
}
|
||||||
}
|
t.Lock()
|
||||||
t.Lock()
|
defer t.Unlock()
|
||||||
defer t.Unlock()
|
t.textures[name] = id
|
||||||
t.textures[name] = id
|
}()
|
||||||
}()
|
case s := <-t.renderTargetSizes:
|
||||||
case s := <-t.renderTargetSizes:
|
name := s.name
|
||||||
name := s.name
|
size := s.size
|
||||||
size := s.size
|
go func() {
|
||||||
go func() {
|
id, err := t.textureFactory.CreateRenderTarget(
|
||||||
id, err := t.textureFactory.CreateRenderTarget(
|
size.Width,
|
||||||
size.Width,
|
size.Height,
|
||||||
size.Height,
|
graphics.FilterNearest)
|
||||||
graphics.FilterNearest)
|
if err != nil {
|
||||||
if err != nil {
|
panic(err)
|
||||||
panic(err)
|
}
|
||||||
}
|
t.Lock()
|
||||||
t.Lock()
|
defer t.Unlock()
|
||||||
defer t.Unlock()
|
t.renderTargets[name] = id
|
||||||
t.renderTargets[name] = id
|
}()
|
||||||
}()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,21 @@ import (
|
|||||||
"github.com/hajimehoshi/go-ebiten/graphics/matrix"
|
"github.com/hajimehoshi/go-ebiten/graphics/matrix"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// #cgo LDFLAGS: -framework OpenGL
|
||||||
|
//
|
||||||
|
// #include <stdlib.h>
|
||||||
|
// #include <OpenGL/gl.h>
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
func enableAlphaBlending() {
|
||||||
|
C.glEnable(C.GL_TEXTURE_2D)
|
||||||
|
C.glEnable(C.GL_BLEND)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flush() {
|
||||||
|
C.glFlush()
|
||||||
|
}
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
screenId graphics.RenderTargetId
|
screenId graphics.RenderTargetId
|
||||||
mainId graphics.RenderTargetId
|
mainId graphics.RenderTargetId
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package opengl
|
|
||||||
|
|
||||||
// #cgo LDFLAGS: -framework OpenGL
|
|
||||||
//
|
|
||||||
// #include <stdlib.h>
|
|
||||||
// #include <OpenGL/gl.h>
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
func enableAlphaBlending() {
|
|
||||||
C.glEnable(C.GL_TEXTURE_2D)
|
|
||||||
C.glEnable(C.GL_BLEND)
|
|
||||||
}
|
|
||||||
|
|
||||||
func flush() {
|
|
||||||
C.glFlush()
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user