GithubHelp home page GithubHelp logo

Comments (3)

thisistherk avatar thisistherk commented on August 23, 2024 1

Not really sure, but you might get something like that if you passed GL_UNSIGNED_SHORT to glDrawElements rather than GL_UNSIGNED_INT. fastObjMesh::positions[0] is a vertex at (0, 0, 0) - all valid indices are 1 based so it's never actually referenced, but if you got the size wrong to the glDrawElements call GL would see lots of 0 indices and might give you something like you describe. Hopefully give you something to look for anyway...

from fast_obj.

somerandompiggo avatar somerandompiggo commented on August 23, 2024

Had another crack at it, no luck so far. Here is a more complete snippet, I hope it helps since my last one was really minimal

Initialization:

fastObjMesh* objmesh = fast_obj_read(path);
if (objmesh == NULL) {
    printf("Error loading OBJ file with path: %s\n", path);
    return;
}

mesh->count = objmesh->index_count;

glGenVertexArrays(1, &mesh->VAO);
glBindVertexArray(mesh->VAO);

glGenBuffers(1, &mesh->VBO);
glBindBuffer(GL_ARRAY_BUFFER, mesh->VBO);
glBufferData(GL_ARRAY_BUFFER, objmesh->position_count * sizeof(float) * 3, objmesh->positions, GL_STATIC_DRAW);

glGenBuffers(1, &mesh->EBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, objmesh->index_count * sizeof(unsigned int), objmesh->indices, GL_STATIC_DRAW);

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);

Draw loop:

glBindVertexArray(mesh->VAO);
glDrawElements(GL_TRIANGLES, mesh->count, GL_UNSIGNED_INT, 0);

from fast_obj.

somerandompiggo avatar somerandompiggo commented on August 23, 2024

Sorry, wrote my own loader to test. Exact same result, not an issue with the library. Will edit this comment when I find a fix

from fast_obj.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.