Permalink
Browse files

added size accessors for textures and render buffers

  • Loading branch information...
1 parent 2716df0 commit 4182f9859fd23f835306f633cec8120b04e01f9a @rsebbe rsebbe committed Oct 16, 2012
Showing with 26 additions and 1 deletion.
  1. +1 −0 Sources/GLRenderbuffer.h
  2. +8 −0 Sources/GLRenderbuffer.m
  3. +6 −1 Sources/GLTexture.h
  4. +11 −0 Sources/GLTexture.m
View
1 Sources/GLRenderbuffer.h
@@ -17,6 +17,7 @@
@property (readonly, nonatomic) GLenum internalFormat;
@property (readonly, nonatomic) GLsizei width, height;
+@property (readonly, nonatomic) CGSize size; // same as width/height
- (void)setFromExistingHandle:(GLuint)handle width:(GLsizei)w height:(GLsizei)h internalFormat:(GLenum)iformat;
- (void)allocateStorageWithWidth:(GLsizei)w height:(GLsizei)h internalFormat:(GLenum)internalFormat ;
View
8 Sources/GLRenderbuffer.m
@@ -67,4 +67,12 @@ - (void)allocateStorageWithWidth:(GLsizei)w height:(GLsizei)h internalFormat:(GL
mHeight = h;
mInternalFormat = internalFormat;
}
+
+#pragma mark -
+#pragma mark Accessors
+- (CGSize)size
+{
+ return CGSizeMake(mWidth, mHeight);
+}
+
@end
View
7 Sources/GLTexture.h
@@ -11,12 +11,13 @@
@interface GLTexture : GLObject {
GLsizei mWidth, mHeight;
- GLenum mInternalFormat; // ex. GL_RGBA
+ GLenum mInternalFormat; // ex. GL_RGBA
//GLenum mType; // ex. GL_UNSIGNED_BYTE
GLint mBorder;
}
@property (readonly, nonatomic) GLsizei width, height;
+@property (readonly, nonatomic) CGSize size; // same as width/height
@property (readonly, nonatomic) GLenum internalFormat;//, type;
@property (readonly, nonatomic) GLint border;
@@ -27,6 +28,10 @@
// Texture definition
- (void)setFromExistingHandle:(GLuint)handle width:(GLsizei)w height:(GLsizei)h internalFormat:(GLenum)iformat border:(GLint)border;
+// Create on GPU with no contents
+- (void)allocateStorageWithWidth:(GLsizei)w height:(GLsizei)h format:(GLenum)format type:(GLenum)type internalFormat:(GLenum)iformat target:(GLenum)target;
+
+// Create on GPU and load contents
- (void)loadImage:(const GLvoid *)pixels width:(GLsizei)w height:(GLsizei)h format:(GLenum)format type:(GLenum)type internalFormat:(GLenum)iformat target:(GLenum)target;
- (void)loadImage:(const GLvoid*)pixels level:(GLint)level width:(GLsizei)w height:(GLsizei)h format:(GLenum)format type:(GLenum)type border:(GLint)border internalFormat:(GLenum)iformat target:(GLenum)target magFilter:(GLenum)magfil minFilter:(GLenum)minfil wrapS:(GLenum)wraps wrapT:(GLenum)wrapt;
View
11 Sources/GLTexture.m
@@ -63,6 +63,11 @@ - (void)setFromExistingHandle:(GLuint)handle width:(GLsizei)w height:(GLsizei)h
mBorder = border;
}
}
+
+- (void)allocateStorageWithWidth:(GLsizei)w height:(GLsizei)h format:(GLenum)format type:(GLenum)type internalFormat:(GLenum)iformat target:(GLenum)target
+{
+ [self loadImage:NULL width:w height:h format:format type:type internalFormat:iformat target:target];
+}
- (void)loadImage:(const GLvoid *)pixels width:(GLsizei)w height:(GLsizei)h format:(GLenum)format type:(GLenum)type internalFormat:(GLenum)iformat target:(GLenum)target
{
[self loadImage:pixels level:0 width:w height:h format:format type:type border:0 internalFormat:iformat target:target magFilter:GL_NEAREST minFilter:GL_NEAREST wrapS:GL_CLAMP_TO_EDGE wrapT:GL_CLAMP_TO_EDGE];
@@ -124,4 +129,10 @@ - (void)bind:(GLenum)target
glBindTexture(target, mHandle);
GLCheckError();
}
+#pragma mark -
+#pragma mark Accessors
+- (CGSize)size
+{
+ return CGSizeMake(mWidth, mHeight);
+}
@end

0 comments on commit 4182f98

Please sign in to comment.