From e406ebb1aabdd79a4b260441ae3993b2aa6270c7 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 19 Sep 2020 19:36:49 +0900 Subject: [PATCH] ebiten: Rename imageSrcTextureRegion -> imageSrcRegionOnTexture Updates #1325 --- examples/shader/water.go | 2 +- examples/shader/water_go.go | 2 +- shader.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/shader/water.go b/examples/shader/water.go index 3d8fc521e..86437e7c6 100644 --- a/examples/shader/water.go +++ b/examples/shader/water.go @@ -27,7 +27,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { } srcsize := imageSrcTextureSize() - rorigin, _ := imageSrcTextureRegion() + rorigin, _ := imageSrcRegionOnTexture() xoffset := (4 / srcsize.x) * cos(Time*3+texCoord.y*200) yoffset := (20 / srcsize.y) * (1.0 + cos(Time*3+texCoord.y*50)) diff --git a/examples/shader/water_go.go b/examples/shader/water_go.go index 5e04f5d84..61b3546fa 100644 --- a/examples/shader/water_go.go +++ b/examples/shader/water_go.go @@ -2,4 +2,4 @@ package main -var water_go = []byte("// Copyright 2020 The Ebiten Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// +build ignore\n\npackage main\n\nvar Time float\nvar Cursor vec2\nvar ScreenSize vec2\n\nfunc Fragment(position vec4, texCoord vec2, color vec4) vec4 {\n\tborder := ScreenSize.y*0.6 + 4*cos(Time*3+texCoord.y*200)\n\tif position.y < border {\n\t\treturn imageSrc2UnsafeAt(texCoord)\n\t}\n\n\tsrcsize := imageSrcTextureSize()\n\trorigin, _ := imageSrcTextureRegion()\n\n\txoffset := (4 / srcsize.x) * cos(Time*3+texCoord.y*200)\n\tyoffset := (20 / srcsize.y) * (1.0 + cos(Time*3+texCoord.y*50))\n\tbordertex := border / srcsize.y\n\tclr := imageSrc2At(vec2(\n\t\ttexCoord.x+xoffset,\n\t\t-(texCoord.y+yoffset-rorigin.y)+bordertex*2+rorigin.y,\n\t)).rgb\n\n\toverlay := vec3(0.5, 1, 1)\n\treturn vec4(mix(clr, overlay, 0.25), 1)\n}\n") +var water_go = []byte("// Copyright 2020 The Ebiten Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// +build ignore\n\npackage main\n\nvar Time float\nvar Cursor vec2\nvar ScreenSize vec2\n\nfunc Fragment(position vec4, texCoord vec2, color vec4) vec4 {\n\tborder := ScreenSize.y*0.6 + 4*cos(Time*3+texCoord.y*200)\n\tif position.y < border {\n\t\treturn imageSrc2UnsafeAt(texCoord)\n\t}\n\n\tsrcsize := imageSrcTextureSize()\n\trorigin, _ := imageSrcRegionOnTexture()\n\n\txoffset := (4 / srcsize.x) * cos(Time*3+texCoord.y*200)\n\tyoffset := (20 / srcsize.y) * (1.0 + cos(Time*3+texCoord.y*50))\n\tbordertex := border / srcsize.y\n\tclr := imageSrc2At(vec2(\n\t\ttexCoord.x+xoffset,\n\t\t-(texCoord.y+yoffset-rorigin.y)+bordertex*2+rorigin.y,\n\t)).rgb\n\n\toverlay := vec3(0.5, 1, 1)\n\treturn vec4(mix(clr, overlay, 0.25), 1)\n}\n") diff --git a/shader.go b/shader.go index a66cfb957..c5d752b9b 100644 --- a/shader.go +++ b/shader.go @@ -58,11 +58,11 @@ var __textureSourceRegionOrigin vec2 // The unit is the source texture's texel. var __textureSourceRegionSize vec2 -// imageSrcTextureRegion returns the source image's region (the origin and the size) on its texture. +// imageSrcRegionOnTexture returns the source image's region (the origin and the size) on its texture. // The unit is the source texture's texel. // // As an image is a part of internal texture, the image can be located at an arbitrary position on the texture. -func imageSrcTextureRegion() (vec2, vec2) { +func imageSrcRegionOnTexture() (vec2, vec2) { return __textureSourceRegionOrigin, __textureSourceRegionSize } `, graphics.ShaderImageNum, graphics.ShaderImageNum-1)