Skip to content

Instantly share code, notes, and snippets.

@krysseltillada
krysseltillada / clipSpaceVS.vert
Created March 29, 2016 17:53
exercise 10 orthographic projection, array indexing, fragment positioning
#version 330
layout (location = 0) in vec4 vertexPosition;
layout (location = 1) in vec4 vertexColor;
smooth out vec4 outputVertexColor;
out float heightOutputPosition;
uniform float heightPosition;
@krysseltillada
krysseltillada / Camera.hpp
Created March 18, 2016 09:20
exercise 8 perspective transform (widescreen aspect ratio, camera position transformation)
#ifndef CAMERA_HPP
#define CAMERA_HPP
class Camera {
public:
Camera() :
zNear(0.0f), zFar(0.0f), fov(0.0f),
x(0.0f), y(0.0f), z(0.0f) { }
float zNear, zFar, fov;
@krysseltillada
krysseltillada / PerspectiveMatrix.vert
Last active March 15, 2016 20:13
exercise 7 Perspective Matrix projection
#version 330
layout(location = 0) in vec4 position; /// assigns a attribute index for the vertex shader
layout(location = 1) in vec4 color;
smooth out vec4 theColor; /// this varible is used by the next stage of the pipeline
uniform mat4 perspectiveMatrix; /// uniform variable of type mat4
uniform vec2 offset; /// uniform variable of type vec2
@krysseltillada
krysseltillada / PerspectiveProjection.vert
Created March 11, 2016 18:12
exercise 6 (perspective projection)
#version 330
layout(location = 0) in vec4 position;
layout(location = 1) in vec4 color;
smooth out vec4 theColor;
uniform float frustumScale; /// how big is the field of view
uniform float zNear; /// how near is the view from the eye
uniform float zFar; /// how far that this camera can view
@krysseltillada
krysseltillada / Shader.hpp
Created March 7, 2016 18:06
exercise 5 (real time fragment color interpolation)
#ifndef SHADER_HEADER
#define SHADER_HEADER
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <initializer_list>
#include <string>
#include <memory>
#include <iostream>
@krysseltillada
krysseltillada / core.cpp
Created March 4, 2016 18:57
exercise 4 (offset vertex position using uniforms)
#define GLEW_STATIC
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <iostream>
#include <cstdlib>
#include "main.hpp"
@krysseltillada
krysseltillada / core.cpp
Created March 2, 2016 17:46
exercise 3 (moving vertex positions)
#define GLEW_STATIC
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
@krysseltillada
krysseltillada / core.cpp
Created February 25, 2016 18:44
(ex2) ch 2 playing with colors
#define GLEW_STATIC /// needs to define because of glew32s.lib
#include <GL/glew.h> /// includes open gl functionality
#include <GL/freeglut.h> /// includes window functions
#include <cstdlib> /// EXIT_SUCESS, exit ();
#include <iostream> /// std::cerr
#include "main.hpp"
@krysseltillada
krysseltillada / fragmentCode.frag
Created February 23, 2016 16:59
open gl (hello triangle)
#version 330
out vec4 outputColor;
void main ()
{
outputColor = vec4(1.0f, 0.50f, 0.50f, 0.0f);
}
@krysseltillada
krysseltillada / MIT6_00SCS11_ps1.py
Created February 7, 2016 18:21
MIT6_00SCS11_ps1
def minMonthPayment (minMonthRate, Balance):
return minMonthRate * Balance
def interestPaid (AnnualRate, Balance):
return AnnualRate / 12.0 * Balance
def principalPaid (minMonthPay, interestPaid):
return minMonthPay - interestPaid
def remainingBalance (Balance, principalPaid):