コード例 #1
0
ファイル: Texture.cs プロジェクト: robterrell/playscript-mono
		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
ファイル: Texture.cs プロジェクト: rajorshi/playscript-mono
		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
ファイル: TextBox.cs プロジェクト: antonargunov/EndingXNA
 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
ファイル: Texture.cs プロジェクト: robterrell/playscript-mono
		//
		// 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
ファイル: Texture.cs プロジェクト: johnv315/playscript-mono
		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
ファイル: Texture.cs プロジェクト: OpenFlex/playscript-mono
		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
ファイル: TextBox.cs プロジェクト: antonargunov/EndingXNA
        /* 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
ファイル: TextBox.cs プロジェクト: antonargunov/EndingXNA
        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
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public uint threshold(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, string operation,
     uint threshold)
 {
     return 0;
 }
コード例 #13
0
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public uint threshold(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, string operation,
     uint threshold, uint color, uint mask, bool copySource)
 {
     return 0;
 }
コード例 #14
0
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public int pixelDissolve(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint)
 {
     return 0;
 }
コード例 #15
0
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public int pixelDissolve(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, int randomSeed,
     int numPixels)
 {
     return 0;
 }
コード例 #16
0
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public void paletteMap(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint)
 {
     return;
 }
コード例 #17
0
ファイル: Graphics.cs プロジェクト: gamificationvn/cstoas3
 /// <summary>
 /// Fills a drawing area with a bitmap image.
 /// </summary>
 public void beginBitmapFill(BitmapData bitmap, Matrix matrix, bool repeat)
 {
     return;
 }
コード例 #18
0
ファイル: Texture.cs プロジェクト: rlfqudxo/playscript-mono
		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
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public void copyPixels(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint)
 {
     return;
 }
コード例 #20
0
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public void copyChannel(BitmapData sourceBitmapData, Rectangle sourceRectangle, Point destination,
     BitmapDataChannel sourceChannel, BitmapDataChannel destinationChannel)
 {
     return;
 }
コード例 #21
0
ファイル: TextBox.cs プロジェクト: antonargunov/EndingXNA
        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
ファイル: Graphics.cs プロジェクト: gamificationvn/cstoas3
 /// <summary>
 /// Fills a drawing area with a bitmap image.
 /// </summary>
 public void beginBitmapFill(BitmapData bitmap, Matrix matrix)
 {
     return;
 }
コード例 #23
0
ファイル: Context3D.cs プロジェクト: Joe-xXx/playscript-mono
		public void drawToBitmapData(BitmapData destination) 
		{
			throw new NotImplementedException();
		}
コード例 #24
0
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public void applyFilter(BitmapData sourceBitmapData, Rectangle sourceRectangle, Point destination, BitmapFilter filter)
 {
     return;
 }
コード例 #25
0
ファイル: Texture.cs プロジェクト: johnv315/playscript-mono
		public void uploadFromBitmapData (BitmapData source, uint miplevel = 0)
		{
			throw new NotImplementedException();
		}
コード例 #26
0
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public object compare(BitmapData otherBitmapData)
 {
     return null;
 }
コード例 #27
0
ファイル: Graphics.cs プロジェクト: gamificationvn/cstoas3
 /// <summary>
 /// Fills a drawing area with a bitmap image.
 /// </summary>
 public void beginBitmapFill(BitmapData bitmap)
 {
     return;
 }
コード例 #28
0
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public void copyPixels(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, BitmapData alphaBitmapData,
     Point alphaPoint, bool mergeAlpha)
 {
     return;
 }
コード例 #29
0
ファイル: Texture.cs プロジェクト: NinZine/playscript-mono
		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
ファイル: Texture.cs プロジェクト: johnv315/playscript-mono
		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
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public void merge(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, uint redMultiplier,
     uint greenMultiplier, uint blueMultiplier, uint alphaMultiplier)
 {
     return;
 }
コード例 #32
0
ファイル: BitmapData.cs プロジェクト: gamificationvn/cstoas3
 public void paletteMap(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, ByteArray redArray)
 {
     return;
 }
コード例 #33
0
		public void uploadFromBitmapData(BitmapData source) {
			throw new System.NotImplementedException();
		}