mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +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 {
|
||||
us := make([]interface{}, len(c.uniforms))
|
||||
// TODO: Adjust the source sizes in uniform variables.
|
||||
for k, v := range c.uniforms {
|
||||
switch v := v.(type) {
|
||||
|
||||
firstImage := true
|
||||
for i := 0; i < len(c.uniforms); i++ {
|
||||
switch v := c.uniforms[i].(type) {
|
||||
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:
|
||||
us[k] = v
|
||||
us[i] = v
|
||||
}
|
||||
}
|
||||
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
|
||||
us := make([]interface{}, len(uniforms))
|
||||
for i := 0; i < len(uniforms); i++ {
|
||||
switch v := us[i].(type) {
|
||||
switch v := uniforms[i].(type) {
|
||||
case *Image:
|
||||
us[i] = v.backend.restorable
|
||||
if !firstImage {
|
||||
i++
|
||||
region := us[i].([]float32)
|
||||
region[0] += oxf
|
||||
region[1] += oyf
|
||||
region[2] += oxf
|
||||
region[3] += oyf
|
||||
region := uniforms[i].([]float32)
|
||||
us[i] = []float32{
|
||||
region[0] + oxf,
|
||||
region[1] + oyf,
|
||||
region[2] + oxf,
|
||||
region[3] + oyf,
|
||||
}
|
||||
}
|
||||
firstImage = false
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user