Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From your code and help from <a href="http://basic4gl.wikispaces.com/2D+Drawing+in+OpenGL" rel="nofollow">http://basic4gl.wikispaces.com/2D+Drawing+in+OpenGL</a>, I got SharpGL displaying a video from EmguCV</p> <pre><code>public partial class FormSharpGLTexturesSample : Form { Capture capture; public FormSharpGLTexturesSample() { InitializeComponent(); // Get the OpenGL object, for quick access. SharpGL.OpenGL gl = this.openGLControl1.OpenGL; // A bit of extra initialisation here, we have to enable textures. gl.Enable(OpenGL.GL_TEXTURE_2D); gl.Disable(OpenGL.GL_DEPTH_TEST); // Create our texture object from a file. This creates the texture for OpenGL. capture = new Capture(@"Video file here"); } private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs e) { // Get the OpenGL object, for quick access. SharpGL.OpenGL gl = this.openGLControl1.OpenGL; int Width = openGLControl1.Width; int Height = openGLControl1.Height; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT); gl.LoadIdentity(); var frame = capture.QueryFrame(); texture.Destroy(gl); texture.Create(gl, frame.Bitmap); // Bind the texture. texture.Bind(gl); gl.Begin(OpenGL.GL_QUADS); gl.TexCoord(0.0f, 0.0f); gl.Vertex(0, 0, 0); gl.TexCoord(1.0f, 0.0f); gl.Vertex(Width, 0, 0); gl.TexCoord(1.0f, 1.0f); gl.Vertex(Width, Height, 0); gl.TexCoord(0.0f, 1.0f); gl.Vertex(0, Height, 0); gl.End(); gl.Flush(); } // The texture identifier. Texture texture = new Texture(); private void openGLControl1_Resized(object sender, EventArgs e) { SharpGL.OpenGL gl = this.openGLControl1.OpenGL; // Create an orthographic projection. gl.MatrixMode(MatrixMode.Projection); gl.LoadIdentity(); // NOTE: Basically no matter what I do, the only points I see are those at // the "near" surface (with z = -zNear)--in this case, I only see green points gl.Ortho(0, openGLControl1.Width, openGLControl1.Height, 0, 0, 1); // Back to the modelview. gl.MatrixMode(MatrixMode.Modelview); } } </code></pre> <p>I hope it helps.</p> <p>After some experiments, I could use TexImage2D but only with images having a width and height be a power of two</p> <p>Instead of:</p> <pre><code>var frame = capture.QueryFrame(); texture.Destroy(gl); texture.Create(gl, frame.Bitmap); </code></pre> <p>It can be replaced by the following block to update the data of the picture. I would like to know how to remove the need to call Resize.</p> <pre><code>var frame = capture.QueryFrame(); frame = frame.Resize(256, 256, Emgu.CV.CvEnum.INTER.CV_INTER_NN); Bitmap Bitmap = frame.Bitmap; BitmapData bitmapData = Bitmap.LockBits(new Rectangle(0, 0, Bitmap.Width, Bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); gl.BindTexture(OpenGL.GL_TEXTURE_2D, textures[0]); gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, OpenGL.GL_RGBA, Bitmap.Width, Bitmap.Height, 0, OpenGL.GL_BGR, OpenGL.GL_UNSIGNED_BYTE, bitmapData.Scan0); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR); // Required for TexImage2D gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR); // Required for TexImage2D </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload