- Posts: 2
- Joined: Thu Mar 07, 2024 9:05 pm
- Real Name: Jad Harkous
Hello,
I am currently working on a node.js application where I want to display the frames captured by a DeckLink Mini Recorder 4K connected to a camera. I am trying to mimic the logic used in the CapturePreview sample of the SDK, but I am creating a WebGL context instead of an OpenGL one. I have a canvas in a html file and the following class for the canvas in the associated typescript file:
In the CapturePreview sample, the DeckLink screen preview helper is created in
When testing this, the result of CoCreateInstance is false as it should be, but I can't figure out why the result from my InitializeGL line is false. From what I understand, InitializeGL is a pure virtual function so it should be overriden somewhere to provide an implementation for it, but I don't see such an implementation in the CapturePreview sample so I'm having trouble figuring out what to do to use InitializeGL correctly. What should I do?
I am currently working on a node.js application where I want to display the frames captured by a DeckLink Mini Recorder 4K connected to a camera. I am trying to mimic the logic used in the CapturePreview sample of the SDK, but I am creating a WebGL context instead of an OpenGL one. I have a canvas in a html file and the following class for the canvas in the associated typescript file:
- Code: Select all
class PreviewWindow {
canvas: HTMLCanvasElement;
gl: WebGLRenderingContext;
constructor(public cameraControl: CameraControlService) {
// Initialize canvas and WebGL context
this.canvas = document.createElement('canvas');
this.canvas.id = 'glCanvas';
const previewBox = document.getElementById('previewBox');
previewBox?.appendChild(this.canvas);
this.gl = this.canvas.getContext('webgl') as WebGLRenderingContext;
this.cameraControl.initScreenPreviewHelper();
if (!this.gl) {
console.error('Unable to initialize WebGL. Your browser may not support it.');
// Handle initialization failure
this.showErrorMessage("This application was unable to initialise the preview window", "Error");
}
}
init(): void {
// Set WebGL rendering context attributes
this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true); // Enable alpha premultiplication
this.gl.enable(this.gl.BLEND);
this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
this.gl.clearColor(0.0, 0.0, 0.0, 1.0);
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
}
showErrorMessage(message: string, title: string): void {
console.error(title + ": " + message);
}
}
In the CapturePreview sample, the DeckLink screen preview helper is created in
- Code: Select all
bool PreviewWindow::init(CStatic *previewBox)
- Code: Select all
bool PreviewWindow::initOpenGL
- Code: Select all
void FrameCallback::initScreenPreviewHelper(){
// Create the DeckLink screen preview helper
bool result = CoCreateInstance(CLSID_CDeckLinkGL3ScreenPreviewHelper, NULL, CLSCTX_ALL, IID_IDeckLinkGLScreenPreviewHelper, (void**)&_deckLinkScreenPreviewHelper) != S_OK;
// Result should be false
std::cout << std::boolalpha << "CoCreateInstance result: " << result << std::endl;
// Result should be true
bool result2 = _deckLinkScreenPreviewHelper->InitializeGL() == S_OK;
std::cout << std::boolalpha << "deckLinkScreenPreviewHelper->InitializeGL result: " << result2 << std::endl;
}
When testing this, the result of CoCreateInstance is false as it should be, but I can't figure out why the result from my InitializeGL line is false. From what I understand, InitializeGL is a pure virtual function so it should be overriden somewhere to provide an implementation for it, but I don't see such an implementation in the CapturePreview sample so I'm having trouble figuring out what to do to use InitializeGL correctly. What should I do?