1#!amber 2# Copyright 2020 The Amber Authors. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# https://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16SHADER vertex vert_shader_tex GLSL 17#version 430 18layout(location = 0) in vec4 position; 19layout(location = 1) in vec2 texcoords_in; 20layout(location = 0) out vec2 texcoords_out; 21void main() { 22 gl_Position = position; 23 texcoords_out = texcoords_in; 24} 25END 26 27SHADER fragment frag_shader_tex GLSL 28#version 430 29layout(location = 0) in vec2 texcoords_in; 30layout(location = 0) out vec4 color_out; 31uniform layout(set=0, binding=0) sampler2D tex_sampler; 32void main() { 33 color_out = texture(tex_sampler, texcoords_in); 34} 35END 36 37BUFFER texture FORMAT R8G8B8A8_UNORM FILE PNG texture.png 38BUFFER framebuffer FORMAT B8G8R8A8_UNORM 39SAMPLER sampler 40BUFFER position DATA_TYPE vec2<float> DATA 41-0.75 -0.75 42 0.75 -0.75 43 0.75 0.75 44-0.75 0.75 45END 46BUFFER texcoords DATA_TYPE vec2<float> DATA 470.0 0.0 481.0 0.0 491.0 1.0 500.0 1.0 51END 52 53PIPELINE graphics pipeline 54 ATTACH vert_shader_tex 55 ATTACH frag_shader_tex 56 BIND BUFFER texture AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 57 VERTEX_DATA position LOCATION 0 58 VERTEX_DATA texcoords LOCATION 1 59 FRAMEBUFFER_SIZE 256 256 60 BIND BUFFER framebuffer AS color LOCATION 0 61END 62 63# Draw the texture using a default sampler. 64CLEAR_COLOR pipeline 0 255 0 255 65CLEAR pipeline 66RUN pipeline DRAW_ARRAY AS TRIANGLE_FAN START_IDX 0 COUNT 4 67