PDA

View Full Version : C loading and rendering models (SDL2, glew, OpenGL 3.3)



Picpenguin
09-10-2017, 06:39 AM
Hi

I'm new to learning OpenGL and still learning C. I'm using SDL2, glew, OpenGL 3.3, linmath and stb_image.
I started following through learnopengl.com and got through it until I had to load models. The problem is, it uses Assimp for loading models. Assimp is C++ and uses things I don't want in my program (boost for example) and C support doesn't seem that good.
Things like glVertexAttribPointer and shaders are still confusing to me, but I have to start somewhere right?

I can't seem to find any good loading/rendering tutorials or source code that is simple to use and easy to understand.
I have tried this for over a week by myself, searching for solutions but so far no luck. With tinyobjloader-c and project that uses it, FantasyGolfSimulator, I was able to actually load the model with plain color (always the same color no matter what I do) on screen and move it around, but cannot figure out how to use textures or use its multiple textures with it.
I don't ask much: I just want to load models with textures in them, maybe have lights affect them (directional spotlight etc). Also, some models have multiple parts and multiple textures in them, how can I handle those?

Are there solutions anywhere?

Thank you for your time. Sorry if this is a bit confusing, English isn't my native language :)

Silence
09-11-2017, 11:57 PM
You can use lib3ds (https://code.google.com/archive/p/lib3ds/) for 3DS files, which is a C library. If I remember well, there are several tutorials and examples provided with it.

I also quickly found this C library (https://github.com/rlk/obj) to read obj files. I never used it so I cannot tell much more about it. Since you are in a learning process, this might be interesting for you to do your own obj loader.