void BuildTexture() { GL.GenTextures(1, out _textureId); #if DEBUG System.Diagnostics.Debug.WriteLine("texture_id" + _textureId); #endif //bind GL.BindTexture(TextureTarget.Texture2D, _textureId); if (_memBitmap != null) { GL.TexImage2D((TextureTarget2d)TextureTarget.Texture2D, 0, (TextureComponentCount)PixelInternalFormat.Rgba, _width, _height, 0, PixelFormat.Rgba, // PixelType.UnsignedByte, PixelFarm.CpuBlit.MemBitmap.GetBufferPtr(_memBitmap).Ptr); } else { IntPtr bmpScan0 = _bmpBufferProvider.GetRawBufferHead(); GL.TexImage2D((TextureTarget2d)TextureTarget.Texture2D, 0, (TextureComponentCount)PixelInternalFormat.Rgba, _width, _height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, (IntPtr)bmpScan0); _bmpBufferProvider.ReleaseBufferHead(); _bmpBufferProvider.NotifyUsage(); } GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); }
void BuildFromExistingBitmap() { GL.GenTextures(1, out _textureId); #if DEBUG System.Diagnostics.Debug.WriteLine("gen texture_id:" + _textureId); #endif //test convert from BGRA to RGBA //bind GL.BindTexture(TextureTarget.Texture2D, _textureId); if (_memBitmap != null) { GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, _width, _height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, PixelFarm.CpuBlit.MemBitmap.GetBufferPtr(_memBitmap).Ptr); } else { IntPtr bmpScan0 = _bmpBufferProvider.GetRawBufferHead(); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, _width, _height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, bmpScan0); _bmpBufferProvider.ReleaseBufferHead(); #if DEBUG _bmpBufferProvider.dbugNotifyUsage(); #endif } //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest); //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); }