Skip to content

Instantly share code, notes, and snippets.

xaxxon@ubuntu:~$ telnet 104.207.142.70 80
Trying 104.207.142.70...
Connected to 104.207.142.70.
Escape character is '^]'.
GET / HTTP/1.1
host: terabyte-gaming.net
HTTP/1.1 200 OK
Server: nginx/1.9.3 (Ubuntu)
Date: Sun, 17 Apr 2016 07:04:38 GMT
WARNING: It looks like you are running these tools from an MSYS shell
(as opposed to a MinGW shell). This shell is not supported and may
fail in mysterious ways.
To run the supported MinGW shell, use `git bash`, or use `bin/bash.exe`
in your MinGW installation, as opposed to `usr/bin/bash.exe`.
@xaxxon
xaxxon / graphics.cpp
Last active April 10, 2016 01:36
why does this turn blue when the if block runs?
TextureData Graphics::load_font_texture(const std::string & message, int max_width, int max_height)
{
SDL_Color color = {255,255,255,255};
SDL_Surface * rendered_message = TTF_RenderText_Blended(Graphics::font, message.c_str(), color);
if (rendered_message->w > max_width ||
rendered_message->h > max_height) {
const float horizontal_scaling = rendered_message->w / (float)max_width;
const float vertical_scaling = rendered_message->h / (float)max_height;
const float final_scaling = horizontal_scaling > vertical_scaling ? horizontal_scaling : vertical_scaling;
SDL_Surface * scaled_surface = SDL_CreateRGBSurface(0, max_width / final_scaling, max_height / final_scaling,
@xaxxon
xaxxon / quad_list.cpp
Created April 7, 2016 17:02
updated line drawing shaders
const char * LineSegmentList::VERTEX_SHADER = R"VERTEXSHADER(#version 410
in vec2 vertex;
in vec2 normal;
in vec4 color;
in float width;
out vec2 normal_g;
@xaxxon
xaxxon / quad_list.cpp
Created April 7, 2016 07:18
fat line shaders
const char * LineSegmentList::VERTEX_SHADER = R"VERTEXSHADER(#version 410
in vec2 vertex;
in vec2 normal;
in vec4 color;
in float width;
out vec2 normal_g;
@xaxxon
xaxxon / quad_list.h
Created April 7, 2016 07:02
allocating an array off a constexpr
struct LineSegment {
struct Vertex {
glm::vec2 position;
glm::vec2 normal;
float width;
uint32_t color;
Vertex() = default;
Vertex(const Vertex &) = delete;
};
x clang+llvm-3.8.0-x86_64-apple-darwin/bin/scan-build
x clang+llvm-3.8.0-x86_64-apple-darwin/bin/scan-view
x clang+llvm-3.8.0-x86_64-apple-darwin/bin/set-xcode-analyzer
x clang+llvm-3.8.0-x86_64-apple-darwin/bin/verify-uselistorder
x clang+llvm-3.8.0-x86_64-apple-darwin/bin/yaml2obj
zacs-MacBook-Pro:deleteme-clang xaxxon$ cd clang+llvm-3.8.0-x86_64-apple-darwin
zacs-MacBook-Pro:clang+llvm-3.8.0-x86_64-apple-darwin xaxxon$ ls
bin include lib libexec share
zacs-MacBook-Pro:clang+llvm-3.8.0-x86_64-apple-darwin xaxxon$ ls -l/
ls: illegal option -- /
@xaxxon
xaxxon / graphics.cpp
Created April 6, 2016 06:06
gl error checker
void Graphics::check_error(const char * filename, int line_number) {
GLenum error;
while ((error = glGetError()) != 0) {
printf("GL Error %x: %s:%d\n", error, filename, line_number);
exit(1);
}
}
@xaxxon
xaxxon / graphics.cpp
Created April 6, 2016 06:05
shader builder
GLuint Graphics::build_shader_program(const char * vertex_shader_source, const char * fragment_shader_source) {
// printf("Compiling shaders %s and %s\n", vertex_shader_source, fragment_shader_source);
/* create program object and attach shaders */
GLuint program = glCreateProgram();
shaderAttach(program, GL_VERTEX_SHADER, vertex_shader_source);
check_error(__FILE__, __LINE__);
shaderAttach(program, GL_FRAGMENT_SHADER, fragment_shader_source);
check_error(__FILE__, __LINE__);
@xaxxon
xaxxon / weirderror
Last active February 28, 2016 03:51
template<typename T, class Enable=void>
struct CastToNative;
// This line causes the compiler error below
CastToNative<std::vector<std::string>>()(...);
modules.cpp:55:25: error: ambiguous partial specializations of 'CastToNative<std::__1::vector<std::__1::basic_string<char>, std::__1::allocator<std::__1::basic_string<char> > >, void>'
/users/xaxxon/v8-class-wrapper/casts.hpp:90:8: note: partial specialization matches [with ElementType = std::__1::basic_string<char>, Rest = <std::__1::allocator<std::__1::basic_string<char> >>]