mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
Revert "shader: Add a predefined uniform variable: Internal_ViewportSize"
This reverts commit 6f411842f0
.
Reason: Test failures on internal/restorable
This commit is contained in:
parent
6f411842f0
commit
fe308f1971
@ -29,20 +29,17 @@ const (
|
|||||||
|
|
||||||
const shaderSrc = `package main
|
const shaderSrc = `package main
|
||||||
|
|
||||||
// Internal_ViewportSize is a predefined uniform variable.
|
|
||||||
// TODO: Hide this and create a function for the projection matrix?
|
|
||||||
|
|
||||||
func Vertex(position vec2, texCoord vec2, color vec4) vec4 {
|
func Vertex(position vec2, texCoord vec2, color vec4) vec4 {
|
||||||
return mat4(
|
return mat4(
|
||||||
2.0/Internal_ViewportSize.x, 0, 0, 0,
|
2.0/640, 0, 0, 0,
|
||||||
0, 2.0/Internal_ViewportSize.y, 0, 0,
|
0, 2.0/480, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
-1, -1, 0, 1,
|
-1, -1, 0, 1,
|
||||||
) * vec4(position, 0, 1)
|
) * vec4(position, 0, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Fragment(position vec4) vec4 {
|
func Fragment(position vec4) vec4 {
|
||||||
return vec4(position.x/Internal_ViewportSize.x, position.y/Internal_ViewportSize.y, 0, 1)
|
return vec4(position.x/640, position.y/480, 0, 1)
|
||||||
}`
|
}`
|
||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
|
4
image.go
4
image.go
@ -384,10 +384,6 @@ func (i *Image) DrawTrianglesWithShader(vertices []Vertex, indices []uint16, sha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The last uniform variable is Internal_ViewportSize.
|
|
||||||
// The actual value is set at graphicscommand package.
|
|
||||||
us = append(us, []float32{0, 0})
|
|
||||||
|
|
||||||
var bx0, by0, bx1, by1 float32
|
var bx0, by0, bx1, by1 float32
|
||||||
if firstImage != nil {
|
if firstImage != nil {
|
||||||
b := firstImage.Bounds()
|
b := firstImage.Bounds()
|
||||||
|
@ -453,13 +453,6 @@ func (c *drawTrianglesCommand) Exec(indexOffset int) error {
|
|||||||
us[i] = v
|
us[i] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The last uniform variables are added at /shader.go and represents a viewport size.
|
|
||||||
w, h := c.dst.InternalSize()
|
|
||||||
viewport := us[len(us)-1].([]float32)
|
|
||||||
viewport[0] = float32(w)
|
|
||||||
viewport[1] = float32(h)
|
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
return theGraphicsDriver.Draw(c.dst.image.ID(), c.src.image.ID(), c.nindices, indexOffset, c.mode, c.color, c.filter, c.address)
|
return theGraphicsDriver.Draw(c.dst.image.ID(), c.src.image.ID(), c.nindices, indexOffset, c.mode, c.color, c.filter, c.address)
|
||||||
|
11
shader.go
11
shader.go
@ -15,25 +15,16 @@
|
|||||||
package ebiten
|
package ebiten
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/buffered"
|
"github.com/hajimehoshi/ebiten/internal/buffered"
|
||||||
"github.com/hajimehoshi/ebiten/internal/shader"
|
"github.com/hajimehoshi/ebiten/internal/shader"
|
||||||
)
|
)
|
||||||
|
|
||||||
const shaderSuffix = `
|
|
||||||
var Internal_ViewportSize vec2`
|
|
||||||
|
|
||||||
type Shader struct {
|
type Shader struct {
|
||||||
shader *buffered.Shader
|
shader *buffered.Shader
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewShader(src []byte) (*Shader, error) {
|
func NewShader(src []byte) (*Shader, error) {
|
||||||
var b bytes.Buffer
|
s, err := shader.Compile(src, "Vertex", "Fragment")
|
||||||
b.Write(src)
|
|
||||||
b.Write([]byte(shaderSuffix))
|
|
||||||
|
|
||||||
s, err := shader.Compile(b.Bytes(), "Vertex", "Fragment")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user