示例#1
0
		public void uploadFromBitmapData (BitmapData source, uint miplevel = 0)
		{
			if (miplevel != 0) {
				throw new NotImplementedException();
			}

			// Bind the texture
			GL.BindTexture (TextureTarget.Texture2D, textureId);
			
			// Bind the PBO
			//GL.BindBuffer (BufferTarget.PixelUnpackBuffer, mBufferId);
			//GL.BufferData (BufferTarget.PixelUnpackBuffer, new IntPtr (mWidth * mHeight * sizeof(System.UInt32)), source.getRawData(), BufferUsageHint.StaticDraw);
			//GL.TexImage2D (TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, mWidth, mHeight, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);
			//GL.BindBuffer (BufferTarget.PixelUnpackBuffer, 0);

#if PLATFORM_MONOMAC
			GL.PixelStore (PixelStoreParameter.UnpackRowLength, 0);
#elif PLATFORM_MONOTOUCH
			GL.PixelStore (PixelStoreParameter.UnpackAlignment, 0);
#endif
			GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, mWidth, mHeight, 0, PixelFormat.Rgba, PixelType.UnsignedByte,source.getRawData());

			// Setup texture parameters
			GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear);
			GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
			GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)All.ClampToEdge);
			GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)All.ClampToEdge);

			// unbind texture and pixel buffer
			GL.BindTexture (TextureTarget.Texture2D, 0);
		}
示例#2
0
		public void uploadFromBitmapData (BitmapData source, uint miplevel = 0)
		{
			// Bind the texture
			GL.BindTexture (textureTarget, textureId);
			GL.TexImage2D(textureTarget, (int)miplevel, PixelInternalFormat.Rgba, mWidth, mHeight, 0, PixelFormat.Rgba, PixelType.UnsignedByte,source.getRawData());

			// unbind texture and pixel buffer
			GL.BindTexture (textureTarget, 0);
		}
示例#3
0
 public void setSize(int width, int height)
 {
     _width     = width;
     _height    = height;
     borderRect = new Rectangle(1, 1, _width - 2, _height - 2);
     boundsRect = new Rectangle(2, 2, _width - 4, _height - 4);
     bitmapData = new BitmapData(Renderer.GameSpriteSheet, width, height, true, 0x0);
     updateText();
     draw();
 }
示例#4
0
		//
		// Methods
		//

#if OPENGL

		public Texture(Context3D context, int width, int height, string format, 
		                        bool optimizeForRenderToTexture, int streamingLevels)
			: base(TextureTarget.Texture2D)
		{
			mContext = context;
			mWidth = width;
			mHeight = height;
			mFormat = format;
			mOptimizeForRenderToTexture = optimizeForRenderToTexture;
			mStreamingLevels = streamingLevels;

			// we do this to clear the texture on creation
			// $$TODO we dont need to allocate a bitmapdata to do this, we should just use a PBO and clear it
			var clearData = new BitmapData(width, height);
			uploadFromBitmapData(clearData);
			clearData.dispose();
		}
示例#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();
			}
		}
示例#6
0
		public void uploadFromBitmapData (BitmapData source, uint miplevel = 0, bool generateMipmap = false)
		{
			// Bind the texture
			GL.BindTexture (textureTarget, textureId);

#if PLATFORM_MONOMAC
            if (generateMipmap) {
                GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1);
            }
#endif

			GL.TexImage2D(textureTarget, (int)miplevel, PixelInternalFormat.Rgba, mWidth, mHeight, 0, PixelFormat.Rgba, PixelType.UnsignedByte,source.getRawData());

#if PLATFORM_MONOTOUCH
            GL.GenerateMipmap(textureTarget);
#endif

			// unbind texture and pixel buffer
			GL.BindTexture (textureTarget, 0);
		}
示例#7
0
        /* This must be called before any TextBox is created so sprites can be drawn */
        public static void init(Array <Rectangle> characterList, BitmapData _spriteSheet)
        {
            spriteSheet = _spriteSheet;
            characters  = new Dictionary <char, Rectangle>();
            char      characterName;
            Rectangle rect;

            for (int i = 0; i < characterList.length; i++)
            {
                if (characterList[i] != null)
                {
                    rect = characterList[i];
                }
                else
                {
                    rect = new Rectangle();
                }
                characterName             = characterNames[i];
                characters[characterName] = rect;
            }
        }
示例#8
0
		public void uploadFromBitmapData(BitmapData source, uint side, uint miplevel = 0, bool generateMipmap = false) {
			// bind the texture
#if PLATFORM_MONOMONO || PLATFORM_MONOMAC
			GL.BindTexture (textureTarget, textureId);
#elif PLATFORM_MONODROID
			GL.BindTexture((All) textureTarget, textureId);
#endif
			// determine which side of the cubmap to upload
			TextureTarget target;
			switch (side)
			{
			case 0: target = TextureTarget.TextureCubeMapPositiveX; break;
			case 1: target = TextureTarget.TextureCubeMapNegativeX; break;
			case 2: target = TextureTarget.TextureCubeMapPositiveY; break;
			case 3: target = TextureTarget.TextureCubeMapNegativeY; break;
			case 4: target = TextureTarget.TextureCubeMapPositiveZ; break;
			case 5: target = TextureTarget.TextureCubeMapNegativeZ; break;
			}

 #if PLATFORM_MONOMAC
			if (generateMipmap) {
                GL.TexParameter (textureTarget, TextureParameterName.GenerateMipmap, 1);
			}
#endif

			// perform upload
#if PLATFORM_MONOMAC || PLATFORM_MONOTOUCH
			GL.TexImage2D(target, (int)miplevel, PixelInternalFormat.Rgba, size, size, 0, PixelFormat.Rgba, PixelType.UnsignedByte, source.getRawData());
#elif PLATFORM_MONODROID
			GL.TexImage2D<uint>(target, (int)miplevel, (int) PixelInternalFormat.Rgba, size, size, 0, PixelFormat.Rgba, PixelType.UnsignedByte, source.getRawData());
#endif

#if PLATFORM_MONOTOUCH
			GL.GenerateMipmap(textureTarget);
#endif


			// unbind texture and pixel buffer
			GL.BindTexture (textureTarget, 0);
		}
示例#9
0
		public void uploadFromBitmapData(BitmapData source, uint side, uint miplevel = 0) {
			// bind the texture
			GL.BindTexture (textureTarget, textureId);

			// determine which side of the cubmap to upload
			TextureTarget target;
			switch (side)
			{
			case 0: target = TextureTarget.TextureCubeMapPositiveX; break;
			case 1: target = TextureTarget.TextureCubeMapNegativeX; break;
			case 2: target = TextureTarget.TextureCubeMapPositiveY; break;
			case 3: target = TextureTarget.TextureCubeMapNegativeY; break;
			case 4: target = TextureTarget.TextureCubeMapPositiveZ; break;
			case 5: target = TextureTarget.TextureCubeMapNegativeZ; break;
			}

			// perform upload
			GL.TexImage2D(target, (int)miplevel, PixelInternalFormat.Rgba, size, size, 0, PixelFormat.Rgba, PixelType.UnsignedByte, source.getRawData());

			// unbind texture and pixel buffer
			GL.BindTexture (textureTarget, 0);
		}
示例#10
0
		public void uploadFromBitmapData(BitmapData source, uint side, uint miplevel = 0) {

			if (miplevel != 0) {
				throw new NotImplementedException();
			}
			
			// Bind the texture
			GL.BindTexture (TextureTarget.TextureCubeMap, textureId);

			// determine which side of the cubmap to upload
			TextureTarget target;
			switch (side)
			{
			case 0: target = TextureTarget.TextureCubeMapPositiveX; break;
			case 1: target = TextureTarget.TextureCubeMapNegativeX; break;
			case 2: target = TextureTarget.TextureCubeMapPositiveY; break;
			case 3: target = TextureTarget.TextureCubeMapNegativeY; break;
			case 4: target = TextureTarget.TextureCubeMapPositiveZ; break;
			case 5: target = TextureTarget.TextureCubeMapNegativeZ; break;
			}

			#if PLATFORM_MONOMAC
			GL.PixelStore (PixelStoreParameter.UnpackRowLength, 0);
			#elif PLATFORM_MONOTOUCH
			GL.PixelStore (PixelStoreParameter.UnpackAlignment, 0);
			#endif
			GL.TexImage2D(target, 0, PixelInternalFormat.Rgba, size, size, 0, PixelFormat.Rgba, PixelType.UnsignedByte,source.getRawData());

			// Setup texture parameters
			GL.TexParameter (TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (int)All.Linear);
			GL.TexParameter (TextureTarget.TextureCubeMap, TextureParameterName.TextureMagFilter, (int)All.Linear);
			GL.TexParameter (TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapS, (int)All.ClampToEdge);
			GL.TexParameter (TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapT, (int)All.ClampToEdge);
			
			// unbind texture and pixel buffer
			GL.BindTexture (TextureTarget.TextureCubeMap, 0);
		}
示例#11
0
        public TextBox(double _width, double _height, uint backgroundCol = 0xFF111111, uint borderCol = 0xFF99999U)
        {
            this._width        = (int)_width;
            this._height       = (int)_height;
            this.backgroundCol = backgroundCol;
            this.borderCol     = borderCol;
            align            = "left";
            alignVert        = "top";
            _colorInt        = 0x00FFFFFF;
            wordWrap         = true;
            tracking         = 0;
            leading          = 1;
            whitespaceLength = 2;
            lineSpacing      = 8;
            _text            = "";

            lines = new Array <Array <Rectangle> >();

            borderRect = new Rectangle(0, 0, _width, _height);
            boundsRect = new Rectangle(0, 0, _width, _height);
            maskRect   = new Rectangle(0, 0, 1, 1);
            bitmapData = new BitmapData(Renderer.GameSpriteSheet, (int)_width, (int)_height, true, 0x0);
            drawBorder();
        }
示例#12
0
 public uint threshold(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, string operation,
     uint threshold)
 {
     return 0;
 }
示例#13
0
 public uint threshold(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, string operation,
     uint threshold, uint color, uint mask, bool copySource)
 {
     return 0;
 }
示例#14
0
 public int pixelDissolve(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint)
 {
     return 0;
 }
示例#15
0
 public int pixelDissolve(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, int randomSeed,
     int numPixels)
 {
     return 0;
 }
示例#16
0
 public void paletteMap(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint)
 {
     return;
 }
示例#17
0
 /// <summary>
 /// Fills a drawing area with a bitmap image.
 /// </summary>
 public void beginBitmapFill(BitmapData bitmap, Matrix matrix, bool repeat)
 {
     return;
 }
示例#18
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();
			}
		}
示例#19
0
 public void copyPixels(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint)
 {
     return;
 }
示例#20
0
 public void copyChannel(BitmapData sourceBitmapData, Rectangle sourceRectangle, Point destination,
     BitmapDataChannel sourceChannel, BitmapDataChannel destinationChannel)
 {
     return;
 }
示例#21
0
        public void renderTo(double x, double y, BitmapData target)
        {
            var p = new Point(x, y);

            target.copyPixels(bitmapData, bitmapData.rect, p, null, null, true);
        }
示例#22
0
 /// <summary>
 /// Fills a drawing area with a bitmap image.
 /// </summary>
 public void beginBitmapFill(BitmapData bitmap, Matrix matrix)
 {
     return;
 }
示例#23
0
		public void drawToBitmapData(BitmapData destination) 
		{
			throw new NotImplementedException();
		}
示例#24
0
 public void applyFilter(BitmapData sourceBitmapData, Rectangle sourceRectangle, Point destination, BitmapFilter filter)
 {
     return;
 }
示例#25
0
		public void uploadFromBitmapData (BitmapData source, uint miplevel = 0)
		{
			throw new NotImplementedException();
		}
示例#26
0
 public object compare(BitmapData otherBitmapData)
 {
     return null;
 }
示例#27
0
 /// <summary>
 /// Fills a drawing area with a bitmap image.
 /// </summary>
 public void beginBitmapFill(BitmapData bitmap)
 {
     return;
 }
示例#28
0
 public void copyPixels(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, BitmapData alphaBitmapData,
     Point alphaPoint, bool mergeAlpha)
 {
     return;
 }
示例#29
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

			// 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);

				if (async) {
					dispatchDelayedTextureReady();
				}

				return;
			}


#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) {
				dispatchDelayedTextureReady();
			}
		}
示例#30
0
		public void uploadFromBitmapData (BitmapData source, uint miplevel = 0, bool generateMipmap = false)
		{
			int memUsage = (mWidth * mHeight) * 4;
			sMemoryUsedForTextures += memUsage;
			Console.WriteLine("Texture.uploadFromBitmapData() - " + mWidth + "x" + mHeight + " - Mem: " + (memUsage / 1024) + " KB - Total Mem: " + (sMemoryUsedForTextures / 1024) + " KB");

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

#if PLATFORM_MONOMAC
            if (generateMipmap) {
                GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1);
            }
#endif

			GL.TexImage2D(textureTarget, (int)miplevel, PixelInternalFormat.Rgba, mWidth, mHeight, 0, PixelFormat.Rgba, PixelType.UnsignedByte,source.getRawData());

#if PLATFORM_MONOTOUCH
            GL.GenerateMipmap(textureTarget);
#endif

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

			source.dispose();
		}
示例#31
0
 public void merge(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, uint redMultiplier,
     uint greenMultiplier, uint blueMultiplier, uint alphaMultiplier)
 {
     return;
 }
示例#32
0
 public void paletteMap(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, ByteArray redArray)
 {
     return;
 }
		public void uploadFromBitmapData(BitmapData source) {
			throw new System.NotImplementedException();
		}