Reputation: 1676
IDE: xcode
System: MacOS
My project [repo] is at the point where I successfully made a skybox [tutorial link] work, but I'm struggling with assimp's model loading [tutorial link].
I don't receive any errors. The model is just not loading into the window, even though I added cout << vertices.data() << endl;
[GitHub line link] at the respective line in the model.h
[GitHub line link], after it get's initialized in main.cpp
[GitHub line link] which is printing 0x106e6b000
, so the models vertices are loading.
However, the window remains empty, apart from the background color. In the tutorial [YouTube video link with timestamp], which I followed faithfully, it's working.
I'm trying to render the model nanosuit.obj
, which is proven to be red in. ourModel.Draw( shader );
should draw it, but doesn't or it's not being displayed.
For some reason it's not being displayed, despite no errors that data can't be found or exceptions triggered.
I would love to give a MCVE, but the code it very much interconnected, hence the GitHub links.
As far as I can say this should draw the model, unless it complains.
// Draw the loaded model
glm::mat4 model;
model = glm::translate( model, glm::vec3( 0.0f, -1.75f, 0.0f ) ); // Translate it down a bit so it's at the center of the scene
model = glm::scale( model, glm::vec3( 0.2f, 0.2f, 0.2f ) ); // It's a bit too big for our scene, so scale it down
glUniformMatrix4fv( glGetUniformLocation( shader.Program, "model" ), 1, GL_FALSE, glm::value_ptr( model ) );
ourModel.Draw( shader );
Stuff I tried:
.obj
sI'm trying not to code dump, hence the line links. Feel free to tell me if you want code snippets. I'm kind of lost here as for why this is happening.
@Botje suggested I try these things:
modelLoading.frag
[repo, line link] to apply red color instead of the textures to try to minimize the risk of something being wrong with the models textures. Was ineffective. Still no model. void main( )
{
//color = vec4( texture( texture_diffuse, TexCoords ));
color = vec4( 1.0f, 0.0f, 0.0f, 1.0f);
}
model.h
, edited cout << vertices.size() << endl;
[repo, line link] prints, which is correct for the nanosuit.obj
model from the tutorial. I had a planet in there, which was not part of the tutorial, therefore the 0x106e6b000
from previously. I now get for vertices.size()
:156 15222 19350 78 6804 7248 8316
So the model is definitely loading, just not rendering. The problem must me somewhere after the model loading but before the rendering.
Upvotes: 0
Views: 727
Reputation: 1676
Got it. Model was never initialised. The tutorial was pre 2018, which is when GLM went away from auto initialising.
In the snippet I posted was the error.
It's supposed to be:
// Draw the loaded model
glm::mat4 model = glm::mat4(1.0f);
Instead of:
// Draw the loaded model
glm::mat4 model;
My GLM version is 0.9.9.3
, while the tutorials is most certainly pre 0.9.9.0
, the version they changed it.
Noted, a lot of tutorials use this code.
The one I worked with didn't change it either.
You can check your GLM version in xcode by clicking on the project in your file browser, selecting the App in the Tartget list and then
Build Settings > Search Paths > Header Search Paths
Double click to open the list.
Upvotes: 3