1#!amber 2# Copyright 2020 The Amber Authors. 3# Copyright 2020 The Google LLC 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# https://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17SHADER vertex vert_shader GLSL 18#version 430 19 20layout(location = 0) in vec4 position; 21layout(location = 1) out vec4 frag_color; 22 23void main() { 24 gl_Position = position; 25 frag_color = position * 0.5; 26} 27END 28 29SHADER fragment frag_shader GLSL 30#version 430 31layout(location = 0) out vec4 color_out; 32layout(location = 1) in vec4 frag_color; 33void main() { 34 ivec2 iv = ivec2(frag_color.xy * 256); 35 if (((iv.y / 2) & 64) == 64) 36 color_out = vec4(1, 0, 0, 1); 37 else 38 color_out = vec4(0, 1, 1, 1); 39} 40END 41 42BUFFER framebuffer FORMAT B8G8R8A8_UNORM 43 44PIPELINE graphics my_pipeline 45 ATTACH vert_shader 46 ATTACH frag_shader 47 BIND BUFFER framebuffer AS color LOCATION 0 48END 49 50RUN my_pipeline DRAW_RECT POS 0 0 SIZE 250 250 51EXPECT framebuffer IDX 0 220 SIZE 30 30 EQ_RGBA 0 255 255 255 52EXPECT framebuffer IDX 0 0 SIZE 30 30 EQ_RGBA 255 0 0 255 53 54