コード例 #1
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);
		}
コード例 #2
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);
		}
コード例 #3
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);
		}
コード例 #4
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);
		}
コード例 #5
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);
		}
コード例 #6
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();
		}
コード例 #7
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);
		}