Exemple #1
0
        private void dispatchDelayedTextureReady()
        {
            // load with a delay
            var timer = new flash.utils.Timer(1, 1);

            timer.addEventListener(TimerEvent.TIMER, (System.Action <Event>) this.OnTextureReady);
            timer.start();
        }
Exemple #2
0
        public void uploadCompressedTextureFromByteArray(ByteArray data, uint byteArrayOffset, bool async = false)
        {
            // $$TODO
            // this is empty for now
            System.Console.WriteLine("NotImplementedWarning: Texture.uploadCompressedTextureFromByteArray()");

            if (async)
            {
                // load with a delay
                var timer = new flash.utils.Timer(1, 1);
                timer.addEventListener(TimerEvent.TIMER, (System.Action <Event>) this.OnTextureReady);
                timer.start();
            }
        }
		public void uploadCompressedTextureFromByteArray (ByteArray data, uint byteArrayOffset, bool async = false)
		{
			// $$TODO 
			// this is empty for now
			System.Console.WriteLine("NotImplementedWarning: Texture.uploadCompressedTextureFromByteArray()");

			if (async) {
				// load with a delay
				var timer = new flash.utils.Timer(1, 1);
				timer.addEventListener(TimerEvent.TIMER, (System.Action<Event>)this.OnTextureReady );
				timer.start();
			}

		}
Exemple #4
0
        public void uploadCompressedTextureFromByteArray(ByteArray data, uint byteArrayOffset, bool async = false)
        {
            // $$TODO
            // this is empty for now
#if PLATFORM_MONOMAC
            System.Console.WriteLine("NotImplementedWarning: Texture.uploadCompressedTextureFromByteArray()");

            if (!mDidUpload)
            {
                var clearData = new BitmapData(32, 32, true, sColors[sColor % sColors.Length]);
                sColor++;
                uploadFromBitmapData(clearData);
                clearData.dispose();
                mDidUpload = true;
            }
#endif

#if PLATFORM_MONOTOUCH
            int memUsage = (mWidth * mHeight) / 2;
            sMemoryUsedForTextures += memUsage;
            Console.WriteLine("Texture.uploadCompressedTextureFromByteArray() - " + mWidth + "x" + mHeight + " - Mem: " + (memUsage / 1024) + " KB - Total Mem: " + (sMemoryUsedForTextures / 1024) + " KB");

            // Bind the texture
            GL.BindTexture(textureTarget, textureId);

            if (byteArrayOffset != 0)
            {
                throw new NotSupportedException();
            }

            int dataLength = (int)(data.length - byteArrayOffset) - 4;                          // We remove the 4 bytes footer
            // TODO: Fix hardcoded value here

            OpenTK.Graphics.ES20.PixelInternalFormat pixelFormat = (OpenTK.Graphics.ES20.PixelInternalFormat) 0x8C02;
            GL.CompressedTexImage2D(textureTarget, 0, pixelFormat, mWidth, mHeight, 0, dataLength, data.getRawArray());

            // unbind texture and pixel buffer
            GL.BindTexture(textureTarget, 0);
#endif
            if (async)
            {
                // load with a delay
                var timer = new flash.utils.Timer(1, 1);
                timer.addEventListener(TimerEvent.TIMER, (System.Action <Event>) this.OnTextureReady);
                timer.start();
            }
        }
Exemple #5
0
		public void uploadCompressedTextureFromByteArray (ByteArray data, uint byteArrayOffset, bool async = false)
		{
			// $$TODO 
			// this is empty for now
#if PLATFORM_MONOMAC
			System.Console.WriteLine("NotImplementedWarning: Texture.uploadCompressedTextureFromByteArray()");

			if (!mDidUpload) {
				var clearData = new BitmapData(32,32, true, sColors[sColor % sColors.Length]);
				sColor++; 
				uploadFromBitmapData(clearData);
				clearData.dispose();
				mDidUpload = true;
			}
#endif

#if PLATFORM_MONOTOUCH
			int memUsage = (mWidth * mHeight) / 2;
			sMemoryUsedForTextures += memUsage;
			Console.WriteLine("Texture.uploadCompressedTextureFromByteArray() - " + mWidth + "x" + mHeight + " - Mem: " + (memUsage / 1024) + " KB - Total Mem: " + (sMemoryUsedForTextures / 1024) + " KB");

			// Bind the texture
			GL.BindTexture (textureTarget, textureId);

			if (byteArrayOffset != 0) {
				throw new NotSupportedException();
			}

			int dataLength = (int)(data.length - byteArrayOffset) - 4;		// We remove the 4 bytes footer
																			// TODO: Fix hardcoded value here

			OpenTK.Graphics.ES20.PixelInternalFormat pixelFormat = (OpenTK.Graphics.ES20.PixelInternalFormat)0x8C02;
			GL.CompressedTexImage2D(textureTarget, 0, pixelFormat, mWidth, mHeight, 0, dataLength, data.getRawStream().ToArray());

			// unbind texture and pixel buffer
			GL.BindTexture (textureTarget, 0);
#endif
			if (async) {
				// load with a delay
				var timer = new flash.utils.Timer(1, 1);
				timer.addEventListener(TimerEvent.TIMER, (System.Action<Event>)this.OnTextureReady );
				timer.start();
			}
		}
Exemple #6
0
		private void dispatchDelayedTextureReady() {
			// load with a delay
			var timer = new flash.utils.Timer(1, 1);
			timer.addEventListener(TimerEvent.TIMER, (System.Action<Event>)this.OnTextureReady );
			timer.start();
		}
Exemple #7
0
		public void uploadCompressedTextureFromByteArray (ByteArray data, uint byteArrayOffset, bool async = false)
		{
#if PLATFORM_MONOMAC
			System.Console.WriteLine("NotImplementedWarning: Texture.uploadCompressedTextureFromByteArray()");

			if (!mDidUpload) {
				var clearData = new BitmapData(32,32, true, sColors[sColor % sColors.Length]);
				sColor++; 
				uploadFromBitmapData(clearData);
				clearData.dispose();
				mDidUpload = true;
			}
#endif

			// see if this is an ATF container
			data.position = byteArrayOffset;
			string signature = data.readUTFBytes(3);
			data.position = byteArrayOffset;
			if (signature == "ATF")
			{
				// Bind the texture
				GL.BindTexture (textureTarget, textureId);
				uploadATFTextureFromByteArray(data, byteArrayOffset);
				GL.BindTexture (textureTarget, 0);
				return;
			}


#if PLATFORM_MONOTOUCH || PLATFORM_MONODROID
			int memUsage = (mWidth * mHeight) / 2;
			sMemoryUsedForTextures += memUsage;
			Console.WriteLine("Texture.uploadCompressedTextureFromByteArray() - " + mWidth + "x" + mHeight + " - Mem: " + (memUsage / 1024) + " KB - Total Mem: " + (sMemoryUsedForTextures / 1024) + " KB");

			// Bind the texture
			GL.BindTexture (textureTarget, textureId);

			if (byteArrayOffset != 0) {
				throw new NotSupportedException();
			}

		#if PLATFORM_MONOTOUCH
			int dataLength = (int)(data.length - byteArrayOffset) - 4;		// We remove the 4 bytes footer
	
			// TODO: Fix hardcoded value here
			OpenTK.Graphics.ES20.PixelInternalFormat pixelFormat = (OpenTK.Graphics.ES20.PixelInternalFormat)0x8C02;

			GL.CompressedTexImage2D(textureTarget, 0, pixelFormat, mWidth, mHeight, 0, dataLength, data.getRawArray());
		#elif PLATFORM_MONODROID		
			data.position = 16; // skip the header
			int dataLength = ((int)data.length) - 16;

			GL.CompressedTexImage2D<byte>(textureTarget, 0, All.Etc1Rgb8Oes, mWidth, mHeight, 0, dataLength, data.getRawArray());
		#endif

			// unbind texture and pixel buffer
			GL.BindTexture (textureTarget, 0);
#endif

			if (async) {
				// load with a delay
				var timer = new flash.utils.Timer(1, 1);
				timer.addEventListener(TimerEvent.TIMER, (System.Action<Event>)this.OnTextureReady );
				timer.start();
			}
		}
Exemple #8
0
        public void uploadCompressedTextureFromByteArray(ByteArray data, uint byteArrayOffset, bool async = false)
        {
#if PLATFORM_MONOMAC
            System.Console.WriteLine("NotImplementedWarning: Texture.uploadCompressedTextureFromByteArray()");

            if (!mDidUpload)
            {
                var clearData = new BitmapData(32, 32, true, sColors[sColor % sColors.Length]);
                sColor++;
                uploadFromBitmapData(clearData);
                clearData.dispose();
                mDidUpload = true;
            }
#endif

            // see if this is an ATF container
            data.position = byteArrayOffset;
            string signature = data.readUTFBytes(3);
            data.position = byteArrayOffset;
            if (signature == "ATF")
            {
                // Bind the texture
                GL.BindTexture(textureTarget, textureId);
                GLUtils.CheckGLError();

                uploadATFTextureFromByteArray(data, byteArrayOffset);

                GL.BindTexture(textureTarget, 0);
                GLUtils.CheckGLError();
            }
            else
            {
#if PLATFORM_MONOTOUCH || PLATFORM_MONODROID
                int memUsage = (mWidth * mHeight) / 2;
                sMemoryUsedForTextures += memUsage;
                Console.WriteLine("Texture.uploadCompressedTextureFromByteArray() - " + mWidth + "x" + mHeight + " - Mem: " + (memUsage / 1024) + " KB - Total Mem: " + (sMemoryUsedForTextures / 1024) + " KB");

                // Bind the texture
                GL.BindTexture(textureTarget, textureId);
                GLUtils.CheckGLError();

                if (byteArrayOffset != 0)
                {
                    throw new NotSupportedException();
                }

                #if PLATFORM_MONOTOUCH
                int dataLength = (int)(data.length - byteArrayOffset) - 4;                      // We remove the 4 bytes footer

                // TODO: Fix hardcoded value here
                OpenTK.Graphics.ES20.PixelInternalFormat pixelFormat = (OpenTK.Graphics.ES20.PixelInternalFormat) 0x8C02;

                GL.CompressedTexImage2D(textureTarget, 0, pixelFormat, mWidth, mHeight, 0, dataLength, data.getRawArray());
                mAllocated = true;
                #elif PLATFORM_MONODROID
                data.position = 16;         // skip the header
                int dataLength = ((int)data.length) - 16;

                GL.CompressedTexImage2D <byte>(textureTarget, 0, All.Etc1Rgb8Oes, mWidth, mHeight, 0, dataLength, data.getRawArray());
                mAllocated = true;
                #endif

                trackCompressedMemoryUsage(dataLength);

                // unbind texture and pixel buffer
                GL.BindTexture(textureTarget, 0);
                GLUtils.CheckGLError();
#endif
            }

            if (async)
            {
                // load with a delay
                var timer = new flash.utils.Timer(1, 1);
                timer.addEventListener(TimerEvent.TIMER, (System.Action <Event>) this.OnTextureReady);
                timer.start();
            }
        }