Updated fragment shader sample to use uniform-by-name accessor (#2736)

Do not land until the following are on stable:
- https://github.com/flutter/flutter/pull/176728
- https://github.com/flutter/flutter/pull/176980

If you need help, consider asking for advice on the #hackers-devrel channel on [Discord].
pull/2845/head
gaaclarke 3 weeks ago committed by GitHub
parent 7f2fc7028d
commit 8fbf213817
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -44,13 +44,15 @@ class MyHomePage extends StatelessWidget {
}
class ShaderPainter extends CustomPainter {
ShaderPainter({required this.shader});
ui.FragmentShader shader;
ShaderPainter({required this.shader})
: _resolution = shader.getUniformVec2('resolution');
final ui.FragmentShader shader;
final ui.UniformVec2Slot _resolution;
@override
void paint(Canvas canvas, Size size) {
shader.setFloat(0, size.width);
shader.setFloat(1, size.height);
_resolution.set(size.width, size.height);
final paint = Paint()..shader = shader;
canvas.drawRect(Rect.fromLTWH(0, 0, size.width, size.height), paint);

Loading…
Cancel
Save