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 {
locationCache *locationCache
funcs chan func()
lastCompositeMode CompositeMode
funcs chan func()
}
func NewContext() (*Context, error) {
@ -70,10 +68,10 @@ func NewContext() (*Context, error) {
dstAlpha: gl.DST_ALPHA,
oneMinusSrcAlpha: gl.ONE_MINUS_SRC_ALPHA,
oneMinusDstAlpha: gl.ONE_MINUS_DST_ALPHA,
locationCache: newLocationCache(),
lastCompositeMode: CompositeModeUnknown,
}
c.locationCache = newLocationCache()
c.funcs = make(chan func())
c.lastCompositeMode = CompositeModeUnknown
return c, nil
}

View File

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

View File

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

View File

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