void Update(PGTexture *texture, IntPtr buffer, int x, int y, int width, int height) { var t = textures[(int)texture->UserData]; GL.PixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); var rect = new Rectangle(x, y, width, height); t.SetData(0, rect, buffer); GL.PixelStorei(GL.GL_UNPACK_ALIGNMENT, 4); }
void Draw(PGQuad *quads, PGTexture *texture, int count) { if (texture == (PGTexture *)0) { for (int i = 0; i < count; i++) { var q = quads[i]; q.Dest.X += drawX; q.Dest.Y += drawY; ren.FillRectangle(q.Dest, q.Color); } } else { var t = textures[(int)texture->UserData]; for (int i = 0; i < count; i++) { var q = quads[i]; q.Dest.X += drawX; q.Dest.Y += drawY; ren.Draw(t, q.Source, q.Dest, q.Color); } } }
void Alloc(PGTexture *texture, int width, int height) { textures.Add(new Texture2D(width, height, false, SurfaceFormat.R8)); texture->UserData = (IntPtr)(textures.Count - 1); }