- glm::vec3 lightPos = glm::vec3(sin(d) * 10, 0, cos(d) * 10);
-
- drawPyramids(d, lightPos);
- drawLight(d, lightPos);
-
- glutSwapBuffers();
-}
-
-void attachShader(GLuint progId, const char* filePath, GLenum type) {
- GLuint shader = glCreateShader(type);
-
- if (!shader) {
- fprintf(stderr, "error creating shader\n");
- exit(1);
- }
-
- ifstream file(filePath);
- stringstream buffer;
- buffer << file.rdbuf();
- string str = buffer.str();
- const char* contents = str.c_str();
-
- glShaderSource(shader, 1, (const GLchar**)&contents, NULL);
- glCompileShader(shader);
- GLint success;
- glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
- if (!success) {
- GLchar log[1024];
- glGetShaderInfoLog(shader, 1024, NULL, log);
- fprintf(stderr, "error: %s\n", log);
- exit(1);
- }
- glAttachShader(progId, shader);
-}
-
-GLuint compileShaders(char* vertexShader, char* fragmentShader) {
- GLuint progId = glCreateProgram();
-
- attachShader(progId, vertexShader, GL_VERTEX_SHADER);
- attachShader(progId, fragmentShader, GL_FRAGMENT_SHADER);