Skip to content

Instantly share code, notes, and snippets.

View thetooth's full-sized avatar

Jeff Jenner thetooth

View GitHub Profile
package pages
import (
"crypto/sha1"
"fmt"
"github.com/gorilla/sessions"
"github.com/nfnt/resize"
"image"
"image/gif"
"image/jpeg"
/*
Copyright (c) 2011 Michael Nicolella
Single file conversion by Jeffrey Jenner
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// Before -- What the fuck tier
int Texture::LoadTexture(const char *fname){
cl("Loading Texture: %s ", fname);
unique_ptr<FILE, int(*)(FILE*)> filePtr(fopen(fname, "rb"), fclose);
if(filePtr == nullptr){
cl("[FAILED]\n");
throw KLGLException("[KLGLTexture::LoadTexture][%d:%s] \nResource \"%s\" could not be opened.", __LINE__, __FILE__, fname);
return 1;
}
template<typename T> struct Quad2D
{
T x,y,z,w;
Quad2D(T X, T Y, T Z, T W) : x(X), y(Y), z(Z), w(W) {};
};
@thetooth
thetooth / gl4.hpp
Last active August 29, 2015 13:56
OpenGL 4 Buffer Class
#pragma once
#include // Your lib that includes all the OpenGL bindings and maybe some other stuff i've forgotten like vector
namespace gl4 {
template<int BufferType, typename StorageClass> class glBuffer
{
public:
GLuint buffer;
// Vertex
#version 150 core
uniform mat4 trans;
in vec2 pos;
in float id;
out mat4 projection;
out float gId;
@thetooth
thetooth / demo.cpp
Last active August 29, 2015 13:57
Git Gud Engine
#pragma comment(lib,"kami.lib")
#pragma comment(lib,"Lua.lib")
#include <kami.h>
#include <resources.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
class Shader {
public:
GLuint shader;
Shader() = default;
Shader(GLuint &shaderProgram, GLuint shaderType, std::string shaderSource){
compile(shaderProgram, shaderType, shaderSource);
};
~Shader() = default;
shaderProgram.bind();
glBindTexture(GL_TEXTURE_2D, sys.texture.get(1).gltexture);
glm::mat4 projection = glm::ortho(0.0f, (float)sys.gc.buffer.width, (float)sys.gc.buffer.height, 0.0f);
glm::mat4 trans = glm::translate(
glm::mat4(1.0f),
glm::vec3(translate.x, translate.y, 0.0f)
);
glm::mat4 view = glm::rotate(
trans,
auto projection = glm::ortho(0.0f, (float)window.width, 0.0f, (float)window.height);
auto view = glm::mat4(1.);
auto ratio = ASPRatio(window, buffer, false);
auto model = glm::scale(
glm::mat4(1.0f),
glm::vec3(ratio.width / float(window.width), ratio.height / float(window.height), 0.0f)
);
auto MVP = projection*view*model;