Can someone help me with a weird issue? I'm trying to draw a transformed image. An image where the x's and y's can be whatever so it can look skewed, pinched, etc. with a texture.
The code I do that is here:
[JSFunction
(Name
= "transformBlit")] public void TransformBlit
(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4
) { Vertex
[] array
= new Vertex
[4]; Color c
= new Color
(255,
255,
255); array
[0] = new Vertex
(new Vector2f
((float)x1,
(float)y1
), c,
new Vector2f
(0,
0)); array
[1] = new Vertex
(new Vector2f
((float)x2,
(float)y2
), c,
new Vector2f
((float)_image
.Size.X,
0)); array
[2] = new Vertex
(new Vector2f
((float)x3,
(float)y3
), c,
new Vector2f
((float)_image
.Size.X,
(float)_image
.Size.Y)); array
[3] = new Vertex
(new Vector2f
((float)x4,
(float)y4
), c,
new Vector2f
(0,
(float)_image
.Size.Y)); Program
._window
.Draw(array, PrimitiveType
.Quads, state
); } Excuse the float conversions, I can only get doubles from the JS environment. The state object has the Texture property set to the texture I'm using. It should work! I am loading the texture before setting the state, and making sure it's not disposed in any way. Drawing the texture alone as a sprite works, but not this method. And this is AFAIK the only method where you can skew the drawn image.
You can try the code out at:
https://github.com/Radnen/sphere-sfmlJust download, run in visual studio and have at it. The demo code should draw an image in the upper-left that is not a spaceship, but a face. As you can see, it's invisible even though transformBlit is being used. Removing the state will make it draw a white rectangle. So I know it's working, but just not applying the textured state.