Still need to make sure it compiles and whatnot on OSX, and also add the proper proprocessor defines.
--- /dev/null
+# ignore built files
+build/*
--- /dev/null
+//
+// EAGLView.h
+// Littlest
+//
+// Created by Doris Chen on 12/4/10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import <OpenGLES/ES1/gl.h>
+#import <OpenGLES/ES1/glext.h>
+#import <OpenGLES/ES2/gl.h>
+#import <OpenGLES/ES2/glext.h>
+
+// This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
+// The view content is basically an EAGL surface you render your OpenGL scene into.
+// Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
+@interface EAGLView : UIView
+{
+@private
+ EAGLContext *context;
+
+ // The pixel dimensions of the CAEAGLLayer.
+ GLint framebufferWidth;
+ GLint framebufferHeight;
+
+ // The OpenGL ES names for the framebuffer and renderbuffer used to render to this view.
+ GLuint defaultFramebuffer, colorRenderbuffer;
+}
+
+@property (nonatomic, retain) EAGLContext *context;
+
+- (void)setFramebuffer;
+- (BOOL)presentFramebuffer;
+
+@end
--- /dev/null
+//
+// EAGLView.m
+// Littlest
+//
+// Created by Doris Chen on 12/4/10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <QuartzCore/QuartzCore.h>
+
+#import "EAGLView.h"
+
+//-----------------------------------------------------------------------------------------------------------
+@interface EAGLView (PrivateMethods)
+- (void)createFrameBuffer;
+- (void)deleteFramebuffer;
+@end
+
+//-----------------------------------------------------------------------------------------------------------
+@implementation EAGLView
+
+@dynamic context;
+
+//-----------------------------------------------------------------------------------------------------------
+// You must implement this method
++ (Class)layerClass
+{
+ return [CAEAGLLayer class];
+}
+
+//-----------------------------------------------------------------------------------------------------------
+//The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:.
+- (id)initWithCoder:(NSCoder*)coder
+{
+ self = [super initWithCoder:coder];
+ if (self)
+ {
+ CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
+
+ eaglLayer.opaque = TRUE;
+ eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
+ kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
+ nil];
+ }
+
+ return self;
+}
+
+//-----------------------------------------------------------------------------------------------------------
+- (void)dealloc
+{
+ [self deleteFramebuffer];
+ [context release];
+
+ [super dealloc];
+}
+
+//-----------------------------------------------------------------------------------------------------------
+- (EAGLContext *)context
+{
+ return context;
+}
+
+//-----------------------------------------------------------------------------------------------------------
+- (void)setContext:(EAGLContext *)newContext
+{
+ if (context != newContext)
+ {
+ [self deleteFramebuffer];
+ [context release];
+
+ context = [newContext retain];
+ }
+}
+
+//-----------------------------------------------------------------------------------------------------------
+- (void)createFrameBuffer
+{
+ if (context && !defaultFramebuffer)
+ {
+ [EAGLContext setCurrentContext:context];
+
+ // Create default framebuffer object.
+ glGenFramebuffers(1, &defaultFramebuffer);
+ glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
+
+ // Create color render buffer and allocate backing store.
+ glGenRenderbuffers(1, &colorRenderbuffer);
+ glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
+ [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer];
+ glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &framebufferWidth);
+ glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &framebufferHeight);
+
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
+
+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
+ NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
+ }
+}
+
+//-----------------------------------------------------------------------------------------------------------
+- (void)deleteFramebuffer
+{
+ if (context)
+ {
+ [EAGLContext setCurrentContext:context];
+
+ if (defaultFramebuffer)
+ {
+ glDeleteFramebuffers(1, &defaultFramebuffer);
+ defaultFramebuffer = 0;
+ }
+
+ if (colorRenderbuffer)
+ {
+ glDeleteRenderbuffers(1, &colorRenderbuffer);
+ colorRenderbuffer = 0;
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------------------------------------
+- (void)setFramebuffer
+{
+ if (context)
+ {
+ [EAGLContext setCurrentContext:context];
+
+ if (!defaultFramebuffer)
+ [self createFrameBuffer];
+
+ glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
+
+ glViewport(0, 0, framebufferWidth, framebufferHeight);
+ }
+}
+
+//-----------------------------------------------------------------------------------------------------------
+- (BOOL)presentFramebuffer
+{
+ BOOL success = FALSE;
+
+ if (context)
+ {
+ [EAGLContext setCurrentContext:context];
+
+ glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
+
+ success = [context presentRenderbuffer:GL_RENDERBUFFER];
+ }
+
+ return success;
+}
+
+//-----------------------------------------------------------------------------------------------------------
+- (void)layoutSubviews
+{
+ // The framebuffer will be re-created at the beginning of the next setFramebuffer method call.
+ [self deleteFramebuffer];
+}
+
+@end
--- /dev/null
+#pragma once\r
+\r
+#ifdef DEBUG\r
+\r
+#include <assert.h>\r
+\r
+#define Assert(expression) if (!(expression)) __debugbreak();\r
+\r
+#define AssertMessage(expression, message, ...) \\r
+ if (!(expression)) Printf(message, ##__VA_ARGS__)\r
+\r
+#else\r
+\r
+slInline void Assert(bool expression) {}\r
+slInline void AssertMsg(bool expression, char* msg, ...) {}\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+#pragma once\r
+\r
+namespace Foundation\r
+{\r
+ class CBase\r
+ {\r
+ public:\r
+ CBase() {}\r
+ ~CBase() {}\r
+ };\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include "Foundation/Common/GlobalTypes.h"\r
+\r
+#ifdef _WINDOWS\r
+#define __WINDOWS__\r
+#endif\r
+\r
+#ifdef _DEBUG\r
+#define DEBUG\r
+#endif\r
+\r
+#ifdef _NDEBUG\r
+#define RELEASE\r
+#endif\r
+\r
+#ifndef NULL\r
+#define NULL 0\r
+#endif\r
+\r
+#ifndef FALSE\r
+#define FALSE 0\r
+#endif\r
+\r
+#ifndef TRUE\r
+#define TRUE 1\r
+#endif\r
+\r
+//----------------------------------------------------------------------------------------\r
+// cache information\r
+#ifndef CACHE_LINE_SIZE\r
+#define CACHE_LINE_SIZE 128 //equal to 2 line for intel normally\r
+#endif\r
+\r
+//----------------------------------------------------------------------------------------\r
+//force inline on non-debug, might make code explode\r
+#ifdef _DEBUG\r
+ #define slInline inline\r
+#else\r
+ #define slInline __forceinline\r
+#endif\r
+\r
+//compiler determined inline\r
+#define clInline inline\r
+\r
+#define slRestrict __restrict\r
+\r
+//----------------------------------------------------------------------------------------\r
+// alignment macros\r
+#if defined(__WINDOWS__)\r
+#define ALIGN(N) __declspec(align(N))\r
+#endif\r
+\r
+#define IS_POWER_OF_TWO(x) ( ((x) & -(x)) == (x) )\r
+\r
+#pragma warning(disable:4146) // =(\r
+#define ALIGN_UP(x, ALIGNMENT) ( ((x) + (ALIGNMENT) - 1) & -(ALIGNMENT) )\r
+#define ALIGN_DOWN(x, ALIGNMENT) ( (x) & -(ALIGNMENT) )\r
+\r
+#define POWER_OF_TWO_MOD(x, N) ( (x) & ((N) - 1) )\r
+\r
+#define ALIGN_CACHE ( ALIGN( CACHE_LINE_SIZE ) )\r
+\r
+//----------------------------------------------------------------------------------------\r
+// cache macros\r
+#if defined(__WINDOWS__)\r
+// uhh, nothing?\r
+#elif defined(__ARM__)\r
+#define DCBT(x) __asm__("pld" #(x))\r
+#else\r
+#error Not implemented yet!\r
+#endif\r
+\r
+//----------------------------------------------------------------------------------------\r
+// string and memory functions\r
+#if defined(__WINDOWS__)\r
+ #include <string.h>\r
+\r
+ #pragma intrinsic(memcpy)\r
+ #pragma intrinsic(memset)\r
+ #pragma intrinsic(strcmp)\r
+ #pragma intrinsic(strcpy)\r
+ #pragma intrinsic(strlen)\r
+ #pragma intrinsic(strcat)\r
+#endif\r
+\r
+//----------------------------------------------------------------------------------------\r
+// color constants\r
+#define NULL_COLOR 0x00000000\r
+#define BLACK_COLOR 0x000000ff\r
+#define RED_COLOR 0xff0000ff\r
+#define GREEN_COLOR 0x00ff00ff\r
+#define BLUE_COLOR 0x0000ffff\r
+#define WHITE_COLOR 0xffffffff\r
+\r
+//----------------------------------------------------------------------------------------\r
+#if defined(__WINDOWS__)\r
+slInline uint8_t LZCount(uint64_t x)\r
+{\r
+ uint8_t leading_zero_count = 0;\r
+ uint8_t next_shift = 32;\r
+ uint64_t copy = x;\r
+ while (next_shift != 0)\r
+ {\r
+ bool non_zero = copy >= (0x1ULL << next_shift);\r
+ uint8_t actual_shift = (uint8_t)non_zero * next_shift;\r
+ leading_zero_count += actual_shift;\r
+ copy >>= actual_shift;\r
+ next_shift >>= 1;\r
+ }\r
+ leading_zero_count += (copy == 0x1ULL);\r
+\r
+ return leading_zero_count;\r
+}\r
+#else\r
+#error // use lzcnt!\r
+#endif\r
+\r
+//----------------------------------------------------------------------------------------\r
+#define RightMostEnabledBit(x) ((x) & -(x))
\ No newline at end of file
--- /dev/null
+#pragma once\r
+\r
+#include "GlobalDefines.h"\r
+#include "GlobalTypes.h"\r
+#include "Assert.h"\r
--- /dev/null
+#pragma once\r
+\r
+#ifdef uint32_t\r
+#undef uint32_t\r
+#endif\r
+\r
+typedef signed char int8_t;\r
+typedef unsigned char uint8_t;\r
+typedef short int16_t;\r
+typedef unsigned short uint16_t;\r
+typedef int int32_t;\r
+typedef unsigned int uint32_t;\r
+typedef long long int64_t;\r
+typedef unsigned long long uint64_t;\r
+typedef uint32_t color32_t;\r
+\r
+union IntFloat\r
+{\r
+ int8_t m_Int8[4];\r
+ uint8_t m_UInt8[4];\r
+ int16_t m_Int16[2];\r
+ uint16_t m_UInt16[2];\r
+ int32_t m_Int32;\r
+ uint32_t m_UInt32;\r
+ float m_Float;\r
+};\r
+\r
+union LongDouble\r
+{\r
+ int8_t m_Int8[8];\r
+ uint8_t m_UInt8[8];\r
+ int16_t m_Int16[4];\r
+ uint16_t m_UInt16[4];\r
+ int32_t m_Int32[2];\r
+ uint32_t m_UInt32[2];\r
+ int64_t m_Int64;\r
+ uint64_t m_UInt64;\r
+ float m_Float[2];\r
+ double m_Double;\r
+};\r
--- /dev/null
+#pragma once\r
+\r
+#include <stdio.h>\r
+\r
+#define Printf(message, ...) printf(message, ##__VA_ARGS__)\r
--- /dev/null
+#pragma once\r
+\r
+#include "Foundation/Common/GlobalInclude.h"\r
+\r
+/*\r
+Statically allocates for faster access\r
+*/\r
+\r
+namespace Foundation\r
+{\r
+\r
+template <typename T> \r
+class Singleton\r
+{\r
+private:\r
+ static T* m_Instance; \r
+\r
+protected:\r
+ Singleton(){m_Instance = 0;}\r
+\r
+public:\r
+ static T* Create()\r
+ {\r
+ Assert( m_Instance == 0);\r
+ if(m_Instance)\r
+ {\r
+ return m_Instance;\r
+ }\r
+ m_Instance = new(16) T();\r
+ return m_Instance;\r
+ }\r
+\r
+ slInline static T* GetInstance()\r
+ {\r
+ //Assert( m_Instance == 0);\r
+ return m_Instance;\r
+ }\r
+\r
+ static void DestroyInstance()\r
+ {\r
+ if(m_Instance)\r
+ {\r
+ delete m_Instance;\r
+ }\r
+ }\r
+};\r
+\r
+template<typename T> T* Singleton<T>::m_Instance = 0;\r
+\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+#include "Foundation/Common/GlobalInclude.h"\r
+\r
+#define SET_BITS(x, new_val, shift, mask) ((x) = (((x) & ~(mask)) | (((new_val) << (shift)) & (mask))))\r
+#define ZERO_BITS(x, mask) ((x) &= ~(mask))\r
+#define OR_BITS (x, new_val, shift, mask) ((x) |= (((new_val) << (shift)) & (mask)))\r
+#define AND_BITS(x, new_val, shift, mask) ((x) &= (((new_val) << (shift)) & (mask)))\r
+#define GET_BITS(x, mask) ((x) & (mask))\r
+#define GET_BITS_RIGHT(x, shift, mask) (((x) & (mask)) >> (shift))\r
--- /dev/null
+#pragma once\r
+\r
+#include "LocklessRingBuffer.h"\r
+#include "Foundation/Synchronization/MemorySync.h"\r
+\r
+//----------------------------------------------------------------------------------------\r
+void LocklessRingBuffer::Init(void* buffer, uint32_t buffer_size)\r
+{\r
+ m_Base = (uint8_t*)buffer;\r
+ m_BufferSize = buffer_size;\r
+ m_WriteOffset = 0;\r
+ m_ReadOffset = 0;\r
+}\r
+\r
+//----------------------------------------------------------------------------------------\r
+void LocklessRingBuffer::Destroy()\r
+{\r
+ m_Base = NULL;\r
+ m_BufferSize = 0;\r
+ m_WriteOffset = 0;\r
+ m_ReadOffset = 0;\r
+}\r
+\r
+//----------------------------------------------------------------------------------------\r
+bool LocklessRingBuffer::Write(void* entry, uint32_t entry_size)\r
+{\r
+ Assert(entry_size < m_BufferSize);\r
+\r
+ uint32_t new_write_offset = m_WriteOffset;\r
+ uint32_t remaining_space = m_WriteOffset < m_ReadOffset ? m_ReadOffset - m_WriteOffset - 1 : m_ReadOffset + m_BufferSize - m_WriteOffset;\r
+ if (remaining_space < entry_size)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ bool write_will_end_lower = new_write_offset + entry_size >= m_BufferSize;\r
+\r
+ uint32_t distance_to_top = (entry_size > m_BufferSize - new_write_offset) ? (m_BufferSize - new_write_offset) : entry_size;\r
+ memcpy(m_Base + new_write_offset, entry, distance_to_top);