Skip to content

Instantly share code, notes, and snippets.

@roxlu
roxlu / list.txt
Created January 25, 2013 19:22
List of compiler targets. Use for example: ./configure --target=x86-darwin11-gcc
armv5te-android-gcc armv5te-linux-rvct armv5te-linux-gcc
armv5te-none-rvct
armv6-darwin-gcc armv6-linux-rvct armv6-linux-gcc
armv6-none-rvct
armv7-android-gcc armv7-darwin-gcc armv7-linux-rvct
armv7-linux-gcc armv7-none-rvct
mips32-linux-gcc
ppc32-darwin8-gcc ppc32-darwin9-gcc ppc32-linux-gcc
ppc64-darwin8-gcc ppc64-darwin9-gcc ppc64-linux-gcc
sparc-solaris-gcc
@roxlu
roxlu / TestPattern.cpp
Created September 5, 2013 18:12
Example usage of X264. We create a raw YUV pattern and encode it with x264.
#include <cmath>
#include <assert.h>
#include <core/TestPattern.h>
TestPattern::TestPattern()
:w(0)
,h(0)
,frame_num(0)
,duration(0)
@roxlu
roxlu / Weather.cpp
Created January 6, 2014 11:11
CURL retrieve HTML into string
size_t weather_write_data(void* ptr, size_t size, size_t nmemb, void* str) {
std::string* s = static_cast<std::string*>(str);
std::copy((char*)ptr, (char*)ptr + (size + nmemb), std::back_inserter(*s));
return size * nmemb;
}
std::string weather_download_yahoo_rss() {
std::string result;
std::string url = "http://weather.yahooapis.com/forecastrss?w=10242&u=c"; // w=10242 is Aberaron
@roxlu
roxlu / uyvy422.c
Created June 17, 2013 08:43
GL 3.0, UYVY422 shader using GL_RGB_422_APPLE as internalFormat, GL_UNSIGNED_SHORT_8_8_APPLE as format
static const char* YUYV_VS = ""
"#version 150\n"
"uniform mat4 u_pm;"
"uniform mat4 u_mm;"
"in vec4 a_pos;"
"in vec2 a_tex;"
"out vec2 v_tex;"
"void main() {"
" gl_Position = u_pm * u_mm * a_pos; "
@roxlu
roxlu / VideoSurface.cpp
Created January 29, 2013 11:25
Fast texture uploads using pixel buffer objects. Improved upload of a 768x1366 texture from 16-20ms to 1-3ms (we can improve the performance a bit more by using GPU default pixel formats)
#include <shared/VideoSurface.h>
GLuint VideoSurface::prog = 0;
GLint VideoSurface::u_pm = 0;
GLint VideoSurface::u_mm = 0;
GLint VideoSurface::u_tex = 0;
GLfloat VideoSurface::pm[16] = {0};
VideoSurface::VideoSurface()
:width(0)
@roxlu
roxlu / Socket.cpp
Created September 12, 2012 20:53
Basic Winsock/Posix client socket wrapper (windows/mac)
#include <roxlu/io/Socket.h>
Socket::Socket() {
#ifdef _WIN32
int result = WSAStartup(MAKEWORD(2,2), &wsa_data);
if(result != 0) {
printf("Error: cannot initialize WinSock.\n");
WSACleanup();
}
#endif
@roxlu
roxlu / YUV420PGrabber.cpp
Created September 16, 2013 11:06
YUV420P grabber
#include <assert.h>
#include <roxlu/core/Utils.h>
#include <roxlu/core/Log.h>
#include <image/Image.h>
#include <video/YUV420PGrabber.h>
YUV420PGrabber::YUV420PGrabber()
:y_prog(0)
,y_vert(0)
,y_frag(0)
@roxlu
roxlu / CMakeLists.txt
Created June 23, 2013 09:50
Setting color bit depth. The GLFW 3.0.0 release used a color bit depth of 5,6,5 by default. You should update to 3.0.2 to fix this or set the bit depth yourself. Download the latest from https://github.com/glfw/glfw. This source is a test case I used to figure out why my colors/texcoords were interpolating wrongly. Using this dir structure: src/…
cmake_minimum_required(VERSION 2.8)
set(bd ${CMAKE_CURRENT_LIST_DIR}/)
set(src
${bd}/src/main.cpp
)
find_library(fr_co Cocoa)
@roxlu
roxlu / .gitignore
Last active September 17, 2020 05:49
Super basic glfw setup - this uses GLFX to setup function pointers
._DS*
*DS_Store*
build
install
extern
node-*
references
@roxlu
roxlu / TestFboChangeBuffer.cpp
Last active September 11, 2020 15:48
Comparing the performance of different ping/pong techniques when using FBOs. One version uses two fbos and swaps between these, the other switches the draw and read buffer. See these results https://docs.google.com/spreadsheets/d/1ZyTQGkjYQajQtu8OvgRyaXJl46F4rZJStBCEK2kebgE/edit?usp=sharing for a comparison. It seems that switching read / draw b…
#include <poly/Log.h>
#include <TestFboChangeBuffer.h>
using namespace poly;
TestFboChangeBuffer::TestFboChangeBuffer()
:fbo(0)
,dx(0)
{
tex[0] = 0;