Skip to content

Instantly share code, notes, and snippets.

View olevegard's full-sized avatar

Ole Vegard Mythe Moland olevegard

View GitHub Profile
@olevegard
olevegard / ModelMatrix.h
Last active August 27, 2017 13:24
A simple class for creating and returning model matrices
#pragma once
#include <glm/glm.hpp>
#include <glm/gtx/transform.hpp>
class ModelMatrix
{
public:
glm::mat4 GetModel()
// Compile : clang++ main.cpp -o Part_03 -lGL -lSDL2
//
#include <iostream>
#include <string>
#include "Shader.h"
#define GL3_PROTOTYPES 1
#include <GL/glew.h>
#include <SDL2/SDL.h>
#version 330
precision highp float;
in vec4 ex_Color;
out vec4 fragColor;
float rand(vec2 co);
#version 330
layout(triangles) in;
layout(triangle_strip, max_vertices = 100) out;
in vec4 color[]; // Output from vertex shader for each vertex
out vec4 ex_Color; // Output to fragment shader
void MakeEar(vec4 v);
#version 330
// in_Position was bound to attribute index 0 and in_Color was bound to attribute index 1
in vec4 in_Color;
in vec3 in_Position;
// We output the ex_Color variable to the next shader in the chain
out vec4 color;
void main(void) {
// Set the position to the one defined in our vertex array
#pragma once
#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <string>
#include <vector>
#include <sstream>
#include <fstream>
#include <iostream>
#version 120
// It was expressed that some drivers required this next line to function properly
precision highp float;
in vec4 ex_Color;
void main(void) {
gl_FragColor = vec4(ex_Color);
}
#version 150
// in_Position was bound to attribute index 0 and in_Color was bound to attribute index 1
attribute vec3 in_Position;
attribute vec4 in_Color;
// We output the ex_Color variable to the next shader in the chain
out vec4 ex_Color;
void main(void) {
#pragma once
#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
// Headerphile.com OpenGL Tutorial part 2
// A simple example involving VBOs and a VAO to draw a simple square
// Source code is an adaption / simplicication of : https://www.opengl.org/wiki/Tutorial2:_VAOs,_VBOs,_Vertex_and_Fragment_Shaders_(C_/_SDL)
// Compile :
// clang++ main.cpp -lGL -lGLEW -lSDL2 -std=c++11 -o Test
// or
// g++ main.cpp -lGL -lGLEW -lSDL2 -std=c++11 -o Test
//
#include <iostream>