opengl: Unexport DataType/Float/Short

This commit is contained in:
Hajime Hoshi 2018-11-06 01:55:31 +09:00
parent 82e9f227d1
commit 580cd5cc71
7 changed files with 21 additions and 21 deletions

View File

@ -126,7 +126,7 @@ func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float
q.appendVertices(vertices) q.appendVertices(vertices)
q.appendIndices(indices, uint16(q.nextIndex)) q.appendIndices(indices, uint16(q.nextIndex))
q.nextIndex += len(vertices) * opengl.Float.SizeInBytes() / opengl.ArrayBufferLayoutTotalBytes() q.nextIndex += len(vertices) / opengl.ArrayBufferLayoutFloatNum()
q.tmpNumIndices += len(indices) q.tmpNumIndices += len(indices)
q.doEnqueueDrawImageCommand(dst, src, len(vertices), len(indices), color, mode, filter, split) q.doEnqueueDrawImageCommand(dst, src, len(vertices), len(indices), color, mode, filter, split)

View File

@ -25,8 +25,8 @@ var (
elementArrayBuffer bufferType elementArrayBuffer bufferType
dynamicDraw bufferUsage dynamicDraw bufferUsage
staticDraw bufferUsage staticDraw bufferUsage
Short DataType short dataType
Float DataType float dataType
zero operation zero operation
one operation one operation

View File

@ -61,8 +61,8 @@ func init() {
arrayBuffer = gl.ARRAY_BUFFER arrayBuffer = gl.ARRAY_BUFFER
elementArrayBuffer = gl.ELEMENT_ARRAY_BUFFER elementArrayBuffer = gl.ELEMENT_ARRAY_BUFFER
dynamicDraw = gl.DYNAMIC_DRAW dynamicDraw = gl.DYNAMIC_DRAW
Short = gl.SHORT short = gl.SHORT
Float = gl.FLOAT float = gl.FLOAT
zero = gl.ZERO zero = gl.ZERO
one = gl.ONE one = gl.ONE
@ -408,7 +408,7 @@ func (c *Context) getAttribLocationImpl(p program, location string) attribLocati
return attrib return attrib
} }
func (c *Context) vertexAttribPointer(p program, location string, size int, dataType DataType, stride int, offset int) { func (c *Context) vertexAttribPointer(p program, location string, size int, dataType dataType, stride int, offset int) {
_ = mainthread.Run(func() error { _ = mainthread.Run(func() error {
l := c.locationCache.GetAttribLocation(c, p, location) l := c.locationCache.GetAttribLocation(c, p, location)
gl.VertexAttribPointer(uint32(l), int32(size), uint32(dataType), false, int32(stride), gl.PtrOffset(offset)) gl.VertexAttribPointer(uint32(l), int32(size), uint32(dataType), false, int32(stride), gl.PtrOffset(offset))

View File

@ -78,8 +78,8 @@ func init() {
arrayBuffer = bufferType(c.Get("ARRAY_BUFFER").Int()) arrayBuffer = bufferType(c.Get("ARRAY_BUFFER").Int())
elementArrayBuffer = bufferType(c.Get("ELEMENT_ARRAY_BUFFER").Int()) elementArrayBuffer = bufferType(c.Get("ELEMENT_ARRAY_BUFFER").Int())
dynamicDraw = bufferUsage(c.Get("DYNAMIC_DRAW").Int()) dynamicDraw = bufferUsage(c.Get("DYNAMIC_DRAW").Int())
Short = DataType(c.Get("SHORT").Int()) short = dataType(c.Get("SHORT").Int())
Float = DataType(c.Get("FLOAT").Int()) float = dataType(c.Get("FLOAT").Int())
zero = operation(c.Get("ZERO").Int()) zero = operation(c.Get("ZERO").Int())
one = operation(c.Get("ONE").Int()) one = operation(c.Get("ONE").Int())
@ -410,7 +410,7 @@ func (c *Context) getAttribLocationImpl(p program, location string) attribLocati
return attribLocation(gl.Call("getAttribLocation", p.value, location).Int()) return attribLocation(gl.Call("getAttribLocation", p.value, location).Int())
} }
func (c *Context) vertexAttribPointer(p program, location string, size int, dataType DataType, stride int, offset int) { func (c *Context) vertexAttribPointer(p program, location string, size int, dataType dataType, stride int, offset int) {
c.ensureGL() c.ensureGL()
gl := c.gl gl := c.gl
l := c.locationCache.GetAttribLocation(c, p, location) l := c.locationCache.GetAttribLocation(c, p, location)

View File

@ -57,8 +57,8 @@ func init() {
arrayBuffer = mgl.ARRAY_BUFFER arrayBuffer = mgl.ARRAY_BUFFER
elementArrayBuffer = mgl.ELEMENT_ARRAY_BUFFER elementArrayBuffer = mgl.ELEMENT_ARRAY_BUFFER
dynamicDraw = mgl.DYNAMIC_DRAW dynamicDraw = mgl.DYNAMIC_DRAW
Short = mgl.SHORT short = mgl.SHORT
Float = mgl.FLOAT float = mgl.FLOAT
zero = mgl.ZERO zero = mgl.ZERO
one = mgl.ONE one = mgl.ONE
@ -332,7 +332,7 @@ func (c *Context) getAttribLocationImpl(p program, location string) attribLocati
return a return a
} }
func (c *Context) vertexAttribPointer(p program, location string, size int, dataType DataType, stride int, offset int) { func (c *Context) vertexAttribPointer(p program, location string, size int, dataType dataType, stride int, offset int) {
gl := c.gl gl := c.gl
l := c.locationCache.GetAttribLocation(c, p, location) l := c.locationCache.GetAttribLocation(c, p, location)
gl.VertexAttribPointer(mgl.Attrib(l), size, mgl.Enum(dataType), false, stride, offset) gl.VertexAttribPointer(mgl.Attrib(l), size, mgl.Enum(dataType), false, stride, offset)

View File

@ -46,7 +46,7 @@ func (a *arrayBufferLayout) totalBytes() int {
} }
t := 0 t := 0
for _, p := range a.parts { for _, p := range a.parts {
t += Float.SizeInBytes() * p.num t += float.SizeInBytes() * p.num
} }
a.total = t a.total = t
return a.total return a.total
@ -65,8 +65,8 @@ func (a *arrayBufferLayout) enable(program program) {
total := a.totalBytes() total := a.totalBytes()
offset := 0 offset := 0
for _, p := range a.parts { for _, p := range a.parts {
GetContext().vertexAttribPointer(program, p.name, p.num, Float, total, offset) GetContext().vertexAttribPointer(program, p.name, p.num, float, total, offset)
offset += Float.SizeInBytes() * p.num offset += float.SizeInBytes() * p.num
} }
} }
@ -101,8 +101,8 @@ func initializeArrayBuferLayout() {
} }
} }
func ArrayBufferLayoutTotalBytes() int { func ArrayBufferLayoutFloatNum() int {
return theArrayBufferLayout.totalBytes() return theArrayBufferLayout.totalBytes() / float.SizeInBytes()
} }
// openGLState is a state for // openGLState is a state for

View File

@ -21,13 +21,13 @@ type (
operation int operation int
) )
type DataType int type dataType int
func (d DataType) SizeInBytes() int { func (d dataType) SizeInBytes() int {
switch d { switch d {
case Short: case short:
return 2 return 2
case Float: case float:
return 4 return 4
default: default:
panic("not reached") panic("not reached")