Obj Loader for Opengl + Glut

I'm working on a game for open GL, and I want to simply be able to load OBJ files, with their textures into my game. I want the loader to contain all the necessary code to map the textures to the object.

(Note I have scoured google, and not one example I've seen has been simple enough to bolt onto my currently existing code, I'm talking 2 headers, and 2 cpps maximum)

Could anybody provide me with one?

1

2 Answers

you could get started by this simple loader which loads objects in a wavefront .obj file into a OpenGL scene. This code restricts to just scanning the vertex information out of OBJ. You could enhance it further may be after getting the basic idea.

You can find mine at:

It's a pretty simple one, but clean.

you will only need the Model class, which will load an OBJ file by filename:

You may need to remove some things to make it fit on your project. Namely the dependency to ResourceManager which loads the textures and return their id, but that should not be much work.

Hope it helps.

9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest