Skip to content

Instantly share code, notes, and snippets.

@rdb
rdb / main.py
Last active August 29, 2015 14:02 — forked from anonymous/main.py
# Simple render to texture
node = loader.loadModel("panda")
depthtex = Texture('depth')
depthtex.set_clear(1.0)
colortex = Texture('color')
colortex.set_clear((0, 0, 0, 1))
normaltex = Texture('normal')
@rdb
rdb / UBOs.py
Last active August 29, 2015 14:03 — forked from tobspr/UBOs.py
class Light:
def __init__(self):
self.pos = ParamVector3f(0)
self.color = ParamVector3f(1,1,0)
self.mvp = ParamMatrix4f(0)
self.struct = StructParameter()
array = ArrayParameter()
Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
:audio(debug): create_AudioManager()
audio_library_name="p3openal_audio"
:audio(debug): dl_name="libp3openal_audio.so"
:audio(debug): symbol of get_audio_manager_func_openal_audio = 000007FEECD026F0
:audio(debug): Create_OpenALAudioManager()
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80004005
:audio(error): OpenALAudioManager: alcOpenDevice(NULL): ALC couldn't open device
@rdb
rdb / comparison
Created December 12, 2013 17:46
comparison between macro-composites and compiling the files individually
$ composite_files=`cat p3dtoolbase_composite1.cxx | cut -d '"' -f 2`
$ time g++ -c $composite_files -I../../../build/dtool/ -I/usr/include/python2.7
real 0m4.643s
user 0m4.151s
sys 0m0.477s
$ time g++ -c p3dtoolbase_composite1.cxx -I../../../build/dtool/ -I/usr/include/python2.7
real 0m0.848s
@rdb
rdb / temp.cpp
Last active January 5, 2016 17:38
Color temperature to linearized sRGB color
// Recalculate the color.
PN_stdfloat mm = 1000.0 / temperature;
PN_stdfloat mm2 = mm * mm;
PN_stdfloat mm3 = mm2 * mm;
PN_stdfloat x, y;
if (temperature < 4000) {
x = -0.2661239 * mm3 - 0.2343580 * mm2 + 0.8776956 * mm + 0.179910;
} else {
x = -3.0258469 * mm3 + 2.1070379 * mm2 + 0.2226347 * mm + 0.240390;
from panda3d import core, direct, physics, fx, egg
import sys
if len(sys.argv) > 1:
classname = sys.argv[1]
else:
classname = input("class> ")
for module in [core, direct, physics, fx, egg]:
if hasattr(module, classname):

Keybase proof

I hereby claim:

  • I am rdb on github.
  • I am rdb (https://keybase.io/rdb) on keybase.
  • I have a public key whose fingerprint is 2C05 2186 A18D E379 EEC5 C534 92F0 6704 80AD 5260

To claim this, I am signing this object:

@rdb
rdb / v4l_check.c
Created September 24, 2014 12:13
Small programs that lists supported V4L2 formats.
#include <linux/videodev2.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
struct v4l2_fmtdesc fmt;
int i;
const char *dev;
int fd;
@rdb
rdb / .py
Created November 12, 2017 20:16
# When importing a Panda class, importing everything into the namespace is considered bad style:
from panda3d.bullet import *
# Instead, it is better to enumerate each class specifically:
from panda3d.bullet import BulletWorld, BulletDebugNode
# This gets quite tedious to maintain, so it is easier to do:
from panda3d import bullet
w = bullet.BulletWorld()
@rdb
rdb / main.py
Created March 1, 2018 20:13
Geometry shaders with adjacency in Panda3D
from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
shader = Shader.load(Shader.SL_GLSL, "silh.vert", "silh.frag", "silh.geom")
base = ShowBase()
model = base.loader.loadModel("teapot.egg")
model.reparentTo(base.render)
model.setShader(shader)
model.setRenderModeThickness(2.0)