Skip to content

Commit

Permalink
In the process of deleting all the demo code and demo data so that this
Browse files Browse the repository at this point in the history
library is leaner. Made it so that you specify the actual Renderer from
the AppDelegate (rather than in the IOSGLView or NSGLView, which now can
be left alone!). Added some convenience methods for loading fonts/font
atlases, made it easer to load programs, textures, etc.
  • Loading branch information
Angus Forbes committed Apr 17, 2012
1 parent 45e4a26 commit 0d404ce
Show file tree
Hide file tree
Showing 181 changed files with 106,359 additions and 8,921 deletions.
Binary file modified Classes/.DS_Store
Binary file not shown.
14 changes: 14 additions & 0 deletions Classes/Geometry/ModelView.cpp
Expand Up @@ -14,10 +14,24 @@ vec3 ModelView::GetTranslate() {
void ModelView::Translate(float x, float y, float z) {
Translate(vec3(x,y,z));
}
void ModelView::TranslateX(float x) {
Translate(vec3(x,0.0,0.0));
}
void ModelView::TranslateY(float y) {
Translate(vec3(0.0,y,0.0));
}
void ModelView::TranslateZ(float z) {
Translate(vec3(0.0,0.0,z));
}

void ModelView::Translate(vec3 _t) {
SetTranslate(vec3(translate.x + _t.x, translate.y + _t.y, translate.z + _t.z));
}

void ModelView::SetTranslate(float _x, float _y, float _z) {
SetTranslate(vec3(_x, _y, _z));
}

void ModelView::SetTranslate(vec3 _t) {
//ModelView* ModelView::SetTranslate(vec3 _t) {
translate = _t;
Expand Down
6 changes: 5 additions & 1 deletion Classes/Geometry/ModelView.hpp
Expand Up @@ -22,11 +22,15 @@ class ModelView {
void SetModelView(mat4 mv);

vec3 GetTranslate();
void SetTranslate(float _x, float _y, float _z);
void SetTranslate(vec3 _t);
//ModelView* SetTranslate(vec3 _t);
void Translate(vec3 _t);
void Translate(float x, float y, float z);

void TranslateX(float x);
void TranslateY(float y);
void TranslateZ(float z);

vec3 GetRotate();
void SetRotate(float x, float y, float z);
void SetRotate(vec3 _r);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Geometry/Rectangle.cpp
Expand Up @@ -108,7 +108,7 @@ void Rectangle::Transform() {
mat4 mv = Renderer::GetRenderer()->GetCamera()->GetModelView();

//printf("isTransformed!\n");
mv.Print();
//mv.Print();

//translate
mv = mat4::Translate(mv, GetTranslate());
Expand Down
4 changes: 2 additions & 2 deletions Classes/Geometry/Rectangle3D.cpp
Expand Up @@ -60,8 +60,8 @@ void Rectangle3D::GenerateVertices() {
int tc_idx = 0;

float depthTC = 0.0;
float min = 0.0;
float max = 0.0;
// float min = 0.0;
// float max = 0.0;


// rectVertices[v_idx++] = 0.0; rectVertices[v_idx++] = 0.0; rectVertices[v_idx++] = 0.0;
Expand Down
45 changes: 45 additions & 0 deletions Classes/Utils/FontAtlas.hpp
@@ -0,0 +1,45 @@

#include <map>
#include "FontData.h"
#include "Texture.hpp"
#include "Vector.hpp"
//#include "Program.hpp"

#ifndef OpenGLRenderLibraryNS_FontAtlas_hpp
#define OpenGLRenderLibraryNS_FontAtlas_hpp

using namespace std;

class FontAtlas {

public:


FontAtlas(Texture* _fontTexture, int _tw, int _th,
const string& _fontName, bool _isBold, bool _isItalic,
int _lineHeight, int _base,
map<char, FontData*>& _values );

string fontName;
Texture* fontTexture;
bool isBold;
bool isItalic;
int tw;
int th;
int lineHeight;
int base;
map<char, FontData*> values;

map<char, FontData*>& GetValues();

// void Text(float pen_x, float pen_y, string text, vec4 color, bool usePixel);
// void Text(float pen_x, float pen_y, string text, vec4 color);

void Bind();
void Unbind();



};

#endif
47 changes: 47 additions & 0 deletions Classes/Utils/FontAtlas.mm
@@ -0,0 +1,47 @@

#include "FontAtlas.hpp"
#include "Renderer.hpp"

FontAtlas::FontAtlas(Texture* _fontTexture, int _tw, int _th,
const string &_fontName, bool _isBold, bool _isItalic,
int _lineHeight, int _base,
map<char, FontData*>& _values ) {


fontTexture = _fontTexture;
tw = _tw;
th = _th;
fontName = _fontName;
isBold = _isBold;
isItalic = _isItalic;
lineHeight = _lineHeight;
base = _base;
values = _values;

//should include kerning in here as well... haven't gotten around to it...

}

map<char, FontData*>& FontAtlas::GetValues() {

return values;
}

void FontAtlas::Bind() {
Renderer::GetRenderer()->CurrentFont = this;
}

void FontAtlas::Unbind() {
Renderer::GetRenderer()->CurrentFont = NULL;
}

/*
void FontAtlas::Text( float penx, float peny, string text, vec4 color, bool usePixel ) {
Renderer::GetRenderer()->Text(this, penx, peny, text, color, usePixel);
}
void FontAtlas::Text( float penx, float peny, string text, vec4 color ) {
Renderer::GetRenderer()->Text(this, penx, peny, text, color, false);
}
*/

24 changes: 24 additions & 0 deletions Classes/Utils/FontData.h
@@ -0,0 +1,24 @@


#ifndef OpenGLRenderLibraryNS_FontData_h
#define OpenGLRenderLibraryNS_FontData_h


class FontData {

public:

FontData();
FontData(char _val, int _x, int _y, int _w, int _h, int _xoff, int _yoff, int _xadvance);

char val;
int x;
int y;
int w;
int h;
int xoff;
int yoff;
int xadvance;
};

#endif
15 changes: 15 additions & 0 deletions Classes/Utils/FontData.mm
@@ -0,0 +1,15 @@
#include "FontData.h"

FontData::FontData(char _val, int _x, int _y, int _w, int _h, int _xoff, int _yoff, int _xadvance) {
val = _val;
x = _x;
y = _y;
w =_w;
h = _h;
xoff = _xoff;
yoff = _yoff;
xadvance = _xadvance;

}


100 changes: 100 additions & 0 deletions Classes/Utils/Noise.mm
Expand Up @@ -2,6 +2,106 @@
#include "Noise.hpp"
#include "Utils.hpp"


/*
GLubyte* Noise::CreateLookUpTableForBitReduction32() {
// //makes a 64 by 64 grid
// r1g1b1a1, r1g1b1a2, r1g1b1a4, r1g1b1a8, r1g1b1a16, r1g1b1a32, r1g1b1a64, r1g1b1a128, r1g1b2a1, r1g1b2a2 ... r1g1b128a128
// r1g2b1a1, r1g2b1a2, r1g2b1a4, r1g2b1a8, r1g2b1a16, r1g2b1a32, r1g2b1a64, r1g2b1a128, r1g2b2a1, r1g2b2a2 ... r1g2b128a128
// .
// .
// .
// r2g1b1a1, r2g1b1a2, r2g1b1a4, r2g1b1a8, r2g1b1a16, r2g1b1a32, r2g1b1a64, r2g1b1a128, r2g1b2a1, r2g1b2a2 ... r2g1b128a128
// .
// .
// .
// r128g128b1a1, r128g128b1a2, r128g128b1a4, r128g128b1a8, r128g128b1a16, r128g128b1a32, r128g128b1a64, r128g128b1a128, r128g128b2a1, r128g128b2a2 ... r128g128b128a128
GLubyte* data = (GLubyte*) malloc (64*64*4*sizeof(GLubyte));
int rVal;
int gVal;
int bVal;
int aVal;
int idx = 0;
for (int i = 0; i < 8; i++) {
rVal = (int)pow(2.0, i);
for (int j = 0; j < 8; j++) {
gVal = (int)pow(2.0, j);
for (int k = 0; k < 8; k++) {
bVal = (int)pow(2.0, k);
for (int l = 0; l < 8; l++) {
aVal = (int)pow(2.0, l);
data[idx] = rVal;
data[idx+1] = gVal;
data[idx+2] = bVal;
data[idx+3] = aVal;
idx+=4;
}
}
}
}
return data;
}
*/
/*
GLubyte* Noise::CreateLookUpTableForBitReduction16() {
// //makes an 8 by 8 grid
// r1g1, r1g2, r1g4 ... r1g8
// r2g1, r2g2, r2g4 ... r2g8
// .
// .
// .
// r8g1, r8g2, r8g4 ... r8g8
GLubyte* data = (GLubyte*) malloc (8*8*4*sizeof(GLubyte));
int rVal;
int gVal;
int idx = 0;
for (int i = 0; i < 8; i++) {
rVal = (int)pow(2.0, i);
for (int j = 0; j < 8; j++) {
gVal = (int)pow(2.0, j);
data[idx] = rVal;
data[idx+1] = gVal;
data[idx+2] = 0;
data[idx+3] = 0;
idx+=4;
}
}
return data;
}
*/

GLubyte* Noise::CreateColorNoise(int _w, int _h) {

GLubyte* data = (GLubyte*) malloc (_w*_h*4*sizeof(GLubyte));
Expand Down
3 changes: 1 addition & 2 deletions Classes/Utils/Program.hpp
@@ -1,11 +1,10 @@
#include <iostream>
//#include <iostream>
#include <map>
#include "ResourceHandler.h"

#ifndef PROGRAM
#define PROGRAM


using namespace std;

class Program {
Expand Down
7 changes: 4 additions & 3 deletions Classes/Utils/Texture.mm
Expand Up @@ -6,8 +6,8 @@
printf("in Texture::Texture(int _w, int _h, GLenum _format, GLenum _type)\n");
width = _w;
height = _h;
format = _format;
type = _type;
format = _format; //GL_RGBA, GL_LUMINANCE, etc
type = _type; //GL_UNSIGNED_BYTE, GL_FLOAT, etc
kind = GL_TEXTURE_2D;

wrapMode = GL_CLAMP_TO_EDGE;
Expand Down Expand Up @@ -301,7 +301,8 @@
glTexParameteri(kind, GL_TEXTURE_WRAP_S, wrapMode);
glTexParameteri(kind, GL_TEXTURE_WRAP_T, wrapMode);

glTexImage2D(kind, 0, GL_RGBA, width, height, 0, format, type, data);
//glTexImage2D(kind, 0, GL_RGBA, width, height, 0, format, type, data);
glTexImage2D(kind, 0, format, width, height, 0, format, type, data);

printf("creating a texture at texID %d\n", texID);

Expand Down
3 changes: 3 additions & 0 deletions IOS/IOS/AppDelegate.h → IOS/AppDelegate.h
@@ -1,6 +1,7 @@


#import <UIKit/UIKit.h>
//#include "Renderer.hpp"

#include "ViewController.h"

Expand All @@ -14,4 +15,6 @@
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;

- (void*) GetRenderer;

@end
5 changes: 5 additions & 0 deletions IOS/IOS/AppDelegate.mm → IOS/AppDelegate.mm
@@ -1,11 +1,16 @@

#import "AppDelegate.h"
#include "RendererDunites.hpp"

@implementation AppDelegate

@synthesize window;
@synthesize viewController;

- (void*) GetRenderer {
return new RendererDunites();
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UIApplication sharedApplication] setStatusBarHidden:YES];

Expand Down
3 changes: 2 additions & 1 deletion IOS/IOS/AudioManager.mm
Expand Up @@ -250,7 +250,8 @@ void audioRouteChangeListenerCallback(void * inClientData,AudioSessionPropertyID
startedCallback = NO;
[manager closeDownAudioDevice];

OSStatus err= [manager setUpAudioDevice]; //restart audio session
[manager setUpAudioDevice]; //restart audio session
//OSStatus err= [manager setUpAudioDevice]; //restart audio session

// if(err!=noErr) {
//
Expand Down
1 change: 0 additions & 1 deletion IOS/IOS/IOSGLView.h
Expand Up @@ -5,7 +5,6 @@

#import "Renderer.hpp"


#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>

Expand Down

0 comments on commit 0d404ce

Please sign in to comment.