Advertisement

C loading and rendering models (SDL2, glew, OpenGL 3.3)

Started by September 10, 2017 06:39 PM
2 comments, last by Shaarigan 7 years, 5 months ago

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 :)

Hi, i'am learning from learnopengl.com too.

Assimp have a nice abstract interface for load much file formats. maybe the better solution is create a tool with C++ and Assimp for load your model, textures, vertices, normals and so on, then export all data in a custom binary file.

 

 

Advertisement

Talisson's solution is a usual approach in custom engines and frameworks because it makes loading faster for removing file format specific parsing to favor loading times, memory usage and so on.

An other approach is to use something simple like .obj file format. There exists various loaders out there that do their thing and could be a starting point for your first model/geometry rendering

This topic is closed to new replies.

Advertisement