@@ -183,12 +183,13 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
183183 uint8_t *w = img_data[0 ].ptrw ();
184184 memcpy (w, dataY, new_width * new_height);
185185 img[0 ].instantiate ();
186+ img[0 ]->set_data (new_width, new_height, 0 , Image::FORMAT_R8, img_data[0 ]);
186187#else
187188 GodotUInt8Vector::Write w = img_data[0 ].write ();
188189 memcpy (w.ptr (), dataY, new_width * new_height);
189190 img[0 ].instance ();
190- #endif
191191 img[0 ]->create (new_width, new_height, 0 , Image::FORMAT_R8, img_data[0 ]);
192+ #endif
192193 }
193194
194195 {
@@ -202,18 +203,18 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
202203 img_data[1 ].resize (2 * new_width * new_height);
203204 }
204205
206+ // /TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion
205207#if VERSION_MAJOR == 4
206208 uint8_t *w = img_data[1 ].ptrw ();
207209 memcpy (w, dataCbCr, 2 * new_width * new_height);
208210 img[1 ].instantiate ();
211+ img[1 ]->set_data (new_width, new_height, 0 , Image::FORMAT_RG8, img_data[1 ]);
209212#else
210213 GodotUInt8Vector::Write w = img_data[1 ].write ();
211214 memcpy (w.ptr (), dataCbCr, 2 * new_width * new_height);
212215 img[1 ].instance ();
213- #endif
214-
215- // /TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion
216216 img[1 ]->create (new_width, new_height, 0 , Image::FORMAT_RG8, img_data[1 ]);
217+ #endif
217218 }
218219
219220 // set our texture...
0 commit comments