16
General / How can I assign texture to 3D buildings made with VertexArrays?
« on: December 18, 2019, 07:48:43 pm »
Hello ladies and guys!
I would like that Quads (that are the 2D parts of my 3D buildings) have a texture, so the 3D buildings look a bit more like buildings ... I tried this but they just show the same old Color but darker
Maybe those who remember my Massacre space shooter game will understand better ...
Thanks in advance
Pablo
I would like that Quads (that are the 2D parts of my 3D buildings) have a texture, so the 3D buildings look a bit more like buildings ... I tried this but they just show the same old Color but darker
private void AssignVertices(VertexArray array, Color color, float[] coords)
{
int a;
array.Clear();
for (a = 0; a < coords.Length / 2; a++)
array.Append(new Vertex(new Vector2f(coords[a * 2], coords[a * 2 + 1] + this.ship.Scroll), color, new Vector2f(0, 0)));
array.Append(new Vertex(new Vector2f(coords[0], coords[1]), color, new Vector2f(0, 0)));
RenderStates states = new RenderStates(Graphics.building); // this is the Texture
this.window.Draw(array, states);
}
{
int a;
array.Clear();
for (a = 0; a < coords.Length / 2; a++)
array.Append(new Vertex(new Vector2f(coords[a * 2], coords[a * 2 + 1] + this.ship.Scroll), color, new Vector2f(0, 0)));
array.Append(new Vertex(new Vector2f(coords[0], coords[1]), color, new Vector2f(0, 0)));
RenderStates states = new RenderStates(Graphics.building); // this is the Texture
this.window.Draw(array, states);
}
Maybe those who remember my Massacre space shooter game will understand better ...
Thanks in advance
Pablo