Skip to content

Instantly share code, notes, and snippets.

@sherief
sherief / gist:5233271
Created March 24, 2013 19:57
Tumblr C++ photo upload
#include <iostream>
#include <oauth/oauth.h>
#include <sys/socket.h>
#include <curl/curl.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <iostream>
#include <soft-ieee754/ieee754.hpp>
using namespace std;
int main()
{
typedef IEEE754<10, 5, 15> fp16;
fp16 foo;
#include <iostream>
#include <cassert>
#define GLFW_INCLUDE_GL3
#include <GL/glfw.h>
#include <lgsl/runtime.hpp>
#include <gfx/mat4.h>
struct uniform_info
{
std::string name;
std::string type;
int component_count;
bool is_matrix;
int array_count;
GLint location;
pfn_void parameter_setting_function;
uniform_info()
//Projection Matrix
mat4x4 mP = perspective_matrix(45.0, 1, 0.1, 100);
mP = transpose(mP);
//Translation
mat4x4 mT = mat4x4::translation(float3(0, 0, -14));
//Rotation
mat4x4 mR = rotation_matrix_degrees(Rotation, float3(0, 1, 0));
//View matrix
mat4x4 mV = lookat_matrix(float3(0.0, 0.0, -3.0), float3(0, 0, -3), float3(0, 1, 0));
mV = transpose(mV);
//Projection Matrix
mat4x4 mP = perspective_matrix(45.0, 1, 0.1, 100);
//Translation
mat4x4 mT = mat4x4::translation(float3(0, 0, -14));
//Rotation
mat4x4 mR = rotation_matrix_degrees(Rotation, float3(0, 1, 0));
//View matrix
mat4x4 mV = lookat_matrix(float3(0.0, 0.0, -3.0), float3(0, 0, -3), float3(0, 1, 0));
mV = transpose(mV);
//WorldViewProjection
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
int main(int argc, const char * argv[])
{
Assimp::Importer importer;
unsigned int ppsteps =
aiProcess_FindInvalidData | // detect invalid model data, such as invalid normal vectors
0;
// And have it read the given file with some example postprocessing
@sherief
sherief / gist:7205359
Created October 28, 2013 21:42
Uniform extraction from the parse tree of a LiteGraph Shader after it's been translated to GLSL.
class uniform_extractor
{
public:
std::vector<uniform_info> uniforms;
void operator()(const semparse::semantic_graph_node& Node)
{
if(is_uniform_node(Node))
{
//Extract info
uniform_info Info;
///////
check_al_error();
alGetSourcei(SourceID, AL_BUFFERS_PROCESSED, &SourceBuffersProcessed);
alGetSourcei(SourceID, AL_BUFFERS_QUEUED, &SourceBuffersQueued);
check_al_error();
//
printf("\tfill_and_queue_buffers pre-q - AL_BUFFERS_QUEUED: %d\n", SourceBuffersQueued);
printf("\tfill_and_queue_buffers pre-q - AL_BUFFERS_PROCESSED: %d\n", SourceBuffersProcessed);
check_al_error();
/////////