mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
shader: Add a builtin function viewportSize
This commit is contained in:
parent
92e1c6cf2d
commit
b64dc627e9
@ -29,20 +29,19 @@ const (
|
|||||||
|
|
||||||
const shaderSrc = `package main
|
const shaderSrc = `package main
|
||||||
|
|
||||||
// __viewportSize is a predefined uniform variable.
|
// viewportSize is a predefined function.
|
||||||
// TODO: Hide this by a function.
|
|
||||||
|
|
||||||
func Vertex(position vec2, texCoord vec2, color vec4) vec4 {
|
func Vertex(position vec2, texCoord vec2, color vec4) vec4 {
|
||||||
return mat4(
|
return mat4(
|
||||||
2.0/__viewportSize.x, 0, 0, 0,
|
2.0/viewportSize().x, 0, 0, 0,
|
||||||
0, 2.0/__viewportSize.y, 0, 0,
|
0, 2.0/viewportSize().y, 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/__viewportSize.x, position.y/__viewportSize.y, 0, 1)
|
return vec4(position.x/viewportSize().x, position.y/viewportSize().y, 0, 1)
|
||||||
}`
|
}`
|
||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user