Skip to content

Commit

Permalink
Updated GLView to version 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Lockwood committed Nov 4, 2011
1 parent eebb3ab commit ae56a27
Show file tree
Hide file tree
Showing 32 changed files with 1,779 additions and 117 deletions.
129 changes: 93 additions & 36 deletions GLView.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions GLView/GLImage.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
//

Expand Down
31 changes: 21 additions & 10 deletions GLView/GLImage.m
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
//

Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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:
{
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions GLView/GLImageView.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
//

Expand Down
3 changes: 3 additions & 0 deletions GLView/GLImageView.m
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
//

Expand Down
3 changes: 3 additions & 0 deletions GLView/GLView.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
//

Expand Down
3 changes: 3 additions & 0 deletions GLView/GLView.m
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
//

Expand Down
2 changes: 1 addition & 1 deletion GLViewExample/GLView-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
17 changes: 0 additions & 17 deletions GLViewExample/GLViewExampleController.h

This file was deleted.

37 changes: 0 additions & 37 deletions GLViewExample/GLViewExampleController.m

This file was deleted.

21 changes: 21 additions & 0 deletions GLViewExample/GLViewImageExampleController.h
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions GLViewExample/GLViewImageExampleController.m
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions GLViewExample/GLViewLoadingExampleController.h
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit ae56a27

Please sign in to comment.