Pyramid.cpp - Pyramid.cpp Author Roberto Soto#include <iostream>#include <GL\/glew.h>#include <GL\/freeglut.h> GLM

Pyramid.cpp - Pyramid.cpp Author Roberto Soto#include...

This preview shows page 1 - 3 out of 5 pages.

/* * Pyramid.cpp * * * Author: Roberto Soto */ #include <iostream> #include <GL/glew.h> #include <GL/freeglut.h> // GLM include #include "glm/glm.hpp" #include "glm/gtc/matrix_transform.hpp" #include "glm/gtc/type_ptr.hpp" using namespace std; #define WINDOW_TITLE "Pyramid" // Shader program macro #ifndef GLSL #define GLSL(Version, Source) "#version " #Version "\n" #Source #endif // Var declaration for shader, window size, initialization, buffer and array objects GLint shaderProgram, WindowWidth = 800, WindowHeight = 600; GLuint VBO, VAO, EBO, texture; // Function prototypes void UResizeWindow(int, int); void URenderGraphics(void); void UCreateShader(void); void UCreateBuffers(void); // Vertex shader source const GLchar* vertexShaderSource = GLSL(330, layout(location = 0) in vec3 position; layout(location = 1) in vec3 color; out vec3 mobileColor; // Global vars for transform matrices uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() { gl_Position = projection * view * model * vec4(position, 1.0f); mobileColor = color; } ); // Fragment shader source const GLchar* fragmentShaderSource = GLSL(330, in vec3 mobileColor; out vec4 gpuColor; void main() { gpuColor = vec4(mobileColor, 1.0);
Image of page 1
} ); int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(WindowWidth, WindowHeight); glutCreateWindow(WINDOW_TITLE); glutReshapeFunc(UResizeWindow); glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { std::cout << "Failed to initialize GLEW" << std::endl;
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 5 pages?

  • Winter '19
  • Pixel shader, Shader

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture