mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +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() {
|
||||
C.glEnable(C.GL_TEXTURE_2D)
|
||||
C.glEnable(C.GL_BLEND)
|
||||
|
||||
// The main framebuffer should be created sooner than any other
|
||||
// framebuffers!
|
||||
mainFramebuffer := C.GLint(0)
|
||||
@ -119,7 +122,6 @@ func (context *Context) setOffscreen(rt *grendertarget.RenderTarget) {
|
||||
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.GL_ZERO, C.GL_ONE)
|
||||
|
||||
|
@ -1,10 +1,5 @@
|
||||
package opengl
|
||||
|
||||
// #cgo LDFLAGS: -framework OpenGL
|
||||
//
|
||||
// #include <OpenGL/gl.h>
|
||||
// #include <stdlib.h>
|
||||
import "C"
|
||||
import (
|
||||
"github.com/hajimehoshi/go-ebiten/graphics"
|
||||
"github.com/hajimehoshi/go-ebiten/graphics/matrix"
|
||||
@ -31,7 +26,6 @@ func (device *Device) Init() {
|
||||
|
||||
func (device *Device) Update(draw func(graphics.Context)) {
|
||||
context := device.context
|
||||
C.glEnable(C.GL_TEXTURE_2D)
|
||||
context.ResetOffscreen()
|
||||
context.Clear()
|
||||
|
||||
@ -42,12 +36,8 @@ func (device *Device) Update(draw func(graphics.Context)) {
|
||||
context.Clear()
|
||||
|
||||
scale := float64(context.screenScale)
|
||||
geometryMatrix := matrix.Geometry{
|
||||
[2][3]float64{
|
||||
{scale, 0, 0},
|
||||
{0, scale, 0},
|
||||
},
|
||||
}
|
||||
geometryMatrix := matrix.IdentityGeometry()
|
||||
geometryMatrix.Scale(scale, scale)
|
||||
context.DrawTexture(context.ToTexture(context.screenId),
|
||||
geometryMatrix, matrix.IdentityColor())
|
||||
context.flush()
|
||||
|
Loading…
Reference in New Issue
Block a user