diff --git a/CeedGL.xcodeproj/project.xcworkspace/xcuserdata/Club15CC.xcuserdatad/UserInterfaceState.xcuserstate b/CeedGL.xcodeproj/project.xcworkspace/xcuserdata/Club15CC.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..8c600c2
Binary files /dev/null and b/CeedGL.xcodeproj/project.xcworkspace/xcuserdata/Club15CC.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGL Mac Framework.xcscheme b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGL Mac Framework.xcscheme
new file mode 100644
index 0000000..f0c6f34
--- /dev/null
+++ b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGL Mac Framework.xcscheme
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGL.ios.xcscheme b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGL.ios.xcscheme
new file mode 100644
index 0000000..95d08d0
--- /dev/null
+++ b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGL.ios.xcscheme
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGL.mac.xcscheme b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGL.mac.xcscheme
new file mode 100644
index 0000000..a8cf997
--- /dev/null
+++ b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGL.mac.xcscheme
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGLDemo.ios.xcscheme b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGLDemo.ios.xcscheme
new file mode 100644
index 0000000..2b4e1b8
--- /dev/null
+++ b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGLDemo.ios.xcscheme
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGLDemo.mac.xcscheme b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGLDemo.mac.xcscheme
new file mode 100644
index 0000000..47d57a5
--- /dev/null
+++ b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/CeedGLDemo.mac.xcscheme
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/xcschememanagement.plist b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/xcschememanagement.plist
new file mode 100644
index 0000000..01f5da4
--- /dev/null
+++ b/CeedGL.xcodeproj/xcuserdata/Club15CC.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,62 @@
+
+
+
+
+ SchemeUserState
+
+ CeedGL Mac Framework.xcscheme
+
+ orderHint
+ 0
+
+ CeedGL.ios.xcscheme
+
+ orderHint
+ 2
+
+ CeedGL.mac.xcscheme
+
+ orderHint
+ 1
+
+ CeedGLDemo.ios.xcscheme
+
+ orderHint
+ 4
+
+ CeedGLDemo.mac.xcscheme
+
+ orderHint
+ 3
+
+
+ SuppressBuildableAutocreation
+
+ 050DB7DC148909E300812267
+
+ primary
+
+
+ 050DB80614890EE300812267
+
+ primary
+
+
+ 050DB82D1489145800812267
+
+ primary
+
+
+ 052BD756127ECB10005A3AE9
+
+ primary
+
+
+ 05BE5870128553040054FD91
+
+ primary
+
+
+
+
+
diff --git a/Sources/CeedGL.h b/Sources/CeedGL.h
index 84e67f2..fae2c67 100644
--- a/Sources/CeedGL.h
+++ b/Sources/CeedGL.h
@@ -1,12 +1,12 @@
-#import
-#import
-#import
-#import
-#import
-#import
-#import
-#import
-#import
-#import
-#import
\ No newline at end of file
+#import "GLPlatform.h"
+#import "GLDebug.h"
+#import "GLValue.h"
+#import "GLBuffer.h"
+#import "GLBufferDataSource.h"
+#import "GLTexture.h"
+#import "GLFramebuffer.h"
+#import "GLRenderbuffer.h"
+#import "GLShader.h"
+#import "GLProgram.h"
+#import "GLDrawCommand.h"
\ No newline at end of file
diff --git a/Sources/GLBuffer.h b/Sources/GLBuffer.h
index d417b43..314b86b 100644
--- a/Sources/GLBuffer.h
+++ b/Sources/GLBuffer.h
@@ -7,8 +7,8 @@
//
#import
-#import
-#import
+#import "GLObject.h"
+#import "GLBufferDataSource.h"
@interface GLBuffer : GLObject {
GLenum mUsage;
diff --git a/Sources/GLBuffer.m b/Sources/GLBuffer.m
index e15a72e..526868d 100644
--- a/Sources/GLBuffer.m
+++ b/Sources/GLBuffer.m
@@ -7,6 +7,7 @@
//
#import "GLBuffer.h"
+#import "GLDebug.h"
@implementation GLBuffer
diff --git a/Sources/GLDrawCommand.h b/Sources/GLDrawCommand.h
index 8d48b48..3e05b32 100644
--- a/Sources/GLDrawCommand.h
+++ b/Sources/GLDrawCommand.h
@@ -7,7 +7,7 @@
//
#import
-#import
+#import "GLPlatform.h"
@class GLBuffer, GLProgram, GLTexture, GLValue;
@@ -21,6 +21,8 @@
NSMutableDictionary *mTextures;
NSMutableDictionary *mUniforms;
NSMutableDictionary *mAttributes;
+ NSMutableDictionary *mUniformsDirtyState;
+ NSMutableDictionary *mAttributesDirtyState;
}
@property (readwrite, nonatomic) GLint firstElement, elementCount;
diff --git a/Sources/GLDrawCommand.m b/Sources/GLDrawCommand.m
index 22bb882..b436719 100644
--- a/Sources/GLDrawCommand.m
+++ b/Sources/GLDrawCommand.m
@@ -11,6 +11,7 @@
#import "GLValue.h"
#import "GLBuffer.h"
#import "GLTexture.h"
+#import "GLDebug.h"
@implementation GLDrawCommand
@@ -29,6 +30,8 @@ - (id)init {
mTextures = [NSMutableDictionary new];
mAttributes = [NSMutableDictionary new];
mUniforms = [NSMutableDictionary new];
+ mUniformsDirtyState = [NSMutableDictionary new];
+ mAttributesDirtyState = [NSMutableDictionary new];
}
return self;
@@ -75,6 +78,9 @@ - (void)removeTextureForUnit:(GLenum)unit
- (void)setUniform:(GLValue*)value forName:(NSString*)name
{
[mUniforms setObject:value forKey:name];
+
+ // Indicate that the uniform needs updating in the program
+ [mUniformsDirtyState setObject:@YES forKey:name];
}
- (GLValue*)uniformForName:(NSString*)name
{
@@ -83,6 +89,7 @@ - (GLValue*)uniformForName:(NSString*)name
- (void)removeUniformForName:(NSString*)name
{
[mUniforms removeObjectForKey:name];
+ [mUniformsDirtyState removeObjectForKey:name];
}
#pragma mark Attributes
@@ -91,6 +98,9 @@ - (void)setAttribute:(GLValue*)value forName:(NSString*)name
id binder = [NSDictionary dictionaryWithObjectsAndKeys:value, @"value", @"GLValue",@"kind", nil];
[mAttributes setObject:binder forKey:name];
+
+ // Indicate that the attribute needs updating in the program
+ [mAttributesDirtyState setObject:@YES forKey:name];
}
- (void)setAttributeBuffer:(GLBuffer*)buffer size:(GLint)size type:(GLenum)type normalized:(GLboolean)norm stride:(GLsizei)stride offset:(GLsizeiptr)off forName:(NSString*)name
{
@@ -104,6 +114,7 @@ - (void)setAttributeBuffer:(GLBuffer*)buffer size:(GLint)size type:(GLenum)type
nil];
[mAttributes setObject:binder forKey:name];
+ [mAttributesDirtyState setObject:@YES forKey:name];
}
- (id)attributeForName:(NSString*)name
{
@@ -115,6 +126,7 @@ - (id)attributeForName:(NSString*)name
- (void)removeAttributeForName:(NSString*)name
{
[mAttributes removeObjectForKey:name];
+ [mAttributesDirtyState removeObjectForKey:name];
}
@@ -131,6 +143,11 @@ - (void)draw
[mUniforms enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
*stop = NO;
+ // If not dirty then skip
+ if (![[mUniformsDirtyState objectForKey:key] boolValue]) {
+ return;
+ }
+
if([prog hasUniformNamed:key])
{
//GLLog(@"Setting value %@ to uniform %@", obj, key);
@@ -139,7 +156,8 @@ - (void)draw
else {
GLLogWarning(@"Trying to set non existent uniform (%@), ignoring...", key);
}
-
+
+ [mUniformsDirtyState setObject:@NO forKey:key];
}];
@@ -147,6 +165,12 @@ - (void)draw
[mAttributes enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
*stop = NO;
+
+ // If not dirty then skip
+ if (![[mAttributesDirtyState objectForKey:key] boolValue]) {
+ return;
+ }
+
if([prog hasAttributeNamed:key])
{
GLint loc = [prog attributeLocationForName:key];
@@ -176,6 +200,9 @@ - (void)draw
else {
//GLLog(@"Trying to set non existent attribute (%@), ignoring...", key);
}
+
+ // Indicate that it's clean/updated
+ [mAttributesDirtyState setObject:@NO forKey:key];
}];
[mTextures enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
diff --git a/Sources/GLFramebuffer.h b/Sources/GLFramebuffer.h
index e2ae2f0..6d7e96b 100644
--- a/Sources/GLFramebuffer.h
+++ b/Sources/GLFramebuffer.h
@@ -7,7 +7,7 @@
//
#import
-#import
+#import "GLObject.h"
@class GLTexture, GLRenderbuffer;
diff --git a/Sources/GLFramebuffer.m b/Sources/GLFramebuffer.m
index 4605d0e..e2f8719 100644
--- a/Sources/GLFramebuffer.m
+++ b/Sources/GLFramebuffer.m
@@ -9,6 +9,7 @@
#import "GLFramebuffer.h"
#import "GLRenderbuffer.h"
#import "GLTexture.h"
+#import "GLDebug.h"
@implementation GLFramebuffer
diff --git a/Sources/GLObject.h b/Sources/GLObject.h
index 9dd86ab..605f979 100644
--- a/Sources/GLObject.h
+++ b/Sources/GLObject.h
@@ -7,7 +7,7 @@
//
#import
-#import
+#import "GLPlatform.h"
// Handle based OpenGL object
diff --git a/Sources/GLObject.m b/Sources/GLObject.m
index 6047263..ea75248 100644
--- a/Sources/GLObject.m
+++ b/Sources/GLObject.m
@@ -7,7 +7,7 @@
//
#import "GLObject.h"
-
+#import "GLDebug.h"
@implementation GLObject
@synthesize handle = mHandle;
diff --git a/Sources/GLProgram.h b/Sources/GLProgram.h
index 31145c4..e0cb180 100644
--- a/Sources/GLProgram.h
+++ b/Sources/GLProgram.h
@@ -7,7 +7,7 @@
//
#import
-#import
+#import "GLObject.h"
@class GLShader;
diff --git a/Sources/GLProgram.m b/Sources/GLProgram.m
index 966cbe9..d18e586 100644
--- a/Sources/GLProgram.m
+++ b/Sources/GLProgram.m
@@ -8,6 +8,7 @@
#import "GLProgram.h"
#import "GLShader.h"
+#import "GLDebug.h"
@implementation GLProgram
diff --git a/Sources/GLRenderbuffer.h b/Sources/GLRenderbuffer.h
index daafde6..918d32b 100644
--- a/Sources/GLRenderbuffer.h
+++ b/Sources/GLRenderbuffer.h
@@ -7,7 +7,8 @@
//
#import
-#import
+#import "GLObject.h"
+#import
@interface GLRenderbuffer : GLObject {
diff --git a/Sources/GLRenderbuffer.m b/Sources/GLRenderbuffer.m
index e47730d..06b1f68 100644
--- a/Sources/GLRenderbuffer.m
+++ b/Sources/GLRenderbuffer.m
@@ -7,6 +7,7 @@
//
#import "GLRenderbuffer.h"
+#import "GLDebug.h"
@implementation GLRenderbuffer
diff --git a/Sources/GLShader.h b/Sources/GLShader.h
index 7793ce9..9bbaea6 100644
--- a/Sources/GLShader.h
+++ b/Sources/GLShader.h
@@ -7,7 +7,7 @@
//
#import
-#import
+#import "GLObject.h"
#define GL_STRINGIFY(A) [NSString stringWithCString:#A encoding:NSUTF8StringEncoding]
diff --git a/Sources/GLShader.m b/Sources/GLShader.m
index 0d37927..d029294 100644
--- a/Sources/GLShader.m
+++ b/Sources/GLShader.m
@@ -7,6 +7,7 @@
//
#import "GLShader.h"
+#import "GLDebug.h"
@implementation GLShader
diff --git a/Sources/GLTexture.h b/Sources/GLTexture.h
index 1302e4f..23dc1b7 100644
--- a/Sources/GLTexture.h
+++ b/Sources/GLTexture.h
@@ -7,7 +7,8 @@
//
#import
-#import
+#import "GLObject.h"
+#import
@interface GLTexture : GLObject {
GLsizei mWidth, mHeight;
diff --git a/Sources/GLTexture.m b/Sources/GLTexture.m
index 7c34ca3..2cdd626 100644
--- a/Sources/GLTexture.m
+++ b/Sources/GLTexture.m
@@ -7,7 +7,7 @@
//
#import "GLTexture.h"
-
+#import "GLDebug.h"
@implementation GLTexture
diff --git a/Sources/GLValue.h b/Sources/GLValue.h
index d916de6..e673701 100644
--- a/Sources/GLValue.h
+++ b/Sources/GLValue.h
@@ -7,7 +7,7 @@
//
#import
-#import
+#import "GLPlatform.h"
@interface GLValue : NSObject {
GLsizei mSize; // 1, 2, 3, or 4;
diff --git a/Sources/GLValue.m b/Sources/GLValue.m
index e3ebe18..2daa426 100644
--- a/Sources/GLValue.m
+++ b/Sources/GLValue.m
@@ -7,6 +7,7 @@
//
#import "GLValue.h"
+#import "GLDebug.h"
#define mINT_ARRAY ((GLint*)mValues)