Permalink
Browse files

Updated GLView to version 1.1.1

  • Loading branch information...
1 parent eebb3ab commit ae56a27745b61e47776221f53888e00e2fe35e49 Nick Lockwood committed Nov 4, 2011

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,5 +1,6 @@
//
// GLImage.h
+// Version 1.1.1
//
// Created by Nick Lockwood on 10/07/2011.
// Copyright 2011 Charcoal Design. All rights reserved.
@@ -21,8 +22,10 @@
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
+//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
+//
// 3. This notice may not be removed or altered from any source distribution.
//
View
@@ -1,5 +1,6 @@
//
// GLImage.m
+// Version 1.1.1
//
// Created by Nick Lockwood on 10/07/2011.
// Copyright 2011 Charcoal Design. All rights reserved.
@@ -21,8 +22,10 @@
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
+//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
+//
// 3. This notice may not be removed or altered from any source distribution.
//
@@ -40,16 +43,16 @@
GLuint headerSize;
GLuint height;
GLuint width;
- GLuint numMipmaps;
- GLuint pfFlags;
+ GLuint mipmapCount;
+ GLuint pixelFormatFlags;
GLuint textureDataSize;
GLuint bitCount;
- GLuint rBitMask;
- GLuint gBitMask;
- GLuint bBitMask;
+ GLuint redBitMask;
+ GLuint greenBitMask;
+ GLuint blueBitMask;
GLuint alphaBitMask;
- GLuint pvr;
- GLuint numSurfs;
+ GLuint magicNumber;
+ GLuint surfaceCount;
}
PVRTextureHeader;
@@ -205,7 +208,7 @@ - (GLImage *)initWithContentsOfFile:(NSString *)path
{
if ((self = [super init]))
{
- //get scale factor
+ //get scale factor
NSString *scaleSuffix = [[self class] scaleSuffixForImagePath:path];
scale = scaleSuffix? [[scaleSuffix substringWithRange:NSMakeRange(1, 1)] floatValue]: 1.0;
@@ -215,6 +218,14 @@ - (GLImage *)initWithContentsOfFile:(NSString *)path
//parse header
PVRTextureHeader *header = (PVRTextureHeader *)[data bytes];
+ //check magic number
+ if (CFSwapInt32HostToBig(header->magicNumber) != 'PVR!')
+ {
+ NSLog(@"PVR image data was not in a recognised format, or is missing header information");
+ [self release];
+ return nil;
+ }
+
//dimensions
GLint width = header->width;
GLint height = header->height;
@@ -227,7 +238,7 @@ - (GLImage *)initWithContentsOfFile:(NSString *)path
GLuint format;
premultipliedAlpha = NO;
BOOL hasAlpha = header->alphaBitMask;
- switch (header->pfFlags & 0xff)
+ switch (header->pixelFormatFlags & 0xff)
{
case OGL_RGB_565:
{
@@ -291,7 +302,7 @@ - (GLImage *)initWithContentsOfFile:(NSString *)path
}
default:
{
- NSLog(@"Unrecognised PVR image format: %i", header->pfFlags & 0xff);
+ NSLog(@"Unrecognised PVR image format: %i", header->pixelFormatFlags & 0xff);
[self release];
return nil;
}
View
@@ -1,5 +1,6 @@
//
// GLImageView.h
+// Version 1.1.1
//
// Created by Nick Lockwood on 10/07/2011.
// Copyright 2011 Charcoal Design. All rights reserved.
@@ -21,8 +22,10 @@
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
+//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
+//
// 3. This notice may not be removed or altered from any source distribution.
//
View
@@ -1,5 +1,6 @@
//
// GLImageView.m
+// Version 1.1.1
//
// Created by Nick Lockwood on 10/07/2011.
// Copyright 2011 Charcoal Design. All rights reserved.
@@ -21,8 +22,10 @@
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
+//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
+//
// 3. This notice may not be removed or altered from any source distribution.
//
View
@@ -1,5 +1,6 @@
//
// GLView.h
+// Version 1.1.1
//
// Created by Nick Lockwood on 10/07/2011.
// Copyright 2011 Charcoal Design. All rights reserved.
@@ -21,8 +22,10 @@
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
+//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
+//
// 3. This notice may not be removed or altered from any source distribution.
//
View
@@ -1,5 +1,6 @@
//
// GLView.m
+// Version 1.1.1
//
// Created by Nick Lockwood on 10/07/2011.
// Copyright 2011 Charcoal Design. All rights reserved.
@@ -21,8 +22,10 @@
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
+//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
+//
// 3. This notice may not be removed or altered from any source distribution.
//
@@ -11,7 +11,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
- <string>com.charcoaldesign.${PRODUCT_NAME:rfc1034identifier}</string>
+ <string>com.akqa.charcoaldesign.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
@@ -1,17 +0,0 @@
-//
-// GLViewViewController.h
-//
-// Created by Nick Lockwood on 09/07/2011.
-// Copyright 2011 Charcoal Design. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-#import "GLImageView.h"
-
-
-@interface GLViewExampleController : UIViewController
-
-@property (readonly, nonatomic) IBOutlet GLImageView *imageView1;
-@property (readonly, nonatomic) IBOutlet GLImageView *imageView2;
-
-@end
@@ -1,37 +0,0 @@
-//
-// GLViewViewController.m
-//
-// Created by Nick Lockwood on 09/07/2011.
-// Copyright 2011 Charcoal Design. All rights reserved.
-//
-
-#import "GLViewExampleController.h"
-
-
-@implementation GLViewExampleController
-
-@synthesize imageView1;
-@synthesize imageView2;
-
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
-
- imageView1.image = [GLImage imageNamed:@"logo.pvr"];
- imageView2.image = [GLImage imageNamed:@"logo.png"];
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
-{
- return YES;
-}
-
-- (void)dealloc
-{
- [imageView1 release];
- [imageView2 release];
- [super dealloc];
-}
-
-@end
@@ -0,0 +1,21 @@
+//
+// GLViewViewController.h
+//
+// Created by Nick Lockwood on 09/07/2011.
+// Copyright 2011 Charcoal Design. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "GLImageView.h"
+
+
+@interface GLViewImageExampleController : UIViewController
+
+@property (nonatomic, retain) IBOutlet GLImageView *imageView1;
+@property (nonatomic, retain) IBOutlet GLImageView *imageView2;
+@property (nonatomic, retain) IBOutlet GLImageView *imageView3;
+@property (nonatomic, retain) IBOutlet GLImageView *imageView4;
+@property (nonatomic, retain) IBOutlet GLImageView *imageView5;
+@property (nonatomic, retain) IBOutlet GLImageView *imageView6;
+
+@end
@@ -0,0 +1,55 @@
+//
+// GLViewViewController.m
+//
+// Created by Nick Lockwood on 09/07/2011.
+// Copyright 2011 Charcoal Design. All rights reserved.
+//
+
+#import "GLViewImageExampleController.h"
+
+
+@implementation GLViewImageExampleController
+
+@synthesize imageView1;
+@synthesize imageView2;
+@synthesize imageView3;
+@synthesize imageView4;
+@synthesize imageView5;
+@synthesize imageView6;
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ imageView1.image = [GLImage imageNamed:@"logo.png"];
+ imageView2.image = [GLImage imageNamed:@"logo-opaque.png"];
+ imageView3.image = [GLImage imageNamed:@"logo-RGBA4444.pvr"];
+ imageView4.image = [GLImage imageNamed:@"logo-RGB565.pvr"];
+ imageView5.image = [GLImage imageNamed:@"logo-RGBA4.pvr"];
+ imageView6.image = [GLImage imageNamed:@"logo-RGB4.pvr"];
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+
+ self.imageView1 = nil;
+ self.imageView2 = nil;
+ self.imageView3 = nil;
+ self.imageView4 = nil;
+ self.imageView5 = nil;
+ self.imageView6 = nil;
+}
+
+- (void)dealloc
+{
+ [imageView1 release];
+ [imageView2 release];
+ [imageView3 release];
+ [imageView4 release];
+ [imageView5 release];
+ [imageView6 release];
+ [super dealloc];
+}
+
+@end
@@ -0,0 +1,23 @@
+//
+// GLViewLoadingExampleController.h
+// GLView
+//
+// Created by Nick Lockwood on 21/07/2011.
+// Copyright 2011 Charcoal Design. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface GLViewLoadingExampleController : UIViewController
+
+@property (nonatomic, retain) IBOutlet UILabel *ttlLabel;
+@property (nonatomic, retain) IBOutlet UILabel *label1;
+@property (nonatomic, retain) IBOutlet UILabel *label2;
+@property (nonatomic, retain) IBOutlet UILabel *label3;
+@property (nonatomic, retain) IBOutlet UILabel *label4;
+@property (nonatomic, retain) IBOutlet UILabel *label5;
+
+- (IBAction)refresh;
+
+@end
Oops, something went wrong.

0 comments on commit ae56a27

Please sign in to comment.