Jump to content
  • Advertisement
Picpenguin

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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.

 

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!