MCPcopy Index your code
hub / github.com/processing/p5.js / testWithConfiguration

Function testWithConfiguration

test/unit/webgl/p5.Framebuffer.js:57–102  ·  view source on GitHub ↗
(
      version,
      format,
      channels,
      antialias,
      depth
    )

Source from the content-addressed store, hash-verified

55
56 suite('formats and channels', function() {
57 function testWithConfiguration(
58 version,
59 format,
60 channels,
61 antialias,
62 depth
63 ) {
64 test(
65 `framebuffers work with WebGL ${version}, ${format} ${channels} ${depth || 'no'} depth ${antialias ? ' antialiased' : ''}`,
66 function() {
67 myp5.createCanvas(10, 10, myp5.WEBGL);
68 myp5.setAttributes({ version });
69
70 // Draw a box to the framebuffer
71 const fbo = myp5.createFramebuffer({
72 format,
73 channels,
74 antialias,
75 depth: depth !== null,
76 depthFormat: depth
77 });
78 fbo.draw(() => {
79 myp5.background(255);
80 myp5.noStroke();
81 myp5.fill('red');
82 myp5.box(5, 5, 5);
83 });
84
85 // Draw the framebuffer to the canvas
86 myp5.background(0);
87 myp5.noStroke();
88 myp5.texture(fbo);
89 myp5.plane(myp5.width, -myp5.height);
90
91 // Make sure it drew
92 assert.deepEqual(
93 myp5.get(0, 0),
94 [255, 255, 255, 255]
95 );
96 assert.deepEqual(
97 myp5.get(5, 5),
98 [255, 0, 0, 255]
99 );
100 }
101 );
102 }
103
104 const versions = [1, 2];
105 const formats = ['unsigned-byte', 'float', 'half-float'];

Callers 1

p5.Framebuffer.jsFile · 0.85

Calls 6

noStrokeMethod · 0.80
createFramebufferMethod · 0.45
drawMethod · 0.45
backgroundMethod · 0.45
fillMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected