mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
opengl: Unexport consts
This commit is contained in:
parent
99594fe732
commit
23a832c0a7
@ -26,12 +26,12 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
VertexShader shaderType
|
||||
FragmentShader shaderType
|
||||
ArrayBuffer bufferType
|
||||
ElementArrayBuffer bufferType
|
||||
DynamicDraw bufferUsage
|
||||
StaticDraw bufferUsage
|
||||
vertexShader shaderType
|
||||
fragmentShader shaderType
|
||||
arrayBuffer bufferType
|
||||
elementArrayBuffer bufferType
|
||||
dynamicDraw bufferUsage
|
||||
staticDraw bufferUsage
|
||||
Short DataType
|
||||
Float DataType
|
||||
|
||||
|
@ -55,11 +55,11 @@ func getProgramID(p program) programID {
|
||||
}
|
||||
|
||||
func init() {
|
||||
VertexShader = gl.VERTEX_SHADER
|
||||
FragmentShader = gl.FRAGMENT_SHADER
|
||||
ArrayBuffer = gl.ARRAY_BUFFER
|
||||
ElementArrayBuffer = gl.ELEMENT_ARRAY_BUFFER
|
||||
DynamicDraw = gl.DYNAMIC_DRAW
|
||||
vertexShader = gl.VERTEX_SHADER
|
||||
fragmentShader = gl.FRAGMENT_SHADER
|
||||
arrayBuffer = gl.ARRAY_BUFFER
|
||||
elementArrayBuffer = gl.ELEMENT_ARRAY_BUFFER
|
||||
dynamicDraw = gl.DYNAMIC_DRAW
|
||||
Short = gl.SHORT
|
||||
Float = gl.FLOAT
|
||||
|
||||
@ -450,8 +450,8 @@ func (c *Context) newArrayBuffer(size int) buffer {
|
||||
_ = c.runOnContextThread(func() error {
|
||||
var b uint32
|
||||
gl.GenBuffers(1, &b)
|
||||
gl.BindBuffer(uint32(ArrayBuffer), b)
|
||||
gl.BufferData(uint32(ArrayBuffer), size, nil, uint32(DynamicDraw))
|
||||
gl.BindBuffer(uint32(arrayBuffer), b)
|
||||
gl.BufferData(uint32(arrayBuffer), size, nil, uint32(dynamicDraw))
|
||||
bf = buffer(b)
|
||||
return nil
|
||||
})
|
||||
@ -463,8 +463,8 @@ func (c *Context) newElementArrayBuffer(size int) buffer {
|
||||
_ = c.runOnContextThread(func() error {
|
||||
var b uint32
|
||||
gl.GenBuffers(1, &b)
|
||||
gl.BindBuffer(uint32(ElementArrayBuffer), b)
|
||||
gl.BufferData(uint32(ElementArrayBuffer), size, nil, uint32(DynamicDraw))
|
||||
gl.BindBuffer(uint32(elementArrayBuffer), b)
|
||||
gl.BufferData(uint32(elementArrayBuffer), size, nil, uint32(dynamicDraw))
|
||||
bf = buffer(b)
|
||||
return nil
|
||||
})
|
||||
@ -480,14 +480,14 @@ func (c *Context) BindBuffer(bufferType bufferType, b buffer) {
|
||||
|
||||
func (c *Context) ArrayBufferSubData(data []float32) {
|
||||
_ = 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
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Context) ElementArrayBufferSubData(data []uint16) {
|
||||
_ = 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
|
||||
})
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ var (
|
||||
func init() {
|
||||
// Accessing the prototype is rquired on Safari.
|
||||
c := js.Global().Get("WebGLRenderingContext").Get("prototype")
|
||||
VertexShader = shaderType(c.Get("VERTEX_SHADER").Int())
|
||||
FragmentShader = shaderType(c.Get("FRAGMENT_SHADER").Int())
|
||||
ArrayBuffer = bufferType(c.Get("ARRAY_BUFFER").Int())
|
||||
ElementArrayBuffer = bufferType(c.Get("ELEMENT_ARRAY_BUFFER").Int())
|
||||
DynamicDraw = bufferUsage(c.Get("DYNAMIC_DRAW").Int())
|
||||
vertexShader = shaderType(c.Get("VERTEX_SHADER").Int())
|
||||
fragmentShader = shaderType(c.Get("FRAGMENT_SHADER").Int())
|
||||
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())
|
||||
|
||||
@ -407,16 +407,16 @@ func (c *Context) disableVertexAttribArray(p program, location string) {
|
||||
func (c *Context) newArrayBuffer(size int) buffer {
|
||||
gl := c.gl
|
||||
b := gl.Call("createBuffer")
|
||||
gl.Call("bindBuffer", int(ArrayBuffer), js.Value(b))
|
||||
gl.Call("bufferData", int(ArrayBuffer), size, int(DynamicDraw))
|
||||
gl.Call("bindBuffer", int(arrayBuffer), js.Value(b))
|
||||
gl.Call("bufferData", int(arrayBuffer), size, int(dynamicDraw))
|
||||
return buffer(b)
|
||||
}
|
||||
|
||||
func (c *Context) newElementArrayBuffer(size int) buffer {
|
||||
gl := c.gl
|
||||
b := gl.Call("createBuffer")
|
||||
gl.Call("bindBuffer", int(ElementArrayBuffer), js.Value(b))
|
||||
gl.Call("bufferData", int(ElementArrayBuffer), size, int(DynamicDraw))
|
||||
gl.Call("bindBuffer", int(elementArrayBuffer), js.Value(b))
|
||||
gl.Call("bufferData", int(elementArrayBuffer), size, int(dynamicDraw))
|
||||
return buffer(b)
|
||||
}
|
||||
|
||||
@ -428,14 +428,14 @@ func (c *Context) BindBuffer(bufferType bufferType, b buffer) {
|
||||
func (c *Context) ArrayBufferSubData(data []float32) {
|
||||
gl := c.gl
|
||||
arr := js.TypedArrayOf(data)
|
||||
gl.Call("bufferSubData", int(ArrayBuffer), 0, arr)
|
||||
gl.Call("bufferSubData", int(arrayBuffer), 0, arr)
|
||||
arr.Release()
|
||||
}
|
||||
|
||||
func (c *Context) ElementArrayBufferSubData(data []uint16) {
|
||||
gl := c.gl
|
||||
arr := js.TypedArrayOf(data)
|
||||
gl.Call("bufferSubData", int(ElementArrayBuffer), 0, arr)
|
||||
gl.Call("bufferSubData", int(elementArrayBuffer), 0, arr)
|
||||
arr.Release()
|
||||
}
|
||||
|
||||
|
@ -52,11 +52,11 @@ func getProgramID(p program) programID {
|
||||
}
|
||||
|
||||
func init() {
|
||||
VertexShader = mgl.VERTEX_SHADER
|
||||
FragmentShader = mgl.FRAGMENT_SHADER
|
||||
ArrayBuffer = mgl.ARRAY_BUFFER
|
||||
ElementArrayBuffer = mgl.ELEMENT_ARRAY_BUFFER
|
||||
DynamicDraw = mgl.DYNAMIC_DRAW
|
||||
vertexShader = mgl.VERTEX_SHADER
|
||||
fragmentShader = mgl.FRAGMENT_SHADER
|
||||
arrayBuffer = mgl.ARRAY_BUFFER
|
||||
elementArrayBuffer = mgl.ELEMENT_ARRAY_BUFFER
|
||||
dynamicDraw = mgl.DYNAMIC_DRAW
|
||||
Short = mgl.SHORT
|
||||
Float = mgl.FLOAT
|
||||
|
||||
@ -356,16 +356,16 @@ func (c *Context) disableVertexAttribArray(p program, location string) {
|
||||
func (c *Context) newArrayBuffer(size int) buffer {
|
||||
gl := c.gl
|
||||
b := gl.CreateBuffer()
|
||||
gl.BindBuffer(mgl.Enum(ArrayBuffer), b)
|
||||
gl.BufferInit(mgl.Enum(ArrayBuffer), size, mgl.Enum(DynamicDraw))
|
||||
gl.BindBuffer(mgl.Enum(arrayBuffer), b)
|
||||
gl.BufferInit(mgl.Enum(arrayBuffer), size, mgl.Enum(dynamicDraw))
|
||||
return buffer(b)
|
||||
}
|
||||
|
||||
func (c *Context) newElementArrayBuffer(size int) buffer {
|
||||
gl := c.gl
|
||||
b := gl.CreateBuffer()
|
||||
gl.BindBuffer(mgl.Enum(ElementArrayBuffer), b)
|
||||
gl.BufferInit(mgl.Enum(ElementArrayBuffer), size, mgl.Enum(DynamicDraw))
|
||||
gl.BindBuffer(mgl.Enum(elementArrayBuffer), b)
|
||||
gl.BufferInit(mgl.Enum(elementArrayBuffer), size, mgl.Enum(dynamicDraw))
|
||||
return buffer(b)
|
||||
}
|
||||
|
||||
@ -376,12 +376,12 @@ func (c *Context) BindBuffer(bufferType bufferType, b buffer) {
|
||||
|
||||
func (c *Context) ArrayBufferSubData(data []float32) {
|
||||
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) {
|
||||
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) {
|
||||
|
@ -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 {
|
||||
panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err))
|
||||
}
|
||||
defer GetContext().deleteShader(shaderVertexModelviewNative)
|
||||
|
||||
shaderFragmentNearestNative, err := GetContext().newShader(FragmentShader, shaderStr(shaderFragmentNearest))
|
||||
shaderFragmentNearestNative, err := GetContext().newShader(fragmentShader, shaderStr(shaderFragmentNearest))
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err))
|
||||
}
|
||||
defer GetContext().deleteShader(shaderFragmentNearestNative)
|
||||
|
||||
shaderFragmentLinearNative, err := GetContext().newShader(FragmentShader, shaderStr(shaderFragmentLinear))
|
||||
shaderFragmentLinearNative, err := GetContext().newShader(fragmentShader, shaderStr(shaderFragmentLinear))
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("graphics: shader compiling error:\n%s", err))
|
||||
}
|
||||
defer GetContext().deleteShader(shaderFragmentLinearNative)
|
||||
|
||||
shaderFragmentScreenNative, err := GetContext().newShader(FragmentShader, shaderStr(shaderFragmentScreen))
|
||||
shaderFragmentScreenNative, err := GetContext().newShader(fragmentShader, shaderStr(shaderFragmentScreen))
|
||||
if err != nil {
|
||||
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)
|
||||
|
||||
if s.lastProgram == zeroProgram {
|
||||
c.BindBuffer(ArrayBuffer, s.arrayBuffer)
|
||||
c.BindBuffer(ElementArrayBuffer, s.elementArrayBuffer)
|
||||
c.BindBuffer(arrayBuffer, s.arrayBuffer)
|
||||
c.BindBuffer(elementArrayBuffer, s.elementArrayBuffer)
|
||||
c.uniformInt(program, "texture", 0)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user