SFML community forums
Bindings - other languages => DotNet => Topic started by: Chris12 on March 07, 2012, 09:49:58 pm
-
Hi there,
I have a custom vertex array (not the VertexArray class).
And when drawing I sometimes only want to draw the first N quads, not all.
This is for a particle effect, if there are only 20 out of 2000 particles "alive", I don't want to draw all 2000.
Draw(vertices, PrimitiveType, renderStates) is missing something like a "count" parameter to specify this ?
Or how do I do this?
-
Doesn't .Net provide a simple way to get a sub-array from a bigger array?
If not, then I can probably add an explicit count, yes.
-
The only possible way would be copying out the part of the array I want to render.
But since there is a (hidden) maximum variable, i'd rather use use that.
-
By the way: RenderStates is somehow buggy.
When I use the following renderstates, the program crashes:
renderStates = new RenderStates(Texture);
renderStates.BlendMode = BlendMode.Add;
target.Draw(vertices, PrimitiveType.Quads, renderStates);
"Access Violation" inside this:
sfRenderWindow_DrawPrimitives(CPointer, vertexPtr, (uint)vertices.Length, type, states.Marshal());
EDITED:
But when I try it that way, it works without problems:
var va = new VertexArray(PrimitiveType.Quads);
for (int i = 0; i < particles.Count; i++)
{
va.Append(vertices[i * 4 + 0]);
va.Append(vertices[i * 4 + 1]);
va.Append(vertices[i * 4 + 2]);
va.Append(vertices[i * 4 + 3]);
}
va.Draw(target, renderState);
That would be very inefficient. But strangely it works.
Maybe only the vertexarray should draw vertices ? But why does RenderTarget.Draw() have an overload that allows drawing Vertex[] types directly ????
I'm using that method for now :/
I hope its only a small bug.
-
The only possible way would be copying out the part of the array I want to render.
But since there is a (hidden) maximum variable, i'd rather use use that.
Hmm ok, I'll do it.
By the way: RenderStates is somehow buggy.
Is it better now? Sorry I haven't tested the fix.
But why does RenderTarget.Draw() have an overload that allows drawing Vertex[] types directly ????
For the same reason that you're not using VertexArray ;)
-
Yeah, now it works, thank you.