/// <summary> /// Maps a texture /// </summary> /// <param name="texture">Texture to map</param> /// <param name="access">Access mode</param> /// <returns></returns> public bool MapTexture(Texture2D texture, BufferAccess access) { if (texture == null || IsLocked || Handle == 0) { return(false); } Texture = texture; Rectangle = texture.Bounds; IsLocked = true; // Bind PBO TK.GL.BindBuffer(TK.BufferTarget.PixelUnpackBuffer, Handle); // Copy the texture to the PBO TK.GL.TexSubImage2D(TK.TextureTarget.Texture2D, 0, 0, 0, Texture.Size.Width, Texture.Size.Height, TK.PixelFormat.Bgra, TK.PixelType.UnsignedByte, IntPtr.Zero); // if (Data == null || Data.Length != Size.Width * Size.Height * 4) // Data = new byte[Size.Width * Size.Height * 4]; // Map PBO to client memory IntPtr ptr = TK.GL.MapBuffer(TK.BufferTarget.PixelUnpackBuffer, (TK.BufferAccess)BufferAccess.ReadWrite); return(false); }
/// <summary> /// Maps the current frame buffer /// </summary> /// <param name="rectangle">Rectangle</param> /// <param name="access">Access mode</param> /// <returns></returns> public bool MapFrameBuffer(Rectangle rectangle, BufferAccess access) { Texture = null; Rectangle = Rectangle.Empty; // No buffer available if (Handle == 0 || IsLocked) { return(false); } // Reserve enough space Rectangle = rectangle; if (Data == null || Data.Length != Size.Width * Size.Height * 4) { Data = new byte[Size.Width * Size.Height * 4]; } Access = access; IsLocked = true; // Write only, no need to get the content if (Access == BufferAccess.WriteOnly) { return(true); } // Read the frame buffer TK.GL.MapBuffer(TK.BufferTarget.PixelPackBuffer, (TK.BufferAccess)access); TK.GL.ReadPixels(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, TK.PixelFormat.Bgra, TK.PixelType.UnsignedByte, IntPtr.Zero); TK.GL.BindBuffer(TK.BufferTarget.PixelPackBuffer, 0); return(true); }
public IntPtr Map(BufferAccess access) { EnsureLoaded(); var ptr = GL.MapBuffer(Target, access); IsMapped = true; return ptr; }
/// <summary> /// Map the buffer to program memory for writing/reading /// </summary> /// <param name="bufferAccess"></param> public unsafe IntPtr Map(BufferAccess bufferAccess) { this.Assert(); Bind(BufferTarget.ArrayBuffer); return(GL.MapBuffer(BufferTarget.ArrayBuffer, bufferAccess)); }
public GLBufferLockedBytes(GLBufferObject buffer, BufferTarget target, BufferAccess access, IntPtr pointer, int offset, int size) { fTarget = target; fBuffer = buffer; fOffset = offset; fSize = size; fAccess = access; fLockingThread = Thread.CurrentThread; fData = pointer; }
/// <summary> /// Initializes a new <see cref="BufferMapping"/>. /// </summary> /// <param name="buffer">The <see cref="IBuffer"/> to map.</param> /// <param name="access">The <see cref="BufferAccess"/>.</param> /// <param name="mapImmediately"><c>true</c> if the <paramref name="buffer"/> shall be mapped directly, otherwise <c>false</c>.</param> public BufferMapping(IBuffer buffer, BufferAccess access, bool mapImmediately = true) : this() { Contract.Requires<ArgumentNullException>(buffer != null); this.access = access; this.buffer = buffer; if (mapImmediately) { this.Map(); } }
public IntPtr Map(BufferAccess access) { if (!this.Loaded) { var s = string.Format("VBO.MapBuffer ({0}): buffer not loaded", this.Name); log.Error(s); throw new InvalidOperationException(s); } var ptr = GL.MapBuffer(this.Target, access); this.Mapped = true; return(ptr); }
public Mapper(GraphicsContext ctx, Buffer thisBuffer, BufferAccess mask) { CheckCurrentContext(ctx); CheckThatExistence(ctx, thisBuffer); _Context = ctx; _Buffer = thisBuffer; // Leave unmapped if not mapped yet _UnmapOnDispose = thisBuffer.MappedBuffer == IntPtr.Zero; if (_UnmapOnDispose) { _Buffer.Map(_Context, mask); } }
/// <summary> /// Map the GPU buffer allocated by this Buffer. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> required for mapping this Buffer. /// </param> /// <param name="mask"> /// A <see cref="BufferAccess"/> that specify the map access. /// </param> /// <exception cref="InvalidOperationException"> /// Exception thrown if this Buffer is already mapped. /// </exception> /// <exception cref="InvalidOperationException"> /// Exception thrown if this Buffer does not exist for <paramref name="ctx"/>. /// </exception> /// <remarks> /// <para> /// After being mapped, the mapped buffer is accessible via <see cref="MapGet{T}(GraphicsContext, long)"/> or /// <see cref="MapSet{T}(GraphicsContext, T, long)"/>, or via <see cref="MappedBuffer"/> as raw pointer. /// </para> /// </remarks> public void Map(GraphicsContext ctx, BufferAccess mask) { CheckThisExistence(ctx); Debug.Assert(ctx.Extensions.VertexBufferObject_ARB || ctx.Version.IsCompatible(Gl.Version_200_ES) || _GpuBuffer != null); if (ctx.Extensions.VertexBufferObject_ARB || ctx.Version.IsCompatible(Gl.Version_200_ES)) { BindCore(ctx); _MappedBuffer = Gl.MapBuffer(Target, mask); } else { _MappedBuffer = _GpuBuffer.AlignedBuffer; } }
/// <summary> /// Map the GPU buffer allocated by this Buffer. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> required for mapping this Buffer. /// </param> /// <param name="mask"> /// A <see cref="BufferAccess"/> that specify the map access. /// </param> /// <exception cref="InvalidOperationException"> /// Exception thrown if this Buffer is already mapped. /// </exception> /// <exception cref="InvalidOperationException"> /// Exception thrown if this Buffer does not exist for <paramref name="ctx"/>. /// </exception> public void Map(GraphicsContext ctx, BufferAccess mask) { CheckThisExistence(ctx); if (IsMapSupported(ctx)) { #if !MONODROID if (ctx.Extensions.DirectStateAccess_ARB || ctx.Version.IsCompatible(Gl.Version_450)) { if ((MappedBuffer = Gl.MapNamedBuffer(ObjectName, mask)) == IntPtr.Zero) { Gl.CheckErrors(); } } else { #endif ctx.Bind(this); if ((MappedBuffer = Gl.MapBuffer(Target, mask)) == IntPtr.Zero) { Gl.CheckErrors(); } #if !MONODROID } #endif } else { if (GpuBuffer == null) { throw new GlException(ErrorCode.InvalidOperation); } if ((MappedBuffer = GpuBuffer.AlignedBuffer) == IntPtr.Zero) { throw new GlException(ErrorCode.InvalidOperation); } } Debug.Assert(MappedBuffer != IntPtr.Zero); MapOffset = IntPtr.Zero; MapSize = Size; _Access = mask; }
public MDLBlock(BinaryReader reader, BlockHeader header) : base(header) { InertiaTensor = reader.ReadVector3(); BoundingRadius = reader.ReadSingle(); if (header.Signature != BlockHeader.MAGIC_MODEL0) { AllowDistanceFade = reader.ReadUInt32() > 0; IncludesBoundingBox = reader.ReadUInt32() > 0; if (IncludesBoundingBox) { AABBMin = reader.ReadVector3(); AABBMax = reader.ReadVector3(); AABBCenter = reader.ReadVector3(); AABBYaw = reader.ReadSingle(); } UseUniqueMaterials = reader.ReadUInt32(); UseUniqueTextures = reader.ReadUInt32(); UseGenericGeometry = reader.ReadUInt32(); VertexBufferAccessFlags = (BufferAccess)reader.ReadUInt32(); reader.ReadBytes(12 * 4); } else { AllowDistanceFade = false; } int textureReferenceCount = reader.ReadInt32(); for (int i = 0; i < textureReferenceCount; i++) { TextureReferences.Add(new TextureReference(reader)); } int materialCount = reader.ReadInt32(); for (int i = 0; i < materialCount; i++) { Materials.Add(new MaterialProps(reader)); } }
static extern IntPtr glitz_buffer_map(IntPtr buffer, BufferAccess access);
public IBufferLock Lock(long startOffset, long length, BufferAccess requestedAccess) => base.innerRefT.Lock(startOffset, length, requestedAccess);
public static void BindImageTexture(uint unit, uint texture, uint level, bool layered, uint layer, BufferAccess access, PixelInternalFormat format) => bindImageTexture(unit, texture, level, layered, layer, access, format);
/// <summary> /// Maps GPU data into the cpu and return an IntPtr pointing to that data, use (<typeparamref name="T"/>*)Map(...) for speed xD /// </summary> /// <param name="bufferAccess"></param> /// <returns></returns> public IntPtr Map(BufferAccess bufferAccess) { Bind(); return(GL.MapBuffer(bufferType, bufferAccess)); }
public IntPtr MapBuffer(BufferTarget target, BufferAccess access) { IntPtr retValue = glMapBufferARB((int)target, (int)access); return retValue; }
public Status Unmap (BufferAccess access) { return GlitzAPI.glitz_buffer_unmap (Handle); }
public static void BindImageTextureEXT(UInt32 index, UInt32 texture, Int32 level, bool layered, Int32 layer, BufferAccess access, InternalFormat format) { Debug.Assert(Delegates.pglBindImageTextureEXT != null, "pglBindImageTextureEXT not implemented"); Delegates.pglBindImageTextureEXT(index, texture, level, layered, layer, (Int32)access, (Int32)format); LogCommand("glBindImageTextureEXT", null, index, texture, level, layered, layer, access, format); DebugCheckErrors(null); }
public IDisposable CreateMapGuard(GraphicsContext ctx, BufferAccess mask) { return(new Mapper(ctx, this, mask)); }
public IntPtr MapBuffer(BufferAccess access) { // If it's already mapped, return the pointer that already // exists for the mapping. if (IsMapped) return GetMappedPointer(); // If it's not already mapped, then map it and return the pointer. IntPtr mappedPointer = GI.MapBuffer(fBufferTarget, access); return mappedPointer; }
public Status Unmap(BufferAccess access) { return(GlitzAPI.glitz_buffer_unmap(Handle)); }
public IntPtr Map(BufferAccess access) { return(GlitzAPI.glitz_buffer_map(Handle, access)); }
/// <summary> /// Map buffer into application's address space. /// </summary> /// <param name="access">An enumerant indicating the operations the client may perform on the data store through the pointer while the buffer data is mapped.</param> /// <returns>Returns a pointer through which the application can read or write the buffer's data store.</returns> public IntPtr Map(BufferAccess access) { return NativeMethods.cgMapBuffer(this.Handle, access); }
public IntPtr MapRange(uint offset, uint length, BufferAccess access) => Gl.MapBufferRange(BufferTarget, new IntPtr(offset), length, (uint)access);
/// <summary> /// Initializes a new <see cref="BufferMapping"/>. /// </summary> /// <param name="buffer">The <see cref="IBuffer"/> to map.</param> /// <param name="access">The <see cref="BufferAccess"/>.</param> public BufferMapping(IBuffer buffer, BufferAccess access) : this(buffer, access, true) { Contract.Requires<ArgumentNullException>(buffer != null); }
static extern IntPtr glitz_buffer_map (IntPtr buffer, BufferAccess access);
public IntPtr Map(BufferAccess access) { return(IGL.Primary.MapBuffer((int)BufferTarget.ShaderStorageBuffer, (int)access)); }
public IntPtr Map (BufferAccess access) { return GlitzAPI.glitz_buffer_map (Handle, access); }
public static extern IntPtr cgMapBuffer(IntPtr buffer, BufferAccess access);
public IntPtr Map(BufferAccess access) => Gl.MapBuffer(BufferTarget, access);
public IntPtr MapBuffer(BufferAccess access) { Bind(); return(GL.MapBuffer(bufferTarget, access)); }
public static IntPtr MapBuffer(BufferTarget target, BufferAccess access) { glMapBuffer deleg = BaseGraphicsContext.Current.Loader.Get<glMapBuffer>(); if (deleg != null) return deleg(target, access); return default(IntPtr); }
public IntPtr Map(BufferAccess access = BufferAccess.WriteOnly) { return(GL.MapBuffer(target, access)); }