Skip to content

Instantly share code, notes, and snippets.

View johnfredcee's full-sized avatar
🚀
On an intergalactic cruise

John Connors johnfredcee

🚀
On an intergalactic cruise
View GitHub Profile
@johnfredcee
johnfredcee / object.c
Created July 13, 2014 13:51
Another c based object system sketch - decouple code from data
enum eClass
{
MODEL,
RENDERABLE,
ATTACHMENT,
LOCATION
};
@johnfredcee
johnfredcee / dot.emacs
Created July 13, 2014 14:35
Dot emacs with el-get
;; Ensure unix binaries on path
(setenv "PATH" (concat "C:\\wsr\\apps\\Git\\bin" path-separator "C:\\wsr\\apps\\emacs-24.3\\bin" path-separator (getenv "PATH")))
;;; basic load-path setup
;;; ------------------------------------------------------------------
(defun add-subdirs-to-load-path (dir)
@johnfredcee
johnfredcee / use-tinyscheme.c
Created July 21, 2014 18:22
TinyScheme Integration Example
/**
* hello-scheme for illustration how to embed
* the tiny scheme interpreter in a C program
*
* 2012, OL
*/
#include <stdio.h>
#include <string.h>
#include "scheme.h"
/* Copyright 2010 Nurullah Akkaya */
/* lisp.c is free software: you can redistribute it and/or modify it */
/* under the terms of the GNU General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* lisp.c is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
;;; The following lines added by ql:add-to-init-file:
#-quicklisp
(let ((quicklisp-init #P"/wsr/lisp/quicklisp/setup.lisp"))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
(defun start-swank-server (&key (port 4006))
"Starts a swank-server on the localhost interface."
@johnfredcee
johnfredcee / opticl-cl-vectors.lisp
Last active November 26, 2015 15:01
Using cl-vectors with opticl
(let ((state (aa:make-state))) ; create the state
;; the 1st triangle
(aa:line-f state 200 50 250 150) ; describe the 3 sides
(aa:line-f state 250 150 50 100) ; of the first triangle
(aa:line-f state 50 100 200 50)
;; the 2nd triangle
(aa:line-f state 75 25 10 75) ; describe the 3 sides
(aa:line-f state 10 75 175 100) ; of the second triangle
(aa:line-f state 175 100 75 25)
(let* ((image (opticl:make-8-bit-rgba-image 200 300 :initial-element 255)))
@johnfredcee
johnfredcee / nanovg_fb.cpp
Created February 2, 2017 10:38
Nanovg - render to framebuffer
nvgImageSize(vg, fb->image, &fboWidth, &fboHeight);
winWidth = (int)(fboWidth / pxRatio);
winHeight = (int)(fboHeight / pxRatio);
// Draw some stuff to an FBO as a test
nvgluBindFramebuffer(fb);
glViewport(0, 0, fboWidth, fboHeight);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
nvgBeginFrame(vg, winWidth, winHeight, pxRatio);
@johnfredcee
johnfredcee / vertlist.py
Last active December 31, 2018 09:43
Naive mesh representation
import euclid
from euclid import Vector3
# naive first attempt at a mesh representation
# a straight list of vertices
class Mesh:
def __init__(self, vertices=[]):
@johnfredcee
johnfredcee / facelist.py
Created December 31, 2018 09:43
Slightly less naive mesh represenation
# if you can't rely on euclid, what can you rely on?
import euclid
from euclid import Vector3
class Mesh:
def __init__(self, vertices=[], faces=[]):
"""Initialises a vertex with a list of faces. Vertex array is a list of Vector3. Face array is a list of 3 tuple indexes into vertex array."""
self.vertex_list = vertices
self.face_list = faces
@johnfredcee
johnfredcee / facelist.py
Created January 2, 2019 16:13
Mesh representation - with edges.
# if you can't rely on euclid, what can you rely on?
import euclid
from euclid import Vector3
class Mesh:
def __init__(self, vertices=[], faces=[]):
"""Initialises a vertex with a list of faces. Vertex array is a list of Vector3. Face array is a list of 3 tuple indexes into vertex array."""
self.vertex_list = vertices
self.face_list = faces