read model file from command line
This commit is contained in:
parent
84e0a927f2
commit
5a59d16b42
11
u07/main.c
11
u07/main.c
|
@ -38,6 +38,9 @@ const GLfloat pi = 3.14159f;
|
|||
|
||||
vec3 cameraPosition = {0.0f, 3.0f, 5.5f};
|
||||
|
||||
char* defaultModel = "../obj/monkey.obj";
|
||||
char** model = &defaultModel;
|
||||
|
||||
// input handler for camera movement
|
||||
void handleInputs(double deltaTime) {
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) {
|
||||
|
@ -132,7 +135,7 @@ void init(void) {
|
|||
|
||||
|
||||
// --------------- READ teapot.obj
|
||||
ParsedObjFile teapot = readObjFile("../obj/monkey.obj");
|
||||
ParsedObjFile teapot = readObjFile(*model);
|
||||
numFaces = teapot.length;
|
||||
|
||||
// write teapot faces to buffer
|
||||
|
@ -215,6 +218,7 @@ void draw(void) {
|
|||
// counts up to 1.0 and then resets back to 0.0 forever
|
||||
step += deltaTime / 5;
|
||||
if (step > 1.0f) step -= 1.0f;
|
||||
if (step < 0.0f) step += 1.0f;
|
||||
|
||||
// step multiplied by pi * 2 for use in rotation and trig functions
|
||||
GLfloat stepi = step * pi * 2;
|
||||
|
@ -299,8 +303,11 @@ void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
|
|||
aspectRatio = (float)width / height;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
if (argc == 2) {
|
||||
model = &argv[1];
|
||||
}
|
||||
// initialise window
|
||||
glfwInit();
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
|
|
Loading…
Reference in New Issue