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); }
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); }
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(); }
// // 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(); }
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(); } }
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); }
/* 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; } }
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); }
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); }
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); }
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(); }
public uint threshold(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, string operation, uint threshold) { return 0; }
public uint threshold(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, string operation, uint threshold, uint color, uint mask, bool copySource) { return 0; }
public int pixelDissolve(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint) { return 0; }
public int pixelDissolve(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, int randomSeed, int numPixels) { return 0; }
public void paletteMap(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint) { return; }
/// <summary> /// Fills a drawing area with a bitmap image. /// </summary> public void beginBitmapFill(BitmapData bitmap, Matrix matrix, bool repeat) { return; }
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(); } }
public void copyPixels(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint) { return; }
public void copyChannel(BitmapData sourceBitmapData, Rectangle sourceRectangle, Point destination, BitmapDataChannel sourceChannel, BitmapDataChannel destinationChannel) { return; }
public void renderTo(double x, double y, BitmapData target) { var p = new Point(x, y); target.copyPixels(bitmapData, bitmapData.rect, p, null, null, true); }
/// <summary> /// Fills a drawing area with a bitmap image. /// </summary> public void beginBitmapFill(BitmapData bitmap, Matrix matrix) { return; }
public void drawToBitmapData(BitmapData destination) { throw new NotImplementedException(); }
public void applyFilter(BitmapData sourceBitmapData, Rectangle sourceRectangle, Point destination, BitmapFilter filter) { return; }
public void uploadFromBitmapData (BitmapData source, uint miplevel = 0) { throw new NotImplementedException(); }
public object compare(BitmapData otherBitmapData) { return null; }
/// <summary> /// Fills a drawing area with a bitmap image. /// </summary> public void beginBitmapFill(BitmapData bitmap) { return; }
public void copyPixels(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, BitmapData alphaBitmapData, Point alphaPoint, bool mergeAlpha) { return; }
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(); } }
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(); }
public void merge(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, uint redMultiplier, uint greenMultiplier, uint blueMultiplier, uint alphaMultiplier) { return; }
public void paletteMap(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, ByteArray redArray) { return; }
public void uploadFromBitmapData(BitmapData source) { throw new System.NotImplementedException(); }