Skip to content

Instantly share code, notes, and snippets.

@brht0
brht0 / trianglefill_and_stuff.cpp
Created March 25, 2022 05:57
Triangle fill and line draw algorithms with SDL2 using SDL_Surface
// Untested code, but should work with some tweaks (more or less)
struct Point{
double x, y;
};
struct Line{
Point p1, p2;
};
// to keep my sanity heres a simplified version of a texture demo for my future self
// original from: github.com/progschj/OpenGL-Examples/blob/master/03texture.cpp
#define GL_GLEXT_PROTOTYPES
#include <GLFW/glfw3.h>
#include <iostream>
#include <string>
#include <vector>
@brht0
brht0 / fontcaching.cpp
Created December 31, 2021 17:47
Simple Text rendering system for OpenGL with GLFW using SDL_ttf and font caching with demo
/* Declarations */
#include <GLFW/glfw3.h>
#include <SDL2/SDL_ttf.h>
#include <string>
class Font{
public:
Font(const char* filename, int resolution);
void RenderText(std::string text, double x, double y, double textHeight, SDL_Color color);