C#中的Spout Receiver / OpenGL - 语法错误

时间:2016-03-01 18:48:20

标签: c# opengl

我正在尝试创建一个通过Spout接收一系列图像的应用程序,但我无法弄清楚它的确切逻辑...... 我从未使用过OpenGL,因此对正确的语法不太了解......

所有信息都来自这里的帮助,看起来很好解释......但我无法正确理解如何使这个逻辑起作用......

https://github.com/matjacques/LightjamsSpout

以下是我的代码,我得到的只是一张静态图片...... 我得到了一个Bitmap的结果并放入了一个PictureBox ......

如何将这些图像放入OpenGL对象类型?

 public Form1()
    {
        InitializeComponent();

        try
        {
            string senderName = "";
            var receiver = new LightjamsSpoutLib.LightjamsSpoutReceiver();
            int nbSenders = receiver.NbSenders();
            for (int t = 0; t < nbSenders; ++t)
            {
                string name; int w, h;
                receiver.GetSenderInfo(t, out name, out w, out h);
                lblConnection.Text = name;
                senderName = name;

                // can instanciate the object in any thread
                LightjamsSpoutLib.GLContext m_glContext = new LightjamsSpoutLib.GLContext();
                m_glContext.Create();

                LightjamsSpoutLib.LightjamsSpoutReceiver m_receiver = new LightjamsSpoutLib.LightjamsSpoutReceiver();

                // the senderName as retrieved when enumerating senders or "" to use the active sender
                int m_width = 500;
                int m_height = 500;
                m_receiver.Connect(senderName, out m_width, out m_height);
                Bitmap m_bitmap = new Bitmap(m_width, m_height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                const int bytesPerPixel = 3;
                int stride = 4 * ((m_width * bytesPerPixel + 3) / 4);
                byte[] m_buffer = new byte[stride * m_height];

                var data = m_bitmap.LockBits(new Rectangle(0, 0, m_width, m_height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                m_receiver.ReceiveImageIntPtr((long)data.Scan0, LightjamsSpoutLib.EPixelFormat.BGR);
                m_bitmap.UnlockBits(data);

                // Put in PictureBox (Only Static)
                PictureBox Screen = new PictureBox();
                Screen.Height = m_height;
                Screen.Width = m_width;
                Screen.Image = m_bitmap;
                this.Controls.Add(Screen);
            }

        }
        catch (System.Runtime.InteropServices.COMException e)
        {
        }
    }

0 个答案:

没有答案