File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -4956,10 +4956,21 @@ class MediaElement extends p5.Element {
49564956 this . _frameOnCanvas = this . _pInst . frameCount ;
49574957 }
49584958 }
4959- loadPixels ( ...args ) {
4960- this . _ensureCanvas ( ) ;
4959+ loadPixels ( ...args ) {
4960+ this . _ensureCanvas ( ) ;
4961+
4962+ // ✅ use the current p5 instance’s renderer instead of global p5
4963+ if ( this . _pInst && this . _pInst . _renderer ) {
4964+ return this . _pInst . _renderer . loadPixels ( ...args ) ;
4965+ }
4966+
4967+ // fallback for old global mode (just in case)
4968+ if ( typeof p5 !== 'undefined' && p5 . Renderer2D && p5 . Renderer2D . prototype ) {
49614969 return p5 . Renderer2D . prototype . loadPixels . apply ( this , args ) ;
49624970 }
4971+
4972+ throw new Error ( 'p5 instance or renderer not available in MediaElement.loadPixels()' ) ;
4973+ }
49634974 updatePixels ( x , y , w , h ) {
49644975 if ( this . loadedmetadata ) {
49654976 // wait for metadata
You can’t perform that action at this time.
0 commit comments