- Home /
What's the Unity equivalent of glDrawArrays(GL_POINTS, ...) and glDrawArrays(GL_LINES, ...) ?
I can't find anything either allows me to specify which type of primitives to draw, or allows me to specify a "point collection" instead of a mesh which is a "triangle collection" ....
Answer by Shreka · Aug 05, 2018 at 04:44 AM
are u tring to build a mesh with a c# code or import a mesh from a unsuported file type.
I'm trying to draw just (millions of) points as fast as possible. data of location of points are retrieved from a C++ library using pointers. Unity is not capable of drawing too many 2D rectangle meshes (even not capable of assigning objects' Transforms) per frame.
could u provide a example image.
Anyways it sucks to bring gl scripts to unity.
Like my md5mesh importer["https://answers.unity.com/questions/1538306/md5mesh-uvs-and-vertices-bugging.html?childToView=1538446#answer-1538446"] which was extracted from gl codes.
mesh.SetIndices (new int[] {0,2},$$anonymous$$eshTopology.Lines);
mesh.SetIndices (new int[] {0,2},$$anonymous$$eshTopology.Points);
Oh the $$anonymous$$eshTopology is something I've missed. I'll try this later. This is the main logic I copied from my code:
unsafe
{
PIVector2* p = (PIVector2*)Environment.GetParticles().ToPointer();
int cc = 0;
foreach(var obj in pool.busyObjects)
{
obj.transform.position = p[cc].vector;
cc++;
};
}
where function GetParticles
is dynamically loaded by LoadLibrary and GetProcAddress, and GameObjects from pool.busyObjects are pooled objects with only one SpriteRenderer for each of them.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172220im_/https://answers.unity.com/themes/thub/images/avi.jpg)