mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 19:58:54 +01:00
Refactoring
This commit is contained in:
parent
e90f6d3222
commit
d97b7a2999
@ -38,6 +38,9 @@ func newContext(screenWidth, screenHeight, screenScale int) *Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (context *Context) Init() {
|
func (context *Context) Init() {
|
||||||
|
C.glEnable(C.GL_TEXTURE_2D)
|
||||||
|
C.glEnable(C.GL_BLEND)
|
||||||
|
|
||||||
// The main framebuffer should be created sooner than any other
|
// The main framebuffer should be created sooner than any other
|
||||||
// framebuffers!
|
// framebuffers!
|
||||||
mainFramebuffer := C.GLint(0)
|
mainFramebuffer := C.GLint(0)
|
||||||
@ -119,7 +122,6 @@ func (context *Context) setOffscreen(rt *grendertarget.RenderTarget) {
|
|||||||
panic(fmt.Sprintf("glBindFramebuffer failed: %d", err))
|
panic(fmt.Sprintf("glBindFramebuffer failed: %d", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
C.glEnable(C.GL_BLEND)
|
|
||||||
C.glBlendFuncSeparate(C.GL_SRC_ALPHA, C.GL_ONE_MINUS_SRC_ALPHA,
|
C.glBlendFuncSeparate(C.GL_SRC_ALPHA, C.GL_ONE_MINUS_SRC_ALPHA,
|
||||||
C.GL_ZERO, C.GL_ONE)
|
C.GL_ZERO, C.GL_ONE)
|
||||||
|
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
// #cgo LDFLAGS: -framework OpenGL
|
|
||||||
//
|
|
||||||
// #include <OpenGL/gl.h>
|
|
||||||
// #include <stdlib.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"
|
||||||
@ -31,7 +26,6 @@ func (device *Device) Init() {
|
|||||||
|
|
||||||
func (device *Device) Update(draw func(graphics.Context)) {
|
func (device *Device) Update(draw func(graphics.Context)) {
|
||||||
context := device.context
|
context := device.context
|
||||||
C.glEnable(C.GL_TEXTURE_2D)
|
|
||||||
context.ResetOffscreen()
|
context.ResetOffscreen()
|
||||||
context.Clear()
|
context.Clear()
|
||||||
|
|
||||||
@ -42,12 +36,8 @@ func (device *Device) Update(draw func(graphics.Context)) {
|
|||||||
context.Clear()
|
context.Clear()
|
||||||
|
|
||||||
scale := float64(context.screenScale)
|
scale := float64(context.screenScale)
|
||||||
geometryMatrix := matrix.Geometry{
|
geometryMatrix := matrix.IdentityGeometry()
|
||||||
[2][3]float64{
|
geometryMatrix.Scale(scale, scale)
|
||||||
{scale, 0, 0},
|
|
||||||
{0, scale, 0},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
context.DrawTexture(context.ToTexture(context.screenId),
|
context.DrawTexture(context.ToTexture(context.screenId),
|
||||||
geometryMatrix, matrix.IdentityColor())
|
geometryMatrix, matrix.IdentityColor())
|
||||||
context.flush()
|
context.flush()
|
||||||
|
Loading…
Reference in New Issue
Block a user