public void SetData(long Key, long Size, IntPtr HostAddress) { if (Cache.TryGetValue(Key, out OGLStreamBuffer Buffer)) { Buffer.SetData(Size, HostAddress); } }
public void SetData(long Key, long Size, IntPtr HostAddress) { if (!Cache.TryGetValue(Key, out OGLStreamBuffer Buffer)) { throw new InvalidOperationException(); } Buffer.SetData(Size, HostAddress); }
public bool TryGetImage(long Key, out ImageHandler CachedImage) { if (TextureCache.TryGetValue(Key, out CachedImage)) { return(true); } CachedImage = null; return(false); }
public bool TryGetImage(long Key, out GalImage Image) { if (TextureCache.TryGetValue(Key, out ImageHandler CachedImage)) { Image = CachedImage.Image; return(true); } Image = default(GalImage); return(false); }
public bool TryGetCachedTexture(long Key, long DataSize, out GalTexture Texture) { if (TextureCache.TryGetSize(Key, out long Size) && Size == DataSize) { if (TextureCache.TryGetValue(Key, out TCE CachedTexture)) { Texture = CachedTexture.Texture; return(true); } } Texture = default(GalTexture); return(false); }
public void DrawElements(long IboKey, int First, int VertexBase, GalPrimitiveType PrimType) { if (!IboCache.TryGetValue(IboKey, out int IboHandle)) { return; } PrimitiveType Mode = OGLEnumConverter.GetPrimitiveType(PrimType); GL.BindVertexArray(VaoHandle); GL.BindBuffer(BufferTarget.ElementArrayBuffer, IboHandle); First <<= IndexBuffer.ElemSizeLog2; if (VertexBase != 0) { IntPtr Indices = new IntPtr(First); GL.DrawElementsBaseVertex(Mode, IndexBuffer.Count, IndexBuffer.Type, Indices, VertexBase); } else { GL.DrawElements(Mode, IndexBuffer.Count, IndexBuffer.Type, First); } }
public void SetVertexArray(int Stride, long VboKey, GalVertexAttrib[] Attribs) { if (!VboCache.TryGetValue(VboKey, out int VboHandle)) { return; } if (VaoHandle == 0) { VaoHandle = GL.GenVertexArray(); } GL.BindVertexArray(VaoHandle); foreach (GalVertexAttrib Attrib in Attribs) { GL.EnableVertexAttribArray(Attrib.Index); GL.BindBuffer(BufferTarget.ArrayBuffer, VboHandle); bool Unsigned = Attrib.Type == GalVertexAttribType.Unorm || Attrib.Type == GalVertexAttribType.Uint || Attrib.Type == GalVertexAttribType.Uscaled; bool Normalize = Attrib.Type == GalVertexAttribType.Snorm || Attrib.Type == GalVertexAttribType.Unorm; VertexAttribPointerType Type = 0; if (Attrib.Type == GalVertexAttribType.Float) { Type = VertexAttribPointerType.Float; } else { Type = AttribTypes[Attrib.Size] + (Unsigned ? 1 : 0); } int Size = AttribElements[Attrib.Size]; int Offset = Attrib.Offset; if (Attrib.Type == GalVertexAttribType.Sint || Attrib.Type == GalVertexAttribType.Uint) { IntPtr Pointer = new IntPtr(Offset); VertexAttribIntegerType IType = (VertexAttribIntegerType)Type; GL.VertexAttribIPointer(Attrib.Index, Size, IType, Stride, Pointer); } else { GL.VertexAttribPointer(Attrib.Index, Size, Type, Normalize, Stride, Offset); } } }
public void DrawElements(long IboKey, int First, GalPrimitiveType PrimType) { if (!IboCache.TryGetValue(IboKey, out int IboHandle)) { return; } PrimitiveType Mode = OGLEnumConverter.GetPrimitiveType(PrimType); GL.BindVertexArray(VaoHandle); GL.BindBuffer(BufferTarget.ElementArrayBuffer, IboHandle); GL.DrawElements(Mode, IndexBuffer.Count, IndexBuffer.Type, First); }
public bool TryGetVbo(long VboKey, out int VboHandle) { return(VboCache.TryGetValue(VboKey, out VboHandle)); }