mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Add opengl.AttribLocation
This commit is contained in:
parent
b8dde70b03
commit
37828c452f
@ -85,8 +85,8 @@ func DrawTexture(c *opengl.Context, native gl.Texture, projectionMatrix [4][4]fl
|
||||
gl.ActiveTexture(gl.TEXTURE0)
|
||||
native.Bind(gl.TEXTURE_2D)
|
||||
|
||||
vertexAttrLocation := getAttributeLocation(program, "vertex")
|
||||
texCoordAttrLocation := getAttributeLocation(program, "tex_coord")
|
||||
vertexAttrLocation := program.GetAttributeLocation("vertex")
|
||||
texCoordAttrLocation := program.GetAttributeLocation("tex_coord")
|
||||
|
||||
vertexAttrLocation.EnableArray()
|
||||
texCoordAttrLocation.EnableArray()
|
||||
@ -95,8 +95,8 @@ func DrawTexture(c *opengl.Context, native gl.Texture, projectionMatrix [4][4]fl
|
||||
vertexAttrLocation.DisableArray()
|
||||
}()
|
||||
|
||||
vertexAttrLocation.AttribPointer(2, gl.FLOAT, false, stride, uintptr(float32Size*0))
|
||||
texCoordAttrLocation.AttribPointer(2, gl.FLOAT, false, stride, uintptr(float32Size*2))
|
||||
vertexAttrLocation.AttribPointer(stride, uintptr(float32Size*0))
|
||||
texCoordAttrLocation.AttribPointer(stride, uintptr(float32Size*2))
|
||||
|
||||
vertices := []float32{}
|
||||
for i := 0; i < quads.Len(); i++ {
|
||||
|
@ -15,7 +15,6 @@
|
||||
package shader
|
||||
|
||||
import (
|
||||
"github.com/go-gl/gl"
|
||||
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||
)
|
||||
|
||||
@ -43,13 +42,9 @@ func initialize(c *opengl.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func getAttributeLocation(program gl.Program, name string) gl.AttribLocation {
|
||||
return program.GetAttribLocation(name)
|
||||
}
|
||||
|
||||
var lastProgram opengl.Program = 0
|
||||
|
||||
func useProgramColorMatrix(projectionMatrix [16]float32, geo Matrix, color Matrix) gl.Program {
|
||||
func useProgramColorMatrix(projectionMatrix [16]float32, geo Matrix, color Matrix) opengl.Program {
|
||||
if lastProgram != programColorMatrix {
|
||||
programColorMatrix.Use()
|
||||
lastProgram = programColorMatrix
|
||||
@ -94,5 +89,5 @@ func useProgramColorMatrix(projectionMatrix [16]float32, geo Matrix, color Matri
|
||||
}
|
||||
program.GetUniformLocation("color_matrix_translation").Uniform4fv(1, glColorMatrixTranslation[:])
|
||||
|
||||
return gl.Program(program)
|
||||
return program
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ func (p Program) Use() {
|
||||
gl.Program(p).Use()
|
||||
}
|
||||
|
||||
func (p Program) GetAttribLocation(name string) AttribLocation {
|
||||
func (p Program) GetAttributeLocation(name string) AttribLocation {
|
||||
return AttribLocation(gl.Program(p).GetAttribLocation(name))
|
||||
}
|
||||
|
||||
@ -100,6 +100,18 @@ func (p Program) GetUniformLocation(name string) UniformLocation {
|
||||
|
||||
type AttribLocation int
|
||||
|
||||
func (a AttribLocation) EnableArray() {
|
||||
gl.AttribLocation(a).EnableArray()
|
||||
}
|
||||
|
||||
func (a AttribLocation) DisableArray() {
|
||||
gl.AttribLocation(a).DisableArray()
|
||||
}
|
||||
|
||||
func (a AttribLocation) AttribPointer(stride int, x uintptr) {
|
||||
gl.AttribLocation(a).AttribPointer(2, gl.FLOAT, false, stride, x)
|
||||
}
|
||||
|
||||
type UniformLocation int
|
||||
|
||||
func (u UniformLocation) UniformMatrix4fv(matrix [16]float32) {
|
||||
|
Loading…
Reference in New Issue
Block a user