Skip to content

Instantly share code, notes, and snippets.

@rectalogic
rectalogic / gist:2254054
Created March 30, 2012 18:59
melt opengl deadlock
consumer_xgl_init
filter_glsl_csc_init -----------------------
consumer_xgl_init
+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
|1=-10| |2= -5| |3= -2| |4= -1| |5= 0| |6= 1| |7= 2| |8= 5| |9= 10|
+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
+---------------------------------------------------------------------+
| H = back 1 minute, L = forward 1 minute |
| h = previous frame, l = next frame |
| g = start of clip, j = next clip, k = previous clip |
@rectalogic
rectalogic / gist:2312526
Created April 5, 2012 17:01
template dispatching to pointer to member function
template<class T, int Arity, v8::Handle<v8::Value> (T::*InvocationCallbackMember)(v8::Arguments const&)>
static v8::Handle<v8::Value> InvocationCallbackDispatcher(v8::Arguments const& args) {
if (args.Length() < Arity)
return ThrowArgCount();
T* object = T::FromV8Object(args.Holder());
if (!object)
return ThrowObjectDisposed();
try {
return ((*object).*(InvocationCallbackMember))(args);
} catch (...) {
@rectalogic
rectalogic / resample-bug.c
Created April 20, 2012 20:42
Demonstrates swr_convert corruption of packed audio
#include <libavcodec/avcodec.h>
#include <libswresample/swresample.h>
int main(int argc, char* argv[]) {
int r;
int nb_samples = 10;
int output_nb_samples = nb_samples;
int nb_channels = av_get_channel_layout_nb_channels(AV_CH_LAYOUT_STEREO);
int bytes_per_sample = av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) * nb_channels;
int bufsize = av_samples_get_buffer_size(NULL, nb_channels, nb_samples,
int zkrb_call_zoo_acreate(zhandle_t *zh, const char *path, const char *value, int valuelen, const struct ACL_vector *acl, int flags, string_completion_t completion, const void *data) {
zkrb_zoo_acreate_args_t args = {
.rc = rc,
.zh = zh,
.path = path,
.value = value,
.valuelen = valuelen,
.acl = acl,
.flags = flags,
.completion = completion,
@rectalogic
rectalogic / gist:2559736
Created April 30, 2012 16:21
Panda3D GLSL
from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
vshader = """
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
"""
fshader = """
@rectalogic
rectalogic / gist:3061630
Created July 6, 2012 17:55
Extend rspec with a method similar to should_receive but that invokes the original method
module RSpec
module Mocks
module Methods
def should_receive_invoke(message, opts={}, &block)
original_method = self.method(message.to_sym)
should_receive(message, opts) do |*args|
original_method.call(*args)
end
end
end
@rectalogic
rectalogic / gist:3061649
Created July 6, 2012 17:56
Extend rspec with a method similar to should_receive but that invokes the original method
module RSpec
module Mocks
module Methods
def should_receive_invoke(message, opts={})
original_method = self.method(message.to_sym)
should_receive(message, opts) do |*args|
original_method.call(*args)
end
end
end
@rectalogic
rectalogic / gist:3151867
Created July 20, 2012 16:54
multisample offscreen rendering in TestRenderToMemory
Index: src/test/jme3test/post/TestRenderToMemory.java
===================================================================
--- src/test/jme3test/post/TestRenderToMemory.java (revision 9561)
+++ src/test/jme3test/post/TestRenderToMemory.java (working copy)
@@ -75,6 +75,7 @@
private float angle = 0;
private FrameBuffer offBuffer;
+ private FrameBuffer resolveBuffer;
private ViewPort offView;
@rectalogic
rectalogic / gist:3153015
Created July 20, 2012 20:21
multiple filters with MSAA
Index: src/test/jme3test/post/TestPosterization.java
===================================================================
--- src/test/jme3test/post/TestPosterization.java (revision 9561)
+++ src/test/jme3test/post/TestPosterization.java (working copy)
@@ -43,6 +43,7 @@
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.PosterizationFilter;
+import com.jme3.post.filters.CrossHatchFilter;
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
{
"source": "http://somehost.com/movie.mov",
"formats": {
"poster": "container1/poster.jpg",
"thumbnail": "container2/thumb.jpg",
"standard_definition": "container3/video.mp4"
}
}