Esempio n. 1
0
        void ReleaseInstance()
        {
            TextureWriter.twGuardBegin();
            otpAPI.otpGuardBegin();

            // release ports & params
            otpAPI.otpDestroyImage(m_img_src);
            m_img_src = default(otpAPI.otpImage);

            otpAPI.otpEraseDeferredCall(m_otp_render); m_otp_render   = 0;
            TextureWriter.twEraseDeferredCall(m_tw_read); m_tw_read   = 0;
            TextureWriter.twEraseDeferredCall(m_tw_write); m_tw_write = 0;
            if (m_ports != null)
            {
                foreach (var port in m_ports)
                {
                    port.Release();
                }
            }

            m_ports  = null;
            m_params = null;

            // release instance
            otpAPI.otpDestroyInstance(m_inst);
            m_inst.ptr = IntPtr.Zero;

            otpAPI.otpGuardEnd();
            TextureWriter.twGuardEnd();
        }
Esempio n. 2
0
        void UpdateInputImages(Texture rt_src)
        {
            if (rt_src != null)
            {
                // copy rt_src content to memory
                if (!m_img_src)
                {
                    m_img_src = otpAPI.otpCreateImage();
                }
                otpAPI.otpResizeImage(m_img_src, rt_src.width, rt_src.height);

                var src_data = default(otpAPI.otpImageData);
                otpAPI.otpGetImageData(m_img_src, ref src_data);
                m_tw_read = TextureWriter.ReadDeferred(
                    src_data.data, src_data.width * src_data.height, TextureWriter.twPixelFormat.RGBAu8, rt_src, m_tw_read);
                GL.IssuePluginEvent(GetTWEvent(), m_tw_read);
            }


            foreach (var port in m_ports)
            {
                if (port.input != null)
                {
                    var     image = port.GetImage();
                    Texture input = port.GetUncompressedInput();
                    otpAPI.otpResizeImage(image, input.width, input.height);

                    var idata = default(otpAPI.otpImageData);
                    otpAPI.otpGetImageData(image, ref idata);
                    port.tw_read = TextureWriter.ReadDeferred(
                        idata.data, idata.width * idata.height, TextureWriter.twPixelFormat.RGBAu8, input, port.tw_read);
                    GL.IssuePluginEvent(GetTWEvent(), port.tw_read);
                }
            }
        }
Esempio n. 3
0
 public otpAPI.otpImage GetImage()
 {
     if (!image)
     {
         image = otpAPI.otpCreateImage();
     }
     return(image);
 }
Esempio n. 4
0
 public void Release()
 {
     if (rt != null)
     {
         rt.Release();
         rt = null;
     }
     if (tw_read != 0)
     {
         TextureWriter.twEraseDeferredCall(tw_read);
         tw_read = 0;
     }
     if (image)
     {
         otpAPI.otpDestroyImage(image);
         image = default(otpAPI.otpImage);
     }
 }