|
@@ -25,6 +25,11 @@ GLubyte image[TextureWidth][TextureHeight][3];
|
|
|
point4 points[NumVertices];
|
|
|
vec2 tex_coords[NumVertices];
|
|
|
|
|
|
+// fog params
|
|
|
+GLuint fog; // is_foggy uniform
|
|
|
+GLuint eye_pos;
|
|
|
+int foggy = 1;
|
|
|
+
|
|
|
// Viewing transformation parameters
|
|
|
GLfloat theta = 0.0;
|
|
|
GLfloat phi = 0.0;
|
|
@@ -69,7 +74,8 @@ void load_model(const std::string &file_name, bool no_tex = false,
|
|
|
while (s >> t) {
|
|
|
if (t == "v") { // vertices
|
|
|
s >> x >> y >> z;
|
|
|
- vertices.emplace_back(x / 50.0f + x_offset, z / 50.0f + z_offset, y / 50.0f + y_offset, 1.0);
|
|
|
+ vertices.emplace_back(x / 50.0f + x_offset, z / 50.0f + z_offset,
|
|
|
+ y / 50.0f + y_offset, 1.0);
|
|
|
} else if (t == "vt") {
|
|
|
s >> x >> y;
|
|
|
tex_cods.emplace_back(x, y);
|
|
@@ -188,10 +194,11 @@ void init() {
|
|
|
glUniform1i(glGetUniformLocation(program, "tex"), 0);
|
|
|
model_view = glGetUniformLocation(program, "model_view");
|
|
|
projection = glGetUniformLocation(program, "projection");
|
|
|
-
|
|
|
+ fog = glGetUniformLocation(program, "foggy");
|
|
|
+ eye_pos = glGetUniformLocation(program, "eye_pos");
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
|
- glClearColor(1.0, 1.0, 1.0, 1.0);
|
|
|
+ glClearColor(1, 1, 1, 1);
|
|
|
}
|
|
|
|
|
|
void display(void) {
|
|
@@ -210,6 +217,10 @@ void display(void) {
|
|
|
mat4 p = Frustum(left, right, bottom, top, zNear, zFar);
|
|
|
glUniformMatrix4fv(projection, 1, GL_TRUE, p);
|
|
|
|
|
|
+ glUniform3f(eye_pos, eye_x, eye_y, eye_z);
|
|
|
+
|
|
|
+ glUniform1i(fog, foggy);
|
|
|
+
|
|
|
glDrawArrays(GL_TRIANGLES, 0, NumVertices);
|
|
|
|
|
|
glutSwapBuffers();
|
|
@@ -299,7 +310,6 @@ int main(int argc, char **argv) {
|
|
|
glutKeyboardFunc(keyboard);
|
|
|
glutMouseFunc(mouse);
|
|
|
// glutIdleFunc(idle);
|
|
|
-
|
|
|
glutMainLoop();
|
|
|
return 0;
|
|
|
}
|