mirror of
https://github.com/libretro/RetroArch
synced 2024-12-28 09:29:16 +00:00
[EMSCRIPTEN] partially implement raw fb camera mode
need to add RGBA->XRGB conversion
This commit is contained in:
parent
79a4f790fe
commit
0bb6c4aafc
@ -58,7 +58,7 @@ var LibraryRWebCam = {
|
||||
RWC.contexts[data] = null;
|
||||
},
|
||||
|
||||
RWebCamStart__deps: ['glGenTextures', 'glBindTexture', 'glGetIntegerv', 'glTexParameteri'],
|
||||
RWebCamStart__deps: ['glGenTextures', 'glBindTexture', 'glGetIntegerv', 'glTexParameteri', 'malloc'],
|
||||
RWebCamStart: function(data) {
|
||||
var ret = 0;
|
||||
if (RWC.contexts[data].glTex) {
|
||||
@ -79,15 +79,28 @@ var LibraryRWebCam = {
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
if (RWC.contexts[data].rawFb) {
|
||||
RWC.contexts[data].rawFbCanvas = document.createElement("canvas");
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
RWebCamStop__deps: ['glDeleteTextures'],
|
||||
RWebCamStop__deps: ['glDeleteTextures', 'free'],
|
||||
RWebCamStop: function(data) {
|
||||
if (RWC.contexts[data].glTexId) {
|
||||
_glDeleteTextures(1, RWC.contexts[data].glTexId);
|
||||
}
|
||||
|
||||
if (RWC.contexts[data].rawFbCanvas) {
|
||||
if (RWC.contexts[data].rawBuffer) {
|
||||
_free(RWC.contexts[data].rawBuffer);
|
||||
RWC.contexts[data].rawBuffer = 0;
|
||||
RWC.contexts[data].rawFbCanvasCtx = null
|
||||
}
|
||||
RWC.contexts[data].rawFbCanvas = null;
|
||||
}
|
||||
},
|
||||
|
||||
RWebCamPoll__deps: ['glBindTexture', 'glGetIntegerv'],
|
||||
@ -111,6 +124,22 @@ var LibraryRWebCam = {
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
if (RWC.contexts[data].rawFbCanvas && frame_raw_cb !== 0)
|
||||
{
|
||||
if (!RWC.contexts[data].rawFbCanvasCtx) {
|
||||
RWC.contexts[data].rawFbCanvas.width = RWC.contexts[data].videoElement.videoWidth;
|
||||
RWC.contexts[data].rawFbCanvas.height = RWC.contexts[data].videoElement.videoHeight;
|
||||
RWC.contexts[data].rawFbCanvasCtx = RWC.contexts[data].rawFbCanvas.getContext("2d");
|
||||
RWC.contexts[data].rawBuffer = _malloc(RWC.contexts[data].videoElement.videoWidth * RWC.contexts[data].videoElement.videoHeight * 4);
|
||||
}
|
||||
RWC.contexts[data].rawFbCanvasCtx.drawImage(RWC.contexts[data].videoElement, 0, 0, RWC.contexts[data].rawFbCanvas.width, RWC.contexts[data].rawFbCanvas.height);
|
||||
var image = RWC.contexts[data].rawFbCanvasCtx.getImageData(0, 0, RWC.contexts[data].videoElement.videoWidth, RWC.contexts[data].videoElement.videoHeight);
|
||||
Module.HEAPU8.set(image.data, RWC.contexts[data].rawBuffer);
|
||||
Runtime.dynCall('viiii', frame_raw_cb, [RWC.contexts[data].rawBuffer, RWC.contexts[data].videoElement.videoWidth, RWC.contexts[data].videoElement.videoHeight, RWC.contexts[data].videoElement.videoWidth * 4]);
|
||||
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user