planetis-m / naylib

Yet another raylib Nim wrapper
MIT License
209 stars 11 forks source link

No way to generate Mesh? #88

Closed thefakeplace closed 1 year ago

thefakeplace commented 1 year ago

Looking at the source, it doesn't seem possible to create a mesh.

Pattern from Raylib (C):

// Generate a simple triangle mesh from code
static Mesh GenMeshCustom(void)
{
    Mesh mesh = { 0 };
    mesh.triangleCount = 1;
    mesh.vertexCount = mesh.triangleCount*3;
    mesh.vertices = (float *)MemAlloc(mesh.vertexCount*3*sizeof(float));    // 3 vertices, 3 coordinates each (x, y, z)
    mesh.texcoords = (float *)MemAlloc(mesh.vertexCount*2*sizeof(float));   // 3 vertices, 2 coordinates each (x, y)
    mesh.normals = (float *)MemAlloc(mesh.vertexCount*3*sizeof(float));     // 3 vertices, 3 coordinates each (x, y, z)

    /* ... */
}

I can't figure out how to do this in Naylib, am I reading the source wrong?

planetis-m commented 1 year ago

I can't provide a code sample right now but https://nim-lang.github.io/Nim/importutils.html#privateAccess%2Ctypedesc was tested before and it works. As for getting MemAlloc, you need to importc it in your project (just copy the definition found in raylib.nim).

planetis-m commented 1 year ago

see example models/mesh_generation.nim