Skip to content

Instantly share code, notes, and snippets.

#include "KGStagePlayerComponent.h"
#include "glfw.h"
KGStagePlayerComponent* KGStagePlayerComponentNew(void){
KGStagePlayerComponent* self = calloc(1, sizeof(KGStagePlayerComponent));
return self;
}
void KGStagePlayerComponentDelete(KGStagePlayerComponent* self){
if(not self) return;
//This:
variant UniformValue (Array[GLfloat, 16], GLfloat, Array[GLubyte, 4], …);
record Uniform
(
name: String,
location: GLint,
value: ShaderUniformValue
);
NSBitmapImageRep* bitmapImageRep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: NULL
pixelsWide: targetImage.width
pixelsHigh: targetImage.height
bitsPerSample: 8
samplesPerPixel: 4
hasAlpha: YES
isPlanar: NO
colorSpaceName: NSDeviceRGBColorSpace
bytesPerRow: 0
Containable: interface {
getRawValue: func<T> -> T//Not really used...
}
Cell: class<T> implements Containable {
value: T
init: func(=value) {}
}
@od0x0
od0x0 / gist:1044107
Created June 24, 2011 02:28
Ideas I want to see in ooc
Features (I don't care about the syntax for this at this point):
1. Ignore the underlying ABI that is compiled to
Reasoning: Portability. A good example of how to handle things like this is with .NET/C#, where any name can be used as an identifier, but if it has other syntax nastiness around it (like being a keyword or having spaces in between) it can be prefixed with a @ or surrounded with []. Obviously we'd have to go with something different, but the same concept can be applied. This would allow compatibility with other languages that may (will!) have a different set of keywords than the ones we use in ooc
Alternative: We could just ignore the idea of a direct name mapping of structures/functions and create a JSON "interface" file, blah, blah, blah or do really nasty name mangling.
2. GC built into the language as a language triggered automatic reference counting system
Reasoning: GC is nice, but for applications where it's crucial to make sure that no sudden pauses of any duration occur, such as
@od0x0
od0x0 / gist:984994
Created May 21, 2011 23:20
Lexer (not sure if this is my broken one)
#pragma once
#include <stdbool.h>
#include <iso646.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef enum{
LX1LexerErrorNone,
LX1LexerErrorUnknown
@od0x0
od0x0 / gist:977800
Created May 18, 2011 01:00
My Lua Object System
Object = {}
local ObjectMetatables = {}
function Object:new(...)
local clone = {}
local meta=ObjectMetatables[self]
if meta == nil then
meta = {__index=self}
ObjectMetatables[self] = meta
#pragma once
#include "AECore.h"
#include "AEMath.h"
#include "AEArray.h"
typedef struct AERenderer AERenderer;
AERenderer* AERendererNew(void);
void AERendererDelete(AERenderer* self);
@od0x0
od0x0 / gist:965399
Created May 10, 2011 21:17
How I Load a .ogg into OpenAL Using stb_vorbis
typedef struct{
ALuint ID;
stb_vorbis* stream;
stb_vorbis_info info;
ALuint buffers[2];
ALuint source;
ALenum format;
#include "AE.h"
#include "AESDL.h"
static void FrameUpdate(AEWindow* window, double seconds){
//Do something here
}
static void FixedUpdate(AEWindow* window, double seconds){
//Do something here
}