Refactoring

This commit is contained in:
Hajime Hoshi 2013-10-27 23:11:26 +09:00
parent e90f6d3222
commit d97b7a2999
2 changed files with 5 additions and 13 deletions

View File

@ -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)

View File

@ -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()