mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 19:58:54 +01:00
graphicscommand: Adjust regions for secondory and following images correctly
This commit is contained in:
parent
915aecb960
commit
b2eee7ee8a
@ -418,13 +418,27 @@ func (c *drawTrianglesCommand) Exec(indexOffset int) error {
|
|||||||
|
|
||||||
if c.shader != nil {
|
if c.shader != nil {
|
||||||
us := make([]interface{}, len(c.uniforms))
|
us := make([]interface{}, len(c.uniforms))
|
||||||
// TODO: Adjust the source sizes in uniform variables.
|
|
||||||
for k, v := range c.uniforms {
|
firstImage := true
|
||||||
switch v := v.(type) {
|
for i := 0; i < len(c.uniforms); i++ {
|
||||||
|
switch v := c.uniforms[i].(type) {
|
||||||
case *Image:
|
case *Image:
|
||||||
us[k] = v.image.ID()
|
us[i] = v.image.ID()
|
||||||
|
if !firstImage {
|
||||||
|
// Convert pixels to texels.
|
||||||
|
w, h := v.InternalSize()
|
||||||
|
i++
|
||||||
|
region := c.uniforms[i].([]float32)
|
||||||
|
us[i] = []float32{
|
||||||
|
region[0] / float32(w),
|
||||||
|
region[1] / float32(h),
|
||||||
|
region[2] / float32(w),
|
||||||
|
region[3] / float32(h),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
firstImage = false
|
||||||
default:
|
default:
|
||||||
us[k] = v
|
us[i] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return theGraphicsDriver.DrawShader(c.dst.image.ID(), c.shader.shader.ID(), c.nindices, indexOffset, c.mode, us)
|
return theGraphicsDriver.DrawShader(c.dst.image.ID(), c.shader.shader.ID(), c.nindices, indexOffset, c.mode, us)
|
||||||
|
@ -324,16 +324,18 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16,
|
|||||||
firstImage := true
|
firstImage := true
|
||||||
us := make([]interface{}, len(uniforms))
|
us := make([]interface{}, len(uniforms))
|
||||||
for i := 0; i < len(uniforms); i++ {
|
for i := 0; i < len(uniforms); i++ {
|
||||||
switch v := us[i].(type) {
|
switch v := uniforms[i].(type) {
|
||||||
case *Image:
|
case *Image:
|
||||||
us[i] = v.backend.restorable
|
us[i] = v.backend.restorable
|
||||||
if !firstImage {
|
if !firstImage {
|
||||||
i++
|
i++
|
||||||
region := us[i].([]float32)
|
region := uniforms[i].([]float32)
|
||||||
region[0] += oxf
|
us[i] = []float32{
|
||||||
region[1] += oyf
|
region[0] + oxf,
|
||||||
region[2] += oxf
|
region[1] + oyf,
|
||||||
region[3] += oyf
|
region[2] + oxf,
|
||||||
|
region[3] + oyf,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
firstImage = false
|
firstImage = false
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user