File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
<!DOCTYPE html> < html lang ="en "> < head >
2
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0 /p5.min.js "> </ script >
2
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1 /p5.min.js "> </ script >
3
3
< script src ="../../p5.Framebuffer.js " type ="text/javascript "> </ script >
4
4
< link rel ="stylesheet " type ="text/css " href ="style.css ">
5
5
< meta charset ="utf-8 ">
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ function draw() {
9
9
// Draw a sphere to the Framebuffer
10
10
fbo . draw ( ( ) => {
11
11
clear ( )
12
+ background ( 255 )
12
13
push ( )
13
14
noStroke ( )
14
15
fill ( 255 , 0 , 0 )
@@ -20,6 +21,7 @@ function draw() {
20
21
21
22
// Do something with fbo.color or dbo.depth
22
23
clear ( )
24
+ background ( 255 )
23
25
push ( )
24
26
noStroke ( )
25
27
@@ -36,4 +38,4 @@ function draw() {
36
38
pop ( )
37
39
38
40
pop ( )
39
- }
41
+ }
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ class Framebuffer {
97
97
const width = this . _renderer . width
98
98
const height = this . _renderer . height
99
99
const density = this . _renderer . _pInst . _pixelDensity
100
+ const hasAlpha = this . _renderer . _pInst . _glAttributes . alpha
100
101
101
102
const colorTexture = gl . createTexture ( )
102
103
if ( ! colorTexture ) {
@@ -111,11 +112,11 @@ class Framebuffer {
111
112
gl . texImage2D (
112
113
gl . TEXTURE_2D ,
113
114
0 ,
114
- gl . RGBA ,
115
+ hasAlpha ? gl . RGBA : gl . RGB ,
115
116
width * density ,
116
117
height * density ,
117
118
0 ,
118
- gl . RGBA ,
119
+ hasAlpha ? gl . RGBA : gl . RGB ,
119
120
gl . UNSIGNED_BYTE ,
120
121
null ,
121
122
)
You can’t perform that action at this time.
0 commit comments