public void Blit() { if (msaa) { NativeGL.nglBlitFBO(FBO, WRITE_FBO, width, height); } }
public void Dispose() { if (Disposed) { return; } Disposed = true; NativeGL.nglDeleteFramebuffer(FBO); Opengl32.glDeleteTextures(1, new int[] { Texture }); }
public static int LoadTexture(Bitmap bmp) { BitmapData dat = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); IntPtr rgba = Marshal.AllocHGlobal(4 * bmp.Width * bmp.Height); NativeGL.nglARGBtoRGBA(rgba, dat.Scan0, bmp.Width * bmp.Height); int tex = LoadTexture(rgba, bmp.Width, bmp.Height); bmp.UnlockBits(dat); Marshal.FreeHGlobal(rgba); return(tex); }
public FrameBufferObject(int width, int height, int samples = 0) { Console.WriteLine("Create FBO {0}", Thread.CurrentThread.ManagedThreadId); this.width = width; this.height = height; this.msaa = samples > 0; if (!this.msaa) { Texture = Util.LoadTexture(IntPtr.Zero, width, height); FBO = NativeGL.nglCreateFBO(Texture, width, height); } else { int tex = 0; texture1 = Util.LoadTexture(IntPtr.Zero, width, height); FBO = NativeGL.nglCreateFBOMultisampling(ref tex, width, height, samples); WRITE_FBO = NativeGL.nglCreateFBO(texture1, width, height); this.Texture = texture1; } }
public void Unbind() { NativeGL.nglBindFramebuffer(0); }
public void Bind() { NativeGL.nglBindFramebuffer(FBO); }