openg: Refactoring

This commit is contained in:
Hajime Hoshi 2016-05-07 19:26:35 +09:00
parent de541bdd7d
commit df23b57b16
4 changed files with 13 additions and 17 deletions

View File

@ -47,9 +47,7 @@ func (p Program) id() programID {
} }
type context struct { type context struct {
locationCache *locationCache funcs chan func()
funcs chan func()
lastCompositeMode CompositeMode
} }
func NewContext() (*Context, error) { func NewContext() (*Context, error) {
@ -70,10 +68,10 @@ func NewContext() (*Context, error) {
dstAlpha: gl.DST_ALPHA, dstAlpha: gl.DST_ALPHA,
oneMinusSrcAlpha: gl.ONE_MINUS_SRC_ALPHA, oneMinusSrcAlpha: gl.ONE_MINUS_SRC_ALPHA,
oneMinusDstAlpha: gl.ONE_MINUS_DST_ALPHA, oneMinusDstAlpha: gl.ONE_MINUS_DST_ALPHA,
locationCache: newLocationCache(),
lastCompositeMode: CompositeModeUnknown,
} }
c.locationCache = newLocationCache()
c.funcs = make(chan func()) c.funcs = make(chan func())
c.lastCompositeMode = CompositeModeUnknown
return c, nil return c, nil
} }

View File

@ -63,11 +63,9 @@ func (p Program) id() programID {
} }
type context struct { type context struct {
gl *webgl.Context gl *webgl.Context
lastFramebuffer Framebuffer lastFramebuffer Framebuffer
locationCache *locationCache lastProgramID programID
lastProgramID programID
lastCompositeMode CompositeMode
} }
func NewContext() (*Context, error) { func NewContext() (*Context, error) {
@ -112,10 +110,10 @@ func NewContext() (*Context, error) {
dstAlpha: operation(gl.DST_ALPHA), dstAlpha: operation(gl.DST_ALPHA),
oneMinusSrcAlpha: operation(gl.ONE_MINUS_SRC_ALPHA), oneMinusSrcAlpha: operation(gl.ONE_MINUS_SRC_ALPHA),
oneMinusDstAlpha: operation(gl.ONE_MINUS_DST_ALPHA), oneMinusDstAlpha: operation(gl.ONE_MINUS_DST_ALPHA),
locationCache: newLocationCache(),
lastCompositeMode: CompositeModeUnknown,
} }
c.gl = gl c.gl = gl
c.locationCache = newLocationCache()
c.lastCompositeMode = CompositeModeUnknown
c.init() c.init()
return c, nil return c, nil
} }

View File

@ -48,9 +48,7 @@ func (p Program) id() programID {
} }
type context struct { type context struct {
gl mgl.Context gl mgl.Context
locationCache *locationCache
lastCompositeMode CompositeMode
} }
func NewContext() *Context { func NewContext() *Context {
@ -65,9 +63,9 @@ func NewContext() *Context {
StaticDraw: mgl.STATIC_DRAW, StaticDraw: mgl.STATIC_DRAW,
Triangles: mgl.TRIANGLES, Triangles: mgl.TRIANGLES,
Lines: mgl.LINES, Lines: mgl.LINES,
locationCache: newLocationCache(),
lastCompositeMode: CompositeModeUnknown,
} }
c.locationCache = newLocationCache()
c.lastCompositeMode = CompositeModeUnknown
return c return c
} }

View File

@ -38,6 +38,8 @@ type Context struct {
dstAlpha operation dstAlpha operation
oneMinusSrcAlpha operation oneMinusSrcAlpha operation
oneMinusDstAlpha operation oneMinusDstAlpha operation
locationCache *locationCache
lastCompositeMode CompositeMode
context context
} }