public void Dispose()
        {
            RocketInterface.Instance.TextureLoaded -= renderOnNextFrame;

            if (RocketWidgetDisposing != null)
            {
                RocketWidgetDisposing.Invoke(this);
            }

            RocketWidgetManager.rocketWidgetDisposed(name);
            imageBox.MouseButtonPressed  -= imageBox_MouseButtonPressed;
            imageBox.MouseButtonReleased -= imageBox_MouseButtonReleased;
            imageBox.MouseMove           -= imageBox_MouseMove;
            imageBox.MouseDrag           -= imageBox_MouseMove;
            imageBox.MouseWheel          -= imageBox_MouseWheel;
            imageBox.KeyButtonPressed    -= imageBox_KeyButtonPressed;
            imageBox.KeyButtonReleased   -= imageBox_KeyButtonReleased;
            imageBox.EventScrollGesture  -= imageBox_EventScrollGesture;

            //In mygui lost/got focus is mouse entered / left
            imageBox.MouseSetFocus      -= imageBox_MouseSetFocus;
            imageBox.MouseLostFocus     -= imageBox_MouseLostFocus;
            imageBox.RootKeyChangeFocus -= imageBox_RootKeyChangeFocus;

            if (context != null)
            {
                context.Dispose();
            }
            if (vp != null)
            {
                renderTexture.destroyViewport(vp);
            }
            if (pixelBuffer != null)
            {
                pixelBuffer.Dispose();
            }
            if (texture != null)
            {
                texture.Dispose();
                RenderManager.Instance.destroyTexture(textureName);
            }
            if (camera != null)
            {
                sceneManager.destroyCamera(camera);
            }
            if (sceneManager != null)
            {
                Root.getSingleton().destroySceneManager(sceneManager);
            }
        }
 public void Dispose()
 {
     Reset();
     pixelBuffer.Dispose();
     TextureManager.getInstance().remove(texture);
     texture.Dispose();
 }
        protected unsafe void setupVideoGraphicsObject()
        {
            this.mCubeTexture = TextureManager.Singleton.CreateManual(
                "MyCubeTexture",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D,
                (uint)this.TexWidth,
                (uint)this.TexHeight,
                0,
                Mogre.PixelFormat.PF_A8R8G8B8);

            MaterialPtr inMat = MaterialManager.Singleton.Create("MyCubeMat", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            inMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("MyCubeTexture");
            mCubeEntity.SetMaterialName("MyCubeMat");

            // draw bitmap to texture
            HardwarePixelBufferSharedPtr texBuffer = this.mCubeTexture.GetBuffer();

            texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
            PixelBox pb = texBuffer.CurrentLock;

            using (Bitmap bm = new Bitmap(
                       (int)this.mCubeTexture.Width,
                       (int)this.mCubeTexture.Height,
                       (int)((this.mCubeTexture.Width * 4) + (pb.RowSkip * 4)),
                       System.Drawing.Imaging.PixelFormat.Format32bppArgb,
                       pb.data))
            {
                mVideoGraphics = Graphics.FromImage(bm);
            }

            texBuffer.Unlock();
            texBuffer.Dispose();
        }
 public void Dispose()
 {
     renderTexture.Dispose();
     renderTexture = null;
     pixelBuffer.Dispose();
     TextureManager.getInstance().remove(texture);
     texture.Dispose();
     fullBitmapBox.Dispose();
     fullBitmap.Dispose();
 }
Beispiel #5
0
 private void destroyTexture()
 {
     if (physicalTexture != null)
     {
         buffer.Dispose();
         TextureManager.getInstance().remove(physicalTexture);
         physicalTexture.Dispose();
         physicalTexture = null;
     }
 }
        private unsafe void ConvertBitmap(Bitmap pTextureBitmap)
        {
            if (this.mCubeTexture == null)
            {
                this.mCubeTexture = TextureManager.Singleton.CreateManual(
                    "MyCubeTexture",
                    ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                    TextureType.TEX_TYPE_2D,
                    (uint)this.TexWidth,
                    (uint)this.TexHeight,
                    0,
                    Mogre.PixelFormat.PF_A8R8G8B8);

                MaterialPtr inMat = MaterialManager.Singleton.Create("MyCubeMat", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
                inMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("MyCubeTexture");
                mCubeEntity.SetMaterialName("MyCubeMat");
            }

            if (pTextureBitmap != null)
            {
                // draw bitmap to texture
                HardwarePixelBufferSharedPtr texBuffer = this.mCubeTexture.GetBuffer();

                texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
                PixelBox pb = texBuffer.CurrentLock;

                using (Bitmap bm = new Bitmap(
                           (int)this.mCubeTexture.Width,
                           (int)this.mCubeTexture.Height,
                           (int)((this.mCubeTexture.Width * 4) + (pb.RowSkip * 4)),
                           System.Drawing.Imaging.PixelFormat.Format32bppArgb,
                           pb.data))
                {
                    using (Graphics g = Graphics.FromImage(bm))
                    {
                        //g.DrawImage(this.mTextureBitmap, 0, 0);
                        g.DrawImage(pTextureBitmap, new System.Drawing.Rectangle(0, 0, (int)this.mCubeTexture.Width, (int)this.mCubeTexture.Height));
                    }
                }

                texBuffer.Unlock();
                texBuffer.Dispose();
            }


            /*
             * // draw bitmap to texture
             * HardwarePixelBufferSharedPtr texBuffer = this.mCubeTexture.GetBuffer();
             * texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
             * mVideoGraphics.DrawImage(this.mTextureBitmap, new System.Drawing.Rectangle(0, 0, (int)this.mCubeTexture.Width, (int)this.mCubeTexture.Height));
             * texBuffer.Unlock();
             */
        }
Beispiel #7
0
 private void destroyColorTexture()
 {
     if (colorTexture != null)
     {
         sensorManager.SensorColorFrameReady -= sensorManager_SensorColorFrameReady;
         setColorImageIcon(); //Because we set this to something with an actual texture, it will replace the texture set when created (that happens in the function called).
         RenderManager.Instance.destroyTexture(colorTexture.Value.getName());
         pixelBox.Dispose();
         hwBuffer.Dispose();
         colorTexture.Dispose();
         colorTexture = null;
     }
 }
Beispiel #8
0
        public void Dispose()
        {
            Stream.GetFrameClose();
            PixelBuffer.Dispose();
            screen.Dispose();
            videoMat.Dispose();
            videoTex.Dispose();

            videoTex    = null;
            videoMat    = null;
            screen      = null;
            PixelBuffer = null;
            FrameNum    = 0;
        }
Beispiel #9
0
        public override void Dispose()
        {
            base.Dispose();

            resourceLoader.Dispose();
            if (pixelBuffer != null)
            {
                pixelBuffer.Dispose();
            }
            if (texture != null)
            {
                TextureManager.getInstance().remove(texture);
                texture.Dispose();
            }
        }
Beispiel #10
0
        public unsafe void Replace2(byte[] bytes, string textureName)
        {
            if (this.IndexOf(textureName) < 0)
            {
                throw new ArgumentException("The texture \"" + textureName + "\"doesn't exist");
            }
            TexturePtr pTexture = this[textureName];
            HardwarePixelBufferSharedPtr texBuffer = pTexture.GetBuffer();

            texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
            PixelBox pb = texBuffer.CurrentLock;

            Marshal.Copy(bytes, 0, pb.data, bytes.Length);
            texBuffer.Unlock();
            texBuffer.Dispose();
        }
Beispiel #11
0
        public unsafe void Replace3(byte[] bytes, string textureName)
        {
            using (ResourcePtr rpt = TextureManager.Singleton.GetByName(textureName))
            {
                using (TexturePtr texture = rpt)
                {
                    HardwarePixelBufferSharedPtr texBuffer = texture.GetBuffer();
                    texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
                    PixelBox pb = texBuffer.CurrentLock;

                    Marshal.Copy(bytes, 0, pb.data, bytes.Length);

                    texBuffer.Unlock();
                    texBuffer.Dispose();
                }
            }
        }
Beispiel #12
0
        private static unsafe void ConvertImageToTexture(Bitmap image, string textureName, Size size)
        {
            int width  = size.Width;
            int height = size.Height;

            using (ResourcePtr rpt = TextureManager.Singleton.GetByName(textureName))
            {
                using (TexturePtr texture = rpt)
                {
                    HardwarePixelBufferSharedPtr texBuffer = texture.GetBuffer();
                    texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
                    PixelBox pb = texBuffer.CurrentLock;

                    System.Drawing.Imaging.BitmapData data = image.LockBits(new System.Drawing.Rectangle(0, 0, width, height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                    CopyMemory(pb.data, data.Scan0, (uint)(width * height * 4));
                    image.UnlockBits(data);

                    texBuffer.Unlock();
                    texBuffer.Dispose();
                }
            }
        }
Beispiel #13
0
 public void Dispose()
 {
     Stream.GetFrameClose();
     PixelBuffer.Dispose();
     FrameNum = 0;
 }