opengl: Unexport consts

This commit is contained in:
Hajime Hoshi 2018-10-30 22:41:05 +09:00
parent 99594fe732
commit 23a832c0a7
5 changed files with 45 additions and 45 deletions

View File

@ -26,12 +26,12 @@ var (
) )
var ( var (
VertexShader shaderType vertexShader shaderType
FragmentShader shaderType fragmentShader shaderType
ArrayBuffer bufferType arrayBuffer bufferType
ElementArrayBuffer bufferType elementArrayBuffer bufferType
DynamicDraw bufferUsage dynamicDraw bufferUsage
StaticDraw bufferUsage staticDraw bufferUsage
Short DataType Short DataType
Float DataType Float DataType

View File

@ -55,11 +55,11 @@ func getProgramID(p program) programID {
} }
func init() { func init() {
VertexShader = gl.VERTEX_SHADER vertexShader = gl.VERTEX_SHADER
FragmentShader = gl.FRAGMENT_SHADER fragmentShader = gl.FRAGMENT_SHADER
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
@ -450,8 +450,8 @@ func (c *Context) newArrayBuffer(size int) buffer {
_ = c.runOnContextThread(func() error { _ = c.runOnContextThread(func() error {
var b uint32 var b uint32
gl.GenBuffers(1, &b) gl.GenBuffers(1, &b)
gl.BindBuffer(uint32(ArrayBuffer), b) gl.BindBuffer(uint32(arrayBuffer), b)
gl.BufferData(uint32(ArrayBuffer), size, nil, uint32(DynamicDraw)) gl.BufferData(uint32(arrayBuffer), size, nil, uint32(dynamicDraw))
bf = buffer(b) bf = buffer(b)
return nil return nil
}) })
@ -463,8 +463,8 @@ func (c *Context) newElementArrayBuffer(size int) buffer {
_ = c.runOnContextThread(func() error { _ = c.runOnContextThread(func() error {
var b uint32 var b uint32
gl.GenBuffers(1, &b) gl.GenBuffers(1, &b)
gl.BindBuffer(uint32(ElementArrayBuffer), b) gl.BindBuffer(uint32(elementArrayBuffer), b)
gl.BufferData(uint32(ElementArrayBuffer), size, nil, uint32(DynamicDraw)) gl.BufferData(uint32(elementArrayBuffer), size, nil, uint32(dynamicDraw))
bf = buffer(b) bf = buffer(b)
return nil return nil
}) })
@ -480,14 +480,14 @@ func (c *Context) BindBuffer(bufferType bufferType, b buffer) {
func (c *Context) ArrayBufferSubData(data []float32) { func (c *Context) ArrayBufferSubData(data []float32) {
_ = c.runOnContextThread(func() error { _ = c.runOnContextThread(func() error {
gl.BufferSubData(uint32(ArrayBuffer), 0, len(data)*4, gl.Ptr(data)) gl.BufferSubData(uint32(arrayBuffer), 0, len(data)*4, gl.Ptr(data))
return nil return nil
}) })
} }
func (c *Context) ElementArrayBufferSubData(data []uint16) { func (c *Context) ElementArrayBufferSubData(data []uint16) {
_ = c.runOnContextThread(func() error { _ = c.runOnContextThread(func() error {
gl.BufferSubData(uint32(ElementArrayBuffer), 0, len(data)*2, gl.Ptr(data)) gl.BufferSubData(uint32(elementArrayBuffer), 0, len(data)*2, gl.Ptr(data))
return nil return nil
}) })
} }

View File

@ -73,11 +73,11 @@ var (
func init() { func init() {
// Accessing the prototype is rquired on Safari. // Accessing the prototype is rquired on Safari.
c := js.Global().Get("WebGLRenderingContext").Get("prototype") c := js.Global().Get("WebGLRenderingContext").Get("prototype")
VertexShader = shaderType(c.Get("VERTEX_SHADER").Int()) vertexShader = shaderType(c.Get("VERTEX_SHADER").Int())
FragmentShader = shaderType(c.Get("FRAGMENT_SHADER").Int()) fragmentShader = shaderType(c.Get("FRAGMENT_SHADER").Int())
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())
@ -407,16 +407,16 @@ func (c *Context) disableVertexAttribArray(p program, location string) {
func (c *Context) newArrayBuffer(size int) buffer { func (c *Context) newArrayBuffer(size int) buffer {
gl := c.gl gl := c.gl
b := gl.Call("createBuffer") b := gl.Call("createBuffer")
gl.Call("bindBuffer", int(ArrayBuffer), js.Value(b)) gl.Call("bindBuffer", int(arrayBuffer), js.Value(b))
gl.Call("bufferData", int(ArrayBuffer), size, int(DynamicDraw)) gl.Call("bufferData", int(arrayBuffer), size, int(dynamicDraw))
return buffer(b) return buffer(b)
} }
func (c *Context) newElementArrayBuffer(size int) buffer { func (c *Context) newElementArrayBuffer(size int) buffer {
gl := c.gl gl := c.gl
b := gl.Call("createBuffer") b := gl.Call("createBuffer")
gl.Call("bindBuffer", int(ElementArrayBuffer), js.Value(b)) gl.Call("bindBuffer", int(elementArrayBuffer), js.Value(b))
gl.Call("bufferData", int(ElementArrayBuffer), size, int(DynamicDraw)) gl.Call("bufferData", int(elementArrayBuffer), size, int(dynamicDraw))
return buffer(b) return buffer(b)
} }
@ -428,14 +428,14 @@ func (c *Context) BindBuffer(bufferType bufferType, b buffer) {
func (c *Context) ArrayBufferSubData(data []float32) { func (c *Context) ArrayBufferSubData(data []float32) {
gl := c.gl gl := c.gl
arr := js.TypedArrayOf(data) arr := js.TypedArrayOf(data)
gl.Call("bufferSubData", int(ArrayBuffer), 0, arr) gl.Call("bufferSubData", int(arrayBuffer), 0, arr)
arr.Release() arr.Release()
} }
func (c *Context) ElementArrayBufferSubData(data []uint16) { func (c *Context) ElementArrayBufferSubData(data []uint16) {
gl := c.gl gl := c.gl
arr := js.TypedArrayOf(data) arr := js.TypedArrayOf(data)
gl.Call("bufferSubData", int(ElementArrayBuffer), 0, arr) gl.Call("bufferSubData", int(elementArrayBuffer), 0, arr)
arr.Release() arr.Release()
} }

View File

@ -52,11 +52,11 @@ func getProgramID(p program) programID {
} }
func init() { func init() {
VertexShader = mgl.VERTEX_SHADER vertexShader = mgl.VERTEX_SHADER
FragmentShader = mgl.FRAGMENT_SHADER fragmentShader = mgl.FRAGMENT_SHADER
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
@ -356,16 +356,16 @@ func (c *Context) disableVertexAttribArray(p program, location string) {
func (c *Context) newArrayBuffer(size int) buffer { func (c *Context) newArrayBuffer(size int) buffer {
gl := c.gl gl := c.gl
b := gl.CreateBuffer() b := gl.CreateBuffer()
gl.BindBuffer(mgl.Enum(ArrayBuffer), b) gl.BindBuffer(mgl.Enum(arrayBuffer), b)
gl.BufferInit(mgl.Enum(ArrayBuffer), size, mgl.Enum(DynamicDraw)) gl.BufferInit(mgl.Enum(arrayBuffer), size, mgl.Enum(dynamicDraw))
return buffer(b) return buffer(b)
} }
func (c *Context) newElementArrayBuffer(size int) buffer { func (c *Context) newElementArrayBuffer(size int) buffer {
gl := c.gl gl := c.gl
b := gl.CreateBuffer() b := gl.CreateBuffer()
gl.BindBuffer(mgl.Enum(ElementArrayBuffer), b) gl.BindBuffer(mgl.Enum(elementArrayBuffer), b)
gl.BufferInit(mgl.Enum(ElementArrayBuffer), size, mgl.Enum(DynamicDraw)) gl.BufferInit(mgl.Enum(elementArrayBuffer), size, mgl.Enum(dynamicDraw))
return buffer(b) return buffer(b)
} }
@ -376,12 +376,12 @@ func (c *Context) BindBuffer(bufferType bufferType, b buffer) {
func (c *Context) ArrayBufferSubData(data []float32) { func (c *Context) ArrayBufferSubData(data []float32) {
gl := c.gl gl := c.gl
gl.BufferSubData(mgl.Enum(ArrayBuffer), 0, float32sToBytes(data)) gl.BufferSubData(mgl.Enum(arrayBuffer), 0, float32sToBytes(data))
} }
func (c *Context) ElementArrayBufferSubData(data []uint16) { func (c *Context) ElementArrayBufferSubData(data []uint16) {
gl := c.gl gl := c.gl
gl.BufferSubData(mgl.Enum(ElementArrayBuffer), 0, uint16sToBytes(data)) gl.BufferSubData(mgl.Enum(elementArrayBuffer), 0, uint16sToBytes(data))
} }
func (c *Context) deleteBuffer(b buffer) { func (c *Context) deleteBuffer(b buffer) {

View File

@ -189,25 +189,25 @@ func (s *openGLState) reset() error {
} }
} }
shaderVertexModelviewNative, err := GetContext().newShader(VertexShader, shaderStr(shaderVertexModelview)) shaderVertexModelviewNative, err := GetContext().newShader(vertexShader, shaderStr(shaderVertexModelview))
if err != nil { if err != nil {
panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err)) panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err))
} }
defer GetContext().deleteShader(shaderVertexModelviewNative) defer GetContext().deleteShader(shaderVertexModelviewNative)
shaderFragmentNearestNative, err := GetContext().newShader(FragmentShader, shaderStr(shaderFragmentNearest)) shaderFragmentNearestNative, err := GetContext().newShader(fragmentShader, shaderStr(shaderFragmentNearest))
if err != nil { if err != nil {
panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err)) panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err))
} }
defer GetContext().deleteShader(shaderFragmentNearestNative) defer GetContext().deleteShader(shaderFragmentNearestNative)
shaderFragmentLinearNative, err := GetContext().newShader(FragmentShader, shaderStr(shaderFragmentLinear)) shaderFragmentLinearNative, err := GetContext().newShader(fragmentShader, shaderStr(shaderFragmentLinear))
if err != nil { if err != nil {
panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err)) panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err))
} }
defer GetContext().deleteShader(shaderFragmentLinearNative) defer GetContext().deleteShader(shaderFragmentLinearNative)
shaderFragmentScreenNative, err := GetContext().newShader(FragmentShader, shaderStr(shaderFragmentScreen)) shaderFragmentScreenNative, err := GetContext().newShader(fragmentShader, shaderStr(shaderFragmentScreen))
if err != nil { if err != nil {
panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err)) panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err))
} }
@ -288,8 +288,8 @@ func (s *openGLState) useProgram(proj []float32, texture Texture, dstW, dstH, sr
theArrayBufferLayout.enable(program) theArrayBufferLayout.enable(program)
if s.lastProgram == zeroProgram { if s.lastProgram == zeroProgram {
c.BindBuffer(ArrayBuffer, s.arrayBuffer) c.BindBuffer(arrayBuffer, s.arrayBuffer)
c.BindBuffer(ElementArrayBuffer, s.elementArrayBuffer) c.BindBuffer(elementArrayBuffer, s.elementArrayBuffer)
c.uniformInt(program, "texture", 0) c.uniformInt(program, "texture", 0)
} }