public Smaa() { this.area_tex_unit = GLTextureUnit.Create() .SetTexture(GLTexture.Create().SetFormat(TextureFormat.RG).SetSize(AREATEX_WIDTH, AREATEX_HEIGHT) .SetData(SMAA_AREA_RAW)).SetWrap(GLWrap.ClampToEdge).SetFiltering(GLScaleFilter.Linear); this.search_tex_unit = GLTextureUnit.Create() .SetTexture(GLTexture.Create().SetFormat(TextureFormat.R).SetSize(SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT) .SetData(SMAA_SEARCH_RAW)).SetWrap(GLWrap.ClampToEdge).SetFiltering(GLScaleFilter.Nearest); CommonHeader = @" #version 410 compatibility #define SMAA_PIXEL_SIZE u_pixelSize.xy #define SMAA_PRESET_ULTRA 1 #define SMAA_GLSL_4 1 //#define SMAA_PREDICATION 0 #define SMAA_PREDICATION 1 #define attribute in " ; VertexHeader = CommonHeader + "\n" + "#define SMAA_ONLY_COMPILE_VS 1" + "\n" + @" uniform vec4 u_pixelSize; attribute vec4 a_position; attribute vec4 a_texcoords; " + SMAA_H + "\n"; FragmentHeader = CommonHeader + "\n" + "#define SMAA_ONLY_COMPILE_PS 1" + "\n" + @" uniform vec4 u_pixelSize; " + "\n" + SMAA_H; }
private static GLTexture GlTextureCreateFromBitmap(Bitmap bitmap) { return(GLTexture.Create() .SetFormat(TextureFormat.RGBA) .SetSize(bitmap.Width, bitmap.Height) .SetData(bitmap.GetChannelsDataInterleaved(BitmapChannelList.Rgba)) ); }
private void GetTexVram(Action <TexturePair> Action) { if (TexVram == null) { TexVram = GLTexture.Create().SetFormat(TextureFormat.RGBA).SetSize(1, 1); } //Console.WriteLine(TexVram); TexVram.Bind(); if (BufferGraphics == null) { BufferGraphics = Graphics.FromImage(Buffer); //BufferGraphics.Clear(Color.Red); BufferGraphics.Clear(Color.Black); } //if (PspDisplayForm.Singleton.WindowState == FormWindowState.Minimized) //{ // return; //} // //if (!PspDisplayForm.Singleton.EnableRefreshing) //{ // return; //} if (IGuiWindowInfo.EnableRefreshing) { try { int Width = 512; int Height = 272; var FrameAddress = PspDisplay.CurrentInfo.FrameAddress; byte *FrameBuffer = null; byte *DepthBuffer = null; try { FrameBuffer = (byte *)Memory.PspAddressToPointerSafe( FrameAddress, PixelFormatDecoder.GetPixelsSize(PspDisplay.CurrentInfo.PixelFormat, Width * Height) ); } catch (Exception Exception) { Console.Error.WriteLine(Exception); } //Console.Error.WriteLine("FrameBuffer == 0x{0:X}!!", (long)FrameBuffer); if (FrameBuffer == null) { //Console.Error.WriteLine("FrameBuffer == null!!"); } //Console.WriteLine("{0:X}", Address); var Hash = PixelFormatDecoder.Hash( PspDisplay.CurrentInfo.PixelFormat, (void *)FrameBuffer, Width, Height ); if (Hash != LastHash) { LastHash = Hash; Buffer.LockBitsUnlock(System.Drawing.Imaging.PixelFormat.Format32bppArgb, (BitmapData) => { var Count = Width * Height; fixed(OutputPixel * BitmapDataDecodePtr = BitmapDataDecode) { var BitmapDataPtr = (BGRA *)BitmapData.Scan0.ToPointer(); //var LastRow = (FrameBuffer + 512 * 260 * 4 + 4 * 10); //Console.WriteLine("{0},{1},{2},{3}", LastRow[0], LastRow[1], LastRow[2], LastRow[3]); if (FrameBuffer == null) { if (OldFrameBuffer != null) { Console.Error.WriteLine("FrameBuffer == null"); } } else if (BitmapDataPtr == null) { Console.Error.WriteLine("BitmapDataPtr == null"); } else { PixelFormatDecoder.Decode( PspDisplay.CurrentInfo.PixelFormat, (void *)FrameBuffer, BitmapDataDecodePtr, Width, Height ); } // Converts the decoded data to Window's format. for (int n = 0; n < Count; n++) { BitmapDataPtr[n].R = BitmapDataDecodePtr[n].B; BitmapDataPtr[n].G = BitmapDataDecodePtr[n].G; BitmapDataPtr[n].B = BitmapDataDecodePtr[n].R; BitmapDataPtr[n].A = 0xFF; } OldFrameBuffer = FrameBuffer; GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, 512, 272, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, BitmapDataPtr); TextureVerticalFlip = true; } }); } //else { //Console.WriteLine("Display not updated!"); } } catch (Exception Exception) { Console.Error.WriteLine(Exception); } } Action(new TexturePair() { Color = TexVram, Depth = GLTexture.Wrap(0) }); return; }
protected override void Init() { Texture = GLTexture.Create(); }