public static Bitmap ScreenShot(int xx, int yy, int width, int height, ReadBufferMode buffer) { Bitmap transfermap = new Bitmap(width, height); System.Drawing.Imaging.BitmapData data = transfermap.LockBits(new Rectangle(0, 0, transfermap.Width, transfermap.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); GL.ReadBuffer(buffer); GL.ReadPixels(xx, yy, transfermap.Width, transfermap.Height, OpenTK.Graphics.OpenGL4.PixelFormat.Rgba, PixelType.UnsignedByte, data.Scan0); unsafe { int PixelSize = 4; unsafe { for (int y = 0; y < data.Height; y++) { byte* row = (byte*)data.Scan0 + (y * data.Stride); for (int x = 0; x < data.Width; x++) { byte r = row[x * PixelSize + 2]; byte b = row[x * PixelSize]; row[x * PixelSize] = r; row[x * PixelSize + 2] = b; } } } } transfermap.UnlockBits(data); transfermap.RotateFlip(RotateFlipType.RotateNoneFlipY); return transfermap; }
public static void FramebufferReadBufferEXT(UInt32 framebuffer, ReadBufferMode mode) { Debug.Assert(Delegates.pglFramebufferReadBufferEXT != null, "pglFramebufferReadBufferEXT not implemented"); Delegates.pglFramebufferReadBufferEXT(framebuffer, (Int32)mode); CallLog("glFramebufferReadBufferEXT({0}, {1})", framebuffer, mode); DebugCheckErrors(); }
internal static extern void glReadBuffer(ReadBufferMode mode);
//public void RasterPos4s(short x, short y, short z, short w) //{ // gl.glRasterPos4s(x, y, z, w); //} //public void RasterPos4sv(short[] v) //{ // gl.glRasterPos4sv(v); //} #endregion #endregion public void ReadBuffer(ReadBufferMode mode) { gl.glReadBuffer((int)mode); }
public static void ReadBuffer(ReadBufferMode mode) { Delegates.glReadBuffer(mode); }
public static extern void glReadBuffer(ReadBufferMode mode);
public static void ReadBuffer(ReadBufferMode mode) { glReadBuffer deleg = BaseGraphicsContext.Current.Loader.Get<glReadBuffer>(); if (deleg != null) deleg(mode); }
///<summary> Blit from read FB into this, x0/y0/x1/y1 are source area, dx0/dy0/dx1/dy1 are destination area. ///Mask indicates what buffer contents are to be copied: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT and GL_STENCIL_BUFFER_BIT. ///Filt is the interpolation filter, GL_NEAREST or GL_LINEAR ///</summary> public void Blit(GLFrameBuffer read, ReadBufferMode src, int x0, int y0, int x1, int y1, int dx0, int dy0, int dx1, int dy1, ClearBufferMask mask, BlitFramebufferFilter filt) { GL.NamedFramebufferReadBuffer(read.Id, src); GL.BlitNamedFramebuffer(read.Id, Id, x0, y0, x1, y1, dx0, dy0, dx1, dy1, mask, filt); GLStatics.Check(); }
public void ReadBuffer(ReadBufferMode readBufferMode) { GL.ReadBuffer(readBufferMode); }
public static void glReadBuffer(ReadBufferMode src) { i_OpenGL1_1.glReadBuffer(src); }
// Bind Read Attachements Only public void bindAttachements(ReadBufferMode read_attachement) { GL.ReadBuffer(read_attachement); }
// Bind to Read public void bind(ReadBufferMode read_attachement) { GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, _id); bindAttachements(read_attachement); }
public void SetReadBuffer(ReadBufferMode mode) { GL.ReadBuffer(mode); }
/// <summary> /// Read this GraphicsSurface color buffer. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> /// </param> /// <param name="rBuffer"> /// A <see cref="ReadBufferMode"/> that specify the read buffer where the colors are read from. /// </param> /// <param name="x"> /// A <see cref="Int32"/> that specify the x coordinate of the lower left corder of the rectangle area to read. /// </param> /// <param name="y"> /// A <see cref="Int32"/> that specify the y coordinate of the lower left corder of the rectangle area to read. /// </param> /// <param name="width"> /// A <see cref="Int32"/> that specify the width of the rectangle area to read. /// </param> /// <param name="height"> /// A <see cref="Int32"/> that specify the height of the rectangle area to read. /// </param> /// <param name="pType"> /// A <see cref="PixelLayout"/> which determine the pixel storage of the returned image. /// </param> /// <returns> /// It returns an <see cref="Image"/> representing the current read buffer <paramref name="rBuffer"/>. /// </returns> protected Image ReadBuffer(GraphicsContext ctx, ReadBufferMode rBuffer, uint x, uint y, uint width, uint height, PixelLayout pType) { Image image = null; if ((x + width > Width) || (y + height > Height)) throw new ArgumentException("specified region lies outside the GraphicsSurface"); // Bind for reading BindRead(ctx); // Set for reading Gl.ReadBuffer(rBuffer); // Allocate image holding data read image = new Image(); image.Create(pType, width, height); // Set pixel transfer foreach (int alignment in new int[] { 8, 4, 2, 1 }) { if (image.Stride % alignment == 0) { Gl.PixelStore(PixelStoreParameter.PackAlignment, alignment); break; } } // Grab frame buffer pixels PixelFormat rFormat = Pixel.GetGlFormat(pType); PixelType rType = Pixel.GetPixelType(pType); Gl.ReadPixels((int)x, (int)y, (int)width, (int)height, rFormat, rType, image.ImageBuffer); // Unbind from reading UnbindRead(ctx); return (image); }
public static void ReadBuffer(ReadBufferMode mode) { CheckCurrent(); _bindings.glReadBuffer((int)mode); CheckError(); }
/// <summary> /// Copy this GraphicsSurface color buffer into a buffer. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> which is bound to this GraphicsSurface. /// </param> /// <param name="rBuffer"> /// A <see cref="ReadBufferMode"/> that specify the read buffer where the colors are read from. /// </param> /// <param name="x"> /// A <see cref="Int32"/> that specify the x coordinate of the lower left corder of the rectangle area to read. /// </param> /// <param name="y"> /// A <see cref="Int32"/> that specify the y coordinate of the lower left corder of the rectangle area to read. /// </param> /// <param name="texture"> /// A <see cref="Texture"/> that will hold the buffer data. /// </param> /// <param name="level"> /// The level of the texture <paramref name="texture"/> to be written. /// </param> /// <returns> /// It returns an <see cref="Image"/> representing the current read buffer <paramref name="rBuffer"/>. /// </returns> protected void CopyBuffer(GraphicsContext ctx, ReadBufferMode rBuffer, uint x, uint y, ref Texture texture, uint level) { if (texture == null) throw new ArgumentNullException("texture"); if (texture.Exists(ctx) == false) throw new ArgumentException("not exists", "texture"); if ((x + texture.Width > Width) || (y + texture.Height > Height)) throw new ArgumentException("specified region lies outside the GraphicsSurface"); // Bind for reading BindRead(ctx); // Set for reading Gl.ReadBuffer(rBuffer); // Copy pixels from read buffer to texture Gl.CopyTexImage2D(texture.TextureTarget, (int)level, Pixel.GetGlInternalFormat(texture.PixelLayout, ctx), (int)x, (int)y, (int)texture.Width, (int)texture.Height, 0); // Unbind from reading UnbindRead(ctx); // Reset read configuration Gl.ReadBuffer(Gl.NONE); }
/// <summary> /// Sets the readbuffer for this framebuffer. /// </summary> /// <param name="FramebufferID">id of framebuffer to set for.</param> /// <param name="mode">Readbuffer mode to set.</param> public static void FramebufferReadBufferEXT(uint FramebufferID, ReadBufferMode mode) { Delegates.glFramebufferReadBufferEXT(FramebufferID, mode); }
public static void ReadBuffer(ReadBufferMode mode) { Debug.Assert(Delegates.pglReadBuffer != null, "pglReadBuffer not implemented"); Delegates.pglReadBuffer((Int32)mode); CallLog("glReadBuffer({0})", mode); DebugCheckErrors(); }
public void ReadBuffer(ReadBufferMode mode) { GL.ReadBuffer(mode); }