mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
Unify Uniform* methods
This commit is contained in:
parent
e10bcb3dd8
commit
25fb0a9e31
@ -74,7 +74,7 @@ func useProgramColorMatrix(c *opengl.Context, projectionMatrix [16]float32, geo
|
|||||||
// TODO: Check the performance.
|
// TODO: Check the performance.
|
||||||
program := programColorMatrix
|
program := programColorMatrix
|
||||||
|
|
||||||
c.UniformMatrix4fv(program, "projection_matrix", projectionMatrix)
|
c.Uniform(program, "projection_matrix", projectionMatrix)
|
||||||
|
|
||||||
ma := float32(geo.Element(0, 0))
|
ma := float32(geo.Element(0, 0))
|
||||||
mb := float32(geo.Element(0, 1))
|
mb := float32(geo.Element(0, 1))
|
||||||
@ -88,8 +88,8 @@ func useProgramColorMatrix(c *opengl.Context, projectionMatrix [16]float32, geo
|
|||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
tx, ty, 0, 1,
|
tx, ty, 0, 1,
|
||||||
}
|
}
|
||||||
c.UniformMatrix4fv(program, "modelview_matrix", glModelviewMatrix)
|
c.Uniform(program, "modelview_matrix", glModelviewMatrix)
|
||||||
c.Uniform1i(program, "texture", 0)
|
c.Uniform(program, "texture", 0)
|
||||||
|
|
||||||
e := [4][5]float32{}
|
e := [4][5]float32{}
|
||||||
for i := 0; i < 4; i++ {
|
for i := 0; i < 4; i++ {
|
||||||
@ -104,11 +104,11 @@ func useProgramColorMatrix(c *opengl.Context, projectionMatrix [16]float32, geo
|
|||||||
e[0][2], e[1][2], e[2][2], e[3][2],
|
e[0][2], e[1][2], e[2][2], e[3][2],
|
||||||
e[0][3], e[1][3], e[2][3], e[3][3],
|
e[0][3], e[1][3], e[2][3], e[3][3],
|
||||||
}
|
}
|
||||||
c.UniformMatrix4fv(program, "color_matrix", glColorMatrix)
|
c.Uniform(program, "color_matrix", glColorMatrix)
|
||||||
glColorMatrixTranslation := [...]float32{
|
glColorMatrixTranslation := [...]float32{
|
||||||
e[0][4], e[1][4], e[2][4], e[3][4],
|
e[0][4], e[1][4], e[2][4], e[3][4],
|
||||||
}
|
}
|
||||||
c.Uniform4fv(program, "color_matrix_translation", glColorMatrixTranslation)
|
c.Uniform(program, "color_matrix_translation", glColorMatrixTranslation)
|
||||||
|
|
||||||
return program
|
return program
|
||||||
}
|
}
|
||||||
|
@ -178,17 +178,16 @@ func (c *Context) UseProgram(p Program) {
|
|||||||
gl.Program(p).Use()
|
gl.Program(p).Use()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) Uniform1i(p Program, location string, v int) {
|
func (c *Context) Uniform(p Program, location string, v interface{}) {
|
||||||
// TODO: Cache the location names.
|
l := gl.Program(p).GetUniformLocation(location)
|
||||||
gl.Program(p).GetUniformLocation(location).Uniform1i(v)
|
switch v := v.(type) {
|
||||||
}
|
case int:
|
||||||
|
l.Uniform1i(v)
|
||||||
func (c *Context) Uniform4fv(p Program, location string, v [4]float32) {
|
case [4]float32:
|
||||||
gl.Program(p).GetUniformLocation(location).Uniform4fv(1, v[:])
|
l.Uniform4fv(1, v[:])
|
||||||
}
|
case [16]float32:
|
||||||
|
l.UniformMatrix4fv(false, v)
|
||||||
func (c *Context) UniformMatrix4fv(p Program, location string, v [16]float32) {
|
}
|
||||||
gl.Program(p).GetUniformLocation(location).UniformMatrix4fv(false, v)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) VertexAttribPointer(p Program, location string, stride int, v uintptr) {
|
func (c *Context) VertexAttribPointer(p Program, location string, stride int, v uintptr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user