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.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.doEnqueueDrawImageCommand(dst, src, len(vertices), len(indices), color, mode, filter, split)

View File

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

View File

@ -61,8 +61,8 @@ func init() {
arrayBuffer = gl.ARRAY_BUFFER
elementArrayBuffer = gl.ELEMENT_ARRAY_BUFFER
dynamicDraw = gl.DYNAMIC_DRAW
Short = gl.SHORT
Float = gl.FLOAT
short = gl.SHORT
float = gl.FLOAT
zero = gl.ZERO
one = gl.ONE
@ -408,7 +408,7 @@ func (c *Context) getAttribLocationImpl(p program, location string) attribLocati
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 {
l := c.locationCache.GetAttribLocation(c, p, location)
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())
elementArrayBuffer = bufferType(c.Get("ELEMENT_ARRAY_BUFFER").Int())
dynamicDraw = bufferUsage(c.Get("DYNAMIC_DRAW").Int())
Short = DataType(c.Get("SHORT").Int())
Float = DataType(c.Get("FLOAT").Int())
short = dataType(c.Get("SHORT").Int())
float = dataType(c.Get("FLOAT").Int())
zero = operation(c.Get("ZERO").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())
}
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()
gl := c.gl
l := c.locationCache.GetAttribLocation(c, p, location)

View File

@ -57,8 +57,8 @@ func init() {
arrayBuffer = mgl.ARRAY_BUFFER
elementArrayBuffer = mgl.ELEMENT_ARRAY_BUFFER
dynamicDraw = mgl.DYNAMIC_DRAW
Short = mgl.SHORT
Float = mgl.FLOAT
short = mgl.SHORT
float = mgl.FLOAT
zero = mgl.ZERO
one = mgl.ONE
@ -332,7 +332,7 @@ func (c *Context) getAttribLocationImpl(p program, location string) attribLocati
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
l := c.locationCache.GetAttribLocation(c, p, location)
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
for _, p := range a.parts {
t += Float.SizeInBytes() * p.num
t += float.SizeInBytes() * p.num
}
a.total = t
return a.total
@ -65,8 +65,8 @@ func (a *arrayBufferLayout) enable(program program) {
total := a.totalBytes()
offset := 0
for _, p := range a.parts {
GetContext().vertexAttribPointer(program, p.name, p.num, Float, total, offset)
offset += Float.SizeInBytes() * p.num
GetContext().vertexAttribPointer(program, p.name, p.num, float, total, offset)
offset += float.SizeInBytes() * p.num
}
}
@ -101,8 +101,8 @@ func initializeArrayBuferLayout() {
}
}
func ArrayBufferLayoutTotalBytes() int {
return theArrayBufferLayout.totalBytes()
func ArrayBufferLayoutFloatNum() int {
return theArrayBufferLayout.totalBytes() / float.SizeInBytes()
}
// openGLState is a state for

View File

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