- Posts: 4
- Joined: Fri Aug 26, 2016 8:08 pm
Hi again,
At this point I've got the framerate issue sorted out (thanks Nick!) but that didn't fix my black GL surface like I was hoping it would. I've followed the documentation's instructions and mimicked the functional CapturePreview C++ as much as possible but can't seem to get the frames to show. I've tested the SharpGL surface with other GL tasks and confirmed that it is functional, which means that I might not understand or have correctly implemented either the GLScreenPreviewHelper, or perhaps I've simply not setup the orthographic projection correctly (code adapted from documentation). I've confirmed the settings and device to be correct (by debugging the C++ project).
So that being said, does the code below look like I've correctly setup the surface and established the correct GL frame setting/painting sequence?
Thanks,
Andrew
At this point I've got the framerate issue sorted out (thanks Nick!) but that didn't fix my black GL surface like I was hoping it would. I've followed the documentation's instructions and mimicked the functional CapturePreview C++ as much as possible but can't seem to get the frames to show. I've tested the SharpGL surface with other GL tasks and confirmed that it is functional, which means that I might not understand or have correctly implemented either the GLScreenPreviewHelper, or perhaps I've simply not setup the orthographic projection correctly (code adapted from documentation). I've confirmed the settings and device to be correct (by debugging the C++ project).
So that being said, does the code below look like I've correctly setup the surface and established the correct GL frame setting/painting sequence?
Thanks,
Andrew
- Code: Select all
public partial class FormSharpGLTexturesSample : Form, IDeckLinkScreenPreviewCallback
{
private IDeckLinkInput m_deckLinkInput;
private IDeckLinkGLScreenPreviewHelper m_deckLinkScreenPreviewHelper;
private int frameCount = 0;
private bool glIsInitialized = false;
public FormSharpGLTexturesSample()
{
InitializeBlackMagicDevice();
InitializeComponent();
//SharpGL.OpenGL gl = this.openGLControl1.OpenGL;
//gl.Enable(OpenGL.GL_TEXTURE_2D);
openGLControl1.OpenGL.RenderContextProvider.MakeCurrent();
m_deckLinkScreenPreviewHelper.InitializeGL();
openGLControl1.OpenGL.MakeNothingCurrent();
glIsInitialized = true;
}
private void InitializeBlackMagicDevice()
{
IDeckLink m_deckLink;
IDeckLinkIterator deckLinkIterator = new CDeckLinkIterator();
deckLinkIterator.Next(out m_deckLink);
m_deckLinkScreenPreviewHelper = new CDeckLinkGLScreenPreviewHelper();
m_deckLinkInput = (IDeckLinkInput)m_deckLink;
m_deckLinkInput.SetScreenPreviewCallback(this);
m_deckLinkInput.EnableVideoInput(_BMDDisplayMode.bmdModeHD720p5994, _BMDPixelFormat.bmdFormat8BitYUV, _BMDVideoInputFlags.bmdVideoInputFlagDefault);
//m_deckLinkInput.EnableAudioInput(_BMDAudioSampleRate.bmdAudioSampleRate48kHz, _BMDAudioSampleType.bmdAudioSampleType16bitInteger, 2);
m_deckLinkInput.StartStreams();
}
public void DrawFrame(IDeckLinkVideoFrame theFrame)
{
if (!glIsInitialized) return;
m_deckLinkScreenPreviewHelper.SetFrame(theFrame);
openGLControl1.OpenGL.RenderContextProvider.MakeCurrent();
m_deckLinkScreenPreviewHelper.PaintGL();
openGLControl1.OpenGL.MakeNothingCurrent();
System.Runtime.InteropServices.Marshal.ReleaseComObject(theFrame);
//frameCount++;
}
private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs e)
{
SharpGL.OpenGL gl = this.openGLControl1.OpenGL;
gl.Viewport(0, 0, (int)openGLControl1.Width, (int)openGLControl1.Height);
gl.MatrixMode(MatrixMode.Projection);
gl.LoadIdentity();
gl.Ortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
gl.MatrixMode(MatrixMode.Modelview);
//this.label1.Text = frameCount.ToString();
}
}
Andrew Singer