Q1: Why do we need to load external models in OpenGL?
A1: Because real 3D models have thousands of vertices and can’t be manually hardcoded — they must be loaded from files like .obj.
Q2: What is the purpose of a model file in 3D graphics?
A2: It stores the vertex positions, normals, and indices that describe a 3D object’s shape and structure.
Q3: What are common sources of 3D models?
A3: Engineering/scientific data or assets created in modeling software like Blender, Maya, or 3ds Max.
Q4: What model format is commonly used in OpenGL teaching examples?
A4: .obj (Wavefront Object).
Q5: What are the advantages of the OBJ format?
A5: It’s text-based, human-readable, platform-independent, and easy to find or create.
Q6: What is a disadvantage of the OBJ format?
A6: It’s slow to load for large models because it’s not binary and may include redundant data.
Q7: What library is used to load .obj models?
A7: TinyOBJLoader — a lightweight C++ library that parses OBJ files and provides vertices, normals, and indices.
Q8: What kind of data does TinyOBJLoader extract?
Vertex positions
Normals
Indices (faces)
Material information
Q9: Why are arrays like vertices and normals declared as pointers?
A9: Because their sizes aren’t known until the model file is read, so memory is allocated dynamically.
Q10: What is a bounding box?
A10: The smallest 3D box that completely encloses a model — defined by (xmin, xmax, ymin, ymax, zmin, zmax).
Q11: Why compute a bounding box when loading a model?
To know the model’s size and position
To scale or center it in view
To position the camera correctly
Q12: Why can’t we use sizeof(vertices) when uploading data to the GPU?
A12: Because vertices is a pointer, not a fixed array — you must use num_vertices * sizeof(GLfloat) instead.
Q13: What buffers are used to send data to the GPU?
VBO (Vertex Buffer Object) for vertices and normals
EBO (Element Buffer Object) for indices
Q14: Why is glBufferSubData used after glBufferData?
A14: To fill different parts of the same buffer (e.g., first the vertices, then the normals).
Q15: Why might your model disappear after “cleaning” your Visual Studio project?
A15: The .obj model file has the same extension as compiled .obj files, so Visual Studio deletes it when cleaning. Keep it in a separate folder.
Q16: What happens if vertex order and normal order don’t match?
A16: Lighting will be incorrect because normals point in the wrong directions.
Q17: How can you fix incorrect normals in a model?
A17: Use a tool like MeshLab → Filters → Normals, Curvature, and Orientation → Recompute Vertex Normals.
Q18: Why might multiple models have mismatched appearance or size?
A18: Different coordinate systems (Y-up vs. Z-up) and inconsistent scales between models.
Q19: What structure is used to represent each model in code?
struct Mesh {
GLuint vbuffer, ibuffer;
GLuint triangles, vbytes;
GLuint program;
glm::mat4 model;
};
Q20: What is stored inside each Mesh?
A20: GPU buffer IDs, triangle count, assigned shader program, and its model transformation matrix.
Q21: Why do we normalize models after loading?
Q21: Why do we normalize models after loading?
Q22: How do you normalize a model’s size?
Find the bounding box size in x, y, and z.
Compute the maximum dimension.
Divide all vertex coordinates by that value
Q23: Why is normalization important in multi-object scenes?
A23: It ensures different models (like a monkey and bunny) appear properly scaled and centered in the same scene.
Q24: Why shouldn’t you recompile shaders for each model?
A24: It’s inefficient — instead, compile them once and reuse the program across models.