mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-12 22:17:26 +01:00
Add gl.go
This commit is contained in:
parent
41eb300065
commit
738c06c28d
@ -1,10 +1,5 @@
|
|||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
// #cgo LDFLAGS: -framework OpenGL
|
|
||||||
//
|
|
||||||
// #include <stdlib.h>
|
|
||||||
// #include <OpenGL/gl.h>
|
|
||||||
import "C"
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/go-ebiten/graphics"
|
"github.com/hajimehoshi/go-ebiten/graphics"
|
||||||
"github.com/hajimehoshi/go-ebiten/graphics/matrix"
|
"github.com/hajimehoshi/go-ebiten/graphics/matrix"
|
||||||
@ -38,6 +33,8 @@ func newContext(ids *ids, screenWidth, screenHeight, screenScale int) *Context {
|
|||||||
context.ResetOffscreen()
|
context.ResetOffscreen()
|
||||||
context.Clear()
|
context.Clear()
|
||||||
|
|
||||||
|
enableAlphaBlending()
|
||||||
|
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,9 +44,6 @@ func (context *Context) Dispose() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (context *Context) update(draw func(graphics.Context)) {
|
func (context *Context) update(draw func(graphics.Context)) {
|
||||||
C.glEnable(C.GL_TEXTURE_2D)
|
|
||||||
C.glEnable(C.GL_BLEND)
|
|
||||||
|
|
||||||
context.ResetOffscreen()
|
context.ResetOffscreen()
|
||||||
context.Clear()
|
context.Clear()
|
||||||
|
|
||||||
@ -63,7 +57,8 @@ func (context *Context) update(draw func(graphics.Context)) {
|
|||||||
geometryMatrix.Scale(scale, scale)
|
geometryMatrix.Scale(scale, scale)
|
||||||
context.DrawRenderTarget(context.screenId,
|
context.DrawRenderTarget(context.screenId,
|
||||||
geometryMatrix, matrix.IdentityColor())
|
geometryMatrix, matrix.IdentityColor())
|
||||||
C.glFlush()
|
|
||||||
|
flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (context *Context) Clear() {
|
func (context *Context) Clear() {
|
||||||
|
16
graphics/opengl/gl.go
Normal file
16
graphics/opengl/gl.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
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