public void SetUp() { position = Vector2.Zero; colour = Vector4.Zero; textureCoordinate = Vector2.Zero; vertex = new VertexPositionColourTexture( position, colour, textureCoordinate ); }
public void TypeEquals_ReturnsTrue_OnEqualVertex(VertexPositionColourTexture other) { vertex.Equals(other).ShouldBeTrue(); }
public void TypeEquals_ReturnsFalse_OnUnequalVertices(VertexPositionColourTexture other) { vertex.Equals(other).ShouldBeFalse(); }
public void NotEqualsOperator_ReturnsFalse_OnEqualVertex(VertexPositionColourTexture other) { (vertex != other).ShouldBeFalse(); }
public void GetHashCode_IsNotEqual_ForUnequalVertices(VertexPositionColourTexture other) { vertex.GetHashCode().ShouldNotBe(other.GetHashCode()); }
public void NotEqualsOperator_ReturnsTrue_OnUnequalVertices(VertexPositionColourTexture other) { (vertex != other).ShouldBeTrue(); }
public void EqualsOperator_ReturnsFalse_OnUnequalVertices(VertexPositionColourTexture other) { (vertex == other).ShouldBeFalse(); }
public void EqualsOperator_ReturnsTrue_OnEqualVertex(VertexPositionColourTexture other) { (vertex == other).ShouldBeTrue(); }
public void Remove_ClearsSpriteVerticesFromVbo_OnSpriteRemoval() { var sprite = new Sprite(spriteSheet.Object.GetRegion(0), 10, 10); var spriteSize = Sprite.VertexCount * declaration.Stride; spriteBatch.Add(sprite); var spriteVboSize = new IntPtr(spriteSize); var spriteVboOffset = new IntPtr(spriteSize * sprite.BatchIndex); // essentially, overwrite the vertex data in the vbo with 4 vertices // that have no alpha and are hence transparent. var emptyVertex = default(VertexPositionColourTexture); var emptyVertices = new VertexPositionColourTexture[] { emptyVertex, emptyVertex, emptyVertex, emptyVertex }; spriteBatch.Remove(sprite); vbo.Verify(v => v.Bind()); vbo.Verify(v => v.FillPartial(spriteVboOffset, spriteVboSize, emptyVertices)); }
public void Add_PreparesSpriteVertices_OnSuccessfulAdd() { var sprite = new Sprite(spriteSheet.Object.GetRegion(0), 10, 10); spriteBatch.Add(sprite); /* The sprite batch should take the sprite's texture region * and scale each corner according to the whole texture atlas width/height * so that they fall in the range 0-1 (to match the expectations of OpenGL) */ float scaledWidth = 1.0f / spriteSheet.Object.Texture.Width; float scaledHeight = 1.0f / spriteSheet.Object.Texture.Height; var region = sprite.TextureRegion; // texture packer x,y refer to bottom left position of the texture region // whereas, OpenGL coordinate system has (0,0) at the upper-left var topLeftCoord = new Vector2(region.X * scaledWidth, (region.Y + region.Height) * scaledHeight); var topRightCoord = new Vector2((region.X + region.Width) * scaledWidth, (region.Y + region.Height) * scaledHeight); var bottomRightCoord = new Vector2((region.X + region.Width) * scaledWidth, region.Y * scaledHeight); var bottomLeftCoord = new Vector2(region.X * scaledWidth, region.Y * scaledHeight); // we should also scale the sprite's colour to fall in the range 0-1 var sColour = sprite.Colour; var scaledColour = new Vector4(sColour.R / 255, sColour.G / 255, sColour.B / 255, sColour.A / 255); // expected vertex positions var topLeftPosition = new Vector2(sprite.X, sprite.Y); var topRightPosition = new Vector2(sprite.X + sprite.Width, sprite.Y); var bottomRightPosition = new Vector2(sprite.X + sprite.Width, sprite.Y + sprite.Height); var bottomLeftPosition = new Vector2(sprite.X, sprite.Y + sprite.Height); var topLeftVertex = new VertexPositionColourTexture(topLeftPosition, scaledColour, topLeftCoord); var topRightvertex = new VertexPositionColourTexture(topRightPosition, scaledColour, topRightCoord); var bottomRightVertex = new VertexPositionColourTexture(bottomRightPosition, scaledColour, bottomRightCoord); var bottomLeftVertex = new VertexPositionColourTexture(bottomLeftPosition, scaledColour, bottomLeftCoord); sprite.Vertices.ShouldSatisfyAllConditions( () => sprite.Vertices[0].ShouldBe(topLeftVertex), () => sprite.Vertices[1].ShouldBe(topRightvertex), () => sprite.Vertices[2].ShouldBe(bottomRightVertex), () => sprite.Vertices[3].ShouldBe(bottomLeftVertex) ); }