public Sprite(SpriteSheet spriteSheet, string name, Vector2i size, Box2 coordinates) { SpriteSheet = spriteSheet; Name = name; Size = size; Coordinates = coordinates; }
public SpriteRenderer(SpriteSheet spriteSheet) { SpriteSheet = spriteSheet; m_program = SpriteProgram.Instance; m_instances = new List<SpriteInstance>(); m_vao = new VertexArray(); GL.BindVertexArray(m_vao); m_bufferSprite = new Buffer<SpriteData>(); m_bufferQuad = new Buffer<Vector3>(); m_bufferQuad.SetData(new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3(0f, 1f, 0f), new Vector3(1f, 1f, 0f), new Vector3(1f, 0f, 0f) }); GL.UseProgram(m_program); m_program.Position.SetValue(m_bufferQuad.GetView()); m_program.Color.SetValue(m_bufferSprite.GetView(s => s.Color)); m_program.Color.SetDivisor(1); m_program.Transform.SetValue(m_bufferSprite.GetView<Matrix4>("Transform")); m_program.Transform.SetDivisor(1); m_program.TextureOrigin.SetValue(m_bufferSprite.GetView<Vector2>("TextureOrigin")); m_program.TextureOrigin.SetDivisor(1); m_program.TextureTarget.SetValue(m_bufferSprite.GetView<Vector2>("TextureTarget")); m_program.TextureTarget.SetDivisor(1); GL.BindVertexArray(null); m_isDirty = true; }
public SnowTexture() { m_backgroundTexture = Texture2D.Load(typeof(Floor).Assembly.GetManifestResourceStream("Zombie.Game.Textures.snow.jpg")); m_backgroundSheet = new SpriteSheet(m_backgroundTexture); m_backgroundSprite = m_backgroundSheet.AddSprite("", new Box2i(Vector2i.Zero, m_backgroundTexture.Size)); }