File tree Expand file tree Collapse file tree 4 files changed +45
-1
lines changed
screenshots/WebGL/Camera/Camera settings on framebuffers reset after push%2Fpop Expand file tree Collapse file tree 4 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -2945,15 +2945,18 @@ function camera(p5, fn){
29452945 p5 . Camera = Camera ;
29462946
29472947 RendererGL . prototype . camera = function ( ...args ) {
2948+ this . states . setValue ( 'curCamera' , this . states . curCamera . clone ( ) ) ;
29482949 this . states . curCamera . camera ( ...args ) ;
29492950 } ;
29502951
29512952 RendererGL . prototype . perspective = function ( ...args ) {
2953+ this . states . setValue ( 'curCamera' , this . states . curCamera . clone ( ) ) ;
29522954 this . states . curCamera . perspective ( ...args ) ;
29532955 } ;
29542956
29552957 RendererGL . prototype . linePerspective = function ( enable ) {
29562958 if ( enable !== undefined ) {
2959+ this . states . setValue ( 'curCamera' , this . states . curCamera . clone ( ) ) ;
29572960 // Set the line perspective if enable is provided
29582961 this . states . curCamera . useLinePerspective = enable ;
29592962 } else {
@@ -2963,10 +2966,12 @@ function camera(p5, fn){
29632966 } ;
29642967
29652968 RendererGL . prototype . ortho = function ( ...args ) {
2969+ this . states . setValue ( 'curCamera' , this . states . curCamera . clone ( ) ) ;
29662970 this . states . curCamera . ortho ( ...args ) ;
29672971 } ;
29682972
29692973 RendererGL . prototype . frustum = function ( ...args ) {
2974+ this . states . setValue ( 'curCamera' , this . states . curCamera . clone ( ) ) ;
29702975 this . states . curCamera . frustum ( ...args ) ;
29712976 } ;
29722977
Original file line number Diff line number Diff line change @@ -25,6 +25,42 @@ visualSuite('WebGL', function() {
2525 p5 . box ( 20 ) ;
2626 screenshot ( ) ;
2727 } ) ;
28+
29+ visualTest ( 'Camera settings on framebuffers reset after push/pop' , function ( p5 , screenshot ) {
30+ p5 . createCanvas ( 100 , 100 , p5 . WEBGL ) ;
31+ p5 . setAttributes ( { antialias : true } ) ;
32+ const fbo = p5 . createFramebuffer ( ) ;
33+
34+ p5 . background ( 220 ) ;
35+ p5 . imageMode ( p5 . CENTER ) ;
36+
37+ fbo . begin ( ) ;
38+ p5 . push ( ) ;
39+ p5 . ortho ( ) ;
40+ p5 . translate ( 0 , - 25 ) ;
41+ for ( let i = - 1 ; i <= 1 ; i ++ ) {
42+ p5 . push ( ) ;
43+ p5 . translate ( i * 35 , 0 ) ;
44+ p5 . box ( 25 , 25 , 150 ) ;
45+ p5 . pop ( ) ;
46+ }
47+ p5 . pop ( ) ;
48+
49+
50+ p5 . push ( ) ;
51+ p5 . translate ( 0 , 25 ) ;
52+ for ( let i = - 1 ; i <= 1 ; i ++ ) {
53+ p5 . push ( ) ;
54+ p5 . translate ( i * 35 , 0 ) ;
55+ p5 . box ( 25 , 25 , 150 ) ;
56+ p5 . pop ( ) ;
57+ }
58+ p5 . pop ( ) ;
59+
60+ fbo . end ( ) ;
61+ p5 . image ( fbo , 0 , 0 ) ;
62+ screenshot ( ) ;
63+ } ) ;
2864 } ) ;
2965
3066 visualSuite ( 'filter' , function ( ) {
@@ -758,7 +794,7 @@ visualSuite('WebGL', function() {
758794 screenshot ( ) ;
759795 } ) ;
760796 } ) ;
761-
797+
762798 visualSuite ( 'p5.strands' , ( ) => {
763799 visualTest ( 'it recovers from p5.strands errors' , ( p5 , screenshot ) => {
764800 p5 . createCanvas ( 50 , 50 , p5 . WEBGL ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "numScreenshots" : 1
3+ }
You can’t perform that action at this time.
0 commit comments