Browse Source

Finally it works

master
Joshua Moerman 13 years ago
parent
commit
21a6984188
  1. 329
      GLGameTemplate/App.h
  2. 14
      GLGameTemplate/Shaders/Shader.fsh
  3. 28
      GLGameTemplate/Shaders/Shader.vsh
  4. 52
      GLGameTemplate/Shaders/effectShader.fsh
  5. 11
      GLGameTemplate/Shaders/effectShader.vsh
  6. 8
      GLGameTemplate/Shaders/teaShader.fsh
  7. 19
      GLGameTemplate/Shaders/teaShader.vsh
  8. 13
      GLGameTemplate/Shaders/textureShader.fsh
  9. 9
      GLGameTemplate/Shaders/textureShader.vsh
  10. 0
      GLGameTemplate/SkyRoads-Info.plist
  11. 0
      GLGameTemplate/SkyRoads-Prefix.pch
  12. 54
      GLGameTemplate/ViewController.mm
  13. 121
      GLGameTemplate/statics.h
  14. 107
      SkyRoads.xcodeproj/project.pbxproj

329
GLGameTemplate/App.h

@ -14,148 +14,241 @@
#include <memory>
#include <cmath>
#include "shader.h"
#include "fbo.h"
#include "interpolator.h"
#include "statics.h"
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
#define kWindowWidth 1024
#define kWindowHeight 768
#define kFBOWidth 128
#define kFBOHeight 128
struct App {
std::unique_ptr<J::shader> program;
GLKMatrix4 modelViewProjectionMatrix;
GLKMatrix3 normalMatrix;
float rotation;
constexpr static int preferred_frames_per_second(){ return 60; }
constexpr static bool multisample(){ return false; }
constexpr static bool depth(){ return true; }
constexpr static std::vector<std::string> get_attributes(){
std::vector<std::string> v;
v.push_back("position");
v.push_back("normal");
v.push_back("color");
v.push_back("tex_coord0");
return v;
}
constexpr static std::string getPath(std::string name, std::string kind){
return [[[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:name.c_str()] ofType:[NSString stringWithUTF8String:kind.c_str()]] UTF8String];
}
constexpr static std::array<GLfloat, 16> from_carray(GLfloat const (& v)[16]){
std::array<GLfloat, 16> a;
for(int i = 0; i < 16; ++i) a[i] = v[i];
return a;
}
constexpr static std::array<GLfloat, 16> transpose(std::array<GLfloat, 16> const & v){
std::array<GLfloat, 16> a;
for(int i = 0; i < 4; ++i)
for(int j = 0; j < 4; ++j)
a[i + 4*j] = v[j + 4*i];
return a;
}
typedef std::array<GLfloat, 7> Vertex;
typedef std::array<Vertex, 8> Quad; //degenerate
int counter;
float time;
unsigned int width, height;
float aspect;
GLuint vertexArray;
GLuint vertexBuffer;
App()
: program(nullptr)
, modelViewProjectionMatrix({{0}})
, normalMatrix({{0}})
, rotation(0)
, aspect(0.75)
, vertexArray(0)
, vertexBuffer(0)
unsigned int color_scheme;
J::shader noise_shader;
J::shader texture_shader;
J::shader effect_shader;
J::fbo fbo1;
J::fbo fbo2;
J::interpolator<std::array<GLfloat, 16>> color_transformation;
std::vector<Quad> quads;
App(float w, float h)
: counter(0)
, time(0)
, width(w)
, height(h)
, aspect(w/h)
, color_scheme(0)
, noise_shader(getPath("teaShader", "vsh"), getPath("teaShader", "fsh"), get_attributes())
, texture_shader(getPath("textureShader", "vsh"), getPath("textureShader", "fsh"), get_attributes())
, effect_shader(getPath("effectShader", "vsh"), getPath("effectShader", "fsh"), get_attributes())
, fbo1(kFBOWidth, kFBOHeight)
, fbo2(kFBOWidth, kFBOHeight)
, color_transformation(transpose(from_carray(color_transformations[0])), 1.0)
{
std::cout << "APP CONSTRUCTED" << std::endl;
make_quads();
glEnable(GL_DEPTH_TEST);
// shader
NSString * vshader_file = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"vsh"];
NSString * fshader_file = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"fsh"];
std::vector<std::string> v;
v.emplace_back("position");
v.emplace_back("normal");
program.reset(new J::shader([vshader_file UTF8String], [fshader_file UTF8String], std::move(v)));
// vertex-buffer
glGenVertexArraysOES(1, &vertexArray);
glBindVertexArrayOES(vertexArray);
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(gCubeVertexData), gCubeVertexData, GL_STATIC_DRAW);
glEnableVertexAttribArray(GLKVertexAttribPosition);
glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(0));
glEnableVertexAttribArray(GLKVertexAttribNormal);
glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(12));
glBindVertexArrayOES(0);
}
~App(){
glDeleteBuffers(1, &vertexBuffer);
glDeleteVertexArraysOES(1, &vertexArray);
std::cout << "APP DESTRUCTED" << std::endl;
~App() {
}
void resize(float width, float height){
aspect = std::abs(width/height);
void resize(float w, float h) {
aspect = std::abs(w/h);
}
void update(float dt){
// projection matrix (perspective)
GLKMatrix4 projectionMatrix = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(65.0f), aspect, 0.1f, 100.0f);
// model matrix (rotation)
GLKMatrix4 baseModelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -4.0f);
baseModelViewMatrix = GLKMatrix4Rotate(baseModelViewMatrix, rotation, 0.0f, 1.0f, 0.0f);
GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 1.5f);
modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, rotation, 1.0f, 1.0f, 1.0f);
modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix);
// setting stuff for later use in the shader
normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL);
modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix);
// time update
rotation += dt * 0.5f;
void change_color(){
++color_scheme %= colors;
color_transformation.set_value(transpose(from_carray(color_transformations[color_scheme])));
}
void make_quads(){
quads.reserve(number_of_quads);
for(int yy = 0; yy < level_height; ++yy){
for(int xx = 0; xx < level_width; ++xx){
if(level[xx + level_width*yy] == 0) continue;
const double size = 1.0;
double x = xx - (int)level_width/2;
double z = -5.0 -level_height + yy;
double y = -1.0;
Quad q;
// deg.
q[0][0] = x - size*0.5;
q[0][1] = y;
q[0][2] = z - size*0.5;
q[1][0] = x - size*0.5;
q[1][1] = y;
q[1][2] = z - size*0.5;
// real quad
q[2][0] = x - size*0.5;
q[2][1] = y;
q[2][2] = z - size*0.5;
q[3][0] = x - size*0.5;
q[3][1] = y;
q[3][2] = z + size*0.5;
q[4][0] = x + size*0.5;
q[4][1] = y;
q[4][2] = z - size*0.5;
q[5][0] = x + size*0.5;
q[5][1] = y;
q[5][2] = z + size*0.5;
// deg.
q[6][0] = x + size*0.5;
q[6][1] = y;
q[6][2] = z + size*0.5;
q[7][0] = x + size*0.5;
q[7][1] = y;
q[7][2] = z + size*0.5;
//double r = rand() / (double) RAND_MAX;
//double g = rand() / (double) RAND_MAX;
//double b = rand() / (double) RAND_MAX;
for(auto& v : q){
v[3] = (x + 2.0) / 5.0;
v[4] = 0.5;
v[5] = (yy < level_height && yy > level_height - 7)? 1.0 : 0.0;
v[6] = 1.0;
}
quads.push_back(q);
}
}
}
void update(float dt) {
time += dt;
for(auto& q : quads){
for(auto& v : q){
v[2] += dt * 7.0;
}
if(q[0][2] > 10.0) {
for(auto& v : q){
v[2] -= level_height;
}
}
}
color_transformation.interpolate(dt);
// Update the FBO's here
// (can't be done in draw, because of apple's fbo shizzle)
fbo1.begin();
scene();
fbo1.end();
fbo2.begin();
effects(fbo1);
fbo2.end();
}
void draw(){
// clear
float red = rand() / (float)RAND_MAX;
glClearColor(red, 0.65f, 0.65f, 1.0f);
void draw() {
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// bind and set up
glBindVertexArrayOES(vertexArray);
program->begin();
program->set_uniform("modelViewProjectionMatrix", modelViewProjectionMatrix.m, 0);
program->set_uniform("normalMatrix", normalMatrix.m, 0);
texture_shader.begin();
texture_shader.set_uniform("color_transformation", color_transformation, GL_FALSE);
texture(texture_shader, fbo2);
texture_shader.end();
}
void effects(J::fbo& read_fbo){
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// draw
glDrawArrays(GL_TRIANGLES, 0, 36);
effect_shader.begin();
effect_shader.set_uniform("time", counter * counter * 0.00001f);
texture(effect_shader, read_fbo);
}
constexpr GLfloat gCubeVertexData[216] = {
// Data layout for each line below is:
// positionX, positionY, positionZ, normalX, normalY, normalZ,
0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
void scene(){
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
noise_shader.begin();
-0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
-0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
-0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
-0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
GLKMatrix4 p1 = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(80.0f), aspect, 0.01f, 20.0f);
GLKMatrix4 p2 = GLKMatrix4MakeLookAt(0.0, 0.0, 9.0, 0.0, -2.0, 0.0, 0.0, 1.0, 0.0);
GLKMatrix4 projectionMatrix = GLKMatrix4Multiply(p1, p2);
GLKMatrix4 modelViewMatrix = GLKMatrix4Identity;
GLKMatrix4 modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix);
GLKMatrix3 normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL);
noise_shader.set_uniform("modelViewProjectionMatrix", modelViewProjectionMatrix.m, 0);
noise_shader.set_uniform("normalMatrix", normalMatrix.m, 0);
noise_shader.set_uniform("time", time);
noise_shader.set_attribute("position", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), &quads[0][0][0]);
noise_shader.set_attribute("color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), &quads[0][0][3]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, quads.size()*8);
}
void texture(J::shader const & tex_shader, J::fbo const & read_fbo) {
tex_shader.set_texture("tex", GL_TEXTURE_2D, read_fbo.texture_id, 0);
-0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
tex_shader.set_attribute("position", 2, GL_FLOAT, GL_FALSE, 0, &quad[0]);
tex_shader.set_attribute("tex_coord0", 2, GL_FLOAT, GL_FALSE, 0, &tex_quad[0]);
0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f
};
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
};
#endif

14
GLGameTemplate/Shaders/Shader.fsh

@ -1,14 +0,0 @@
//
// Shader.fsh
// GLGameTemplate
//
// Created by Joshua Moerman on 5/4/12.
// Copyright (c) 2012 Vadovas. All rights reserved.
//
varying lowp vec4 colorVarying;
void main()
{
gl_FragColor = colorVarying;
}

28
GLGameTemplate/Shaders/Shader.vsh

@ -1,28 +0,0 @@
//
// Shader.vsh
// GLGameTemplate
//
// Created by Joshua Moerman on 5/4/12.
// Copyright (c) 2012 Vadovas. All rights reserved.
//
attribute vec4 position;
attribute vec3 normal;
varying lowp vec4 colorVarying;
uniform mat4 modelViewProjectionMatrix;
uniform mat3 normalMatrix;
void main()
{
vec3 eyeNormal = normalize(normalMatrix * normal);
vec3 lightPosition = vec3(0.0, 0.0, 1.0);
vec4 diffuseColor = vec4(0.4, 0.4, 1.0, 1.0);
float nDotVP = max(0.0, dot(eyeNormal, normalize(lightPosition)));
colorVarying = diffuseColor * nDotVP;
gl_Position = modelViewProjectionMatrix * position;
}

52
GLGameTemplate/Shaders/effectShader.fsh

@ -0,0 +1,52 @@
varying lowp vec2 texCoordVarying;
varying highp vec4 positionVarying;
uniform sampler2D tex;
uniform highp float time;
const highp float threshold = 1.0;
const highp float width = 0.5;
const highp float smoothness = 0.2;
const highp float exposure = 0.8;
const highp float mix = 2.0;
void main( void ) {
lowp vec4 orig = texture2D(tex, texCoordVarying);
if(length(orig.xyz) <= 0.01){
gl_FragColor.b = positionVarying.y*0.5+0.5;
gl_FragColor.g = 0.5 * gl_FragColor.b * (cos(positionVarying.x*3.0) + 1.0);
gl_FragColor.r = sin(-positionVarying.y*positionVarying.x*(10.0 + sin(time*0.1337)) + time*0.2337);
} else {
gl_FragColor = exposure*(mix*orig + (1.0 - mix)*normalize(orig));
}
if(true) { // shine
lowp vec2 offset = vec2(0.01, 0.0)*width;
lowp vec4 a = texture2D(tex, texCoordVarying - offset);
lowp vec4 b = texture2D(tex, texCoordVarying + offset);
gl_FragColor -= smoothness*(orig - a);
gl_FragColor -= smoothness*(orig - b);
if(length(a-b) > threshold)
gl_FragColor = vec4(0.0);
}
if(true) { // shine
lowp vec2 offset = vec2(0.0, 0.01)*width;
lowp vec4 a = texture2D(tex, texCoordVarying - offset);
lowp vec4 b = texture2D(tex, texCoordVarying + offset);
gl_FragColor -= smoothness*(orig - a);
gl_FragColor -= smoothness*(orig - b);
if(length(a-b) > threshold)
gl_FragColor = vec4(0.0);
}
gl_FragColor.a = 1.0;
}

11
GLGameTemplate/Shaders/effectShader.vsh

@ -0,0 +1,11 @@
attribute vec4 position;
attribute vec2 tex_coord0;
varying lowp vec2 texCoordVarying;
varying highp vec4 positionVarying;
void main( void ) {
texCoordVarying = tex_coord0;
gl_Position = position;
positionVarying = position;
}

8
GLGameTemplate/Shaders/teaShader.fsh

@ -0,0 +1,8 @@
varying lowp vec4 colorVarying;
void main( void ) {
gl_FragColor = colorVarying;
gl_FragColor.a = 1.0;
}

19
GLGameTemplate/Shaders/teaShader.vsh

@ -0,0 +1,19 @@
attribute vec4 position;
attribute vec4 color;
varying lowp vec4 colorVarying;
uniform mat4 modelViewProjectionMatrix;
uniform mat3 normalMatrix;
uniform float time;
void main( void ) {
gl_Position = modelViewProjectionMatrix * position;
if(sin(time / 8.0) < 0.0)
gl_Position.y -= gl_Position.x*gl_Position.x*gl_Position.z*sin(time)*0.02;
else
gl_Position.y -= gl_Position.x*gl_Position.z*sin(time)*0.05;
colorVarying = color;
}

13
GLGameTemplate/Shaders/textureShader.fsh

@ -0,0 +1,13 @@
varying lowp vec2 texCoordVarying;
uniform sampler2D tex;
uniform lowp mat4 color_transformation;
void main( void ) {
lowp vec4 orig = texture2D(tex, texCoordVarying);
orig.a = 1.0;
gl_FragColor = color_transformation * orig;
gl_FragColor.a = 1.0;
}

9
GLGameTemplate/Shaders/textureShader.vsh

@ -0,0 +1,9 @@
attribute vec4 position;
attribute vec2 tex_coord0;
varying lowp vec2 texCoordVarying;
void main( void ) {
texCoordVarying = tex_coord0;
gl_Position = position;
}

0
GLGameTemplate/GLGameTemplate-Info.plist → GLGameTemplate/SkyRoads-Info.plist

0
GLGameTemplate/GLGameTemplate-Prefix.pch → GLGameTemplate/SkyRoads-Prefix.pch

54
GLGameTemplate/ViewController.mm

@ -30,18 +30,31 @@
#pragma mark - View stuff
- (void)viewDidLoad {
self.preferredFramesPerSecond = 60;
self.preferredFramesPerSecond = App::preferred_frames_per_second();
[super viewDidLoad];
self.context = [[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2] autorelease];
if (!self.context) NSLog(@"Failed to create ES context");
GLKView* view = (GLKView* )self.view;
view.autoresizesSubviews = YES;
view.context = self.context;
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
view.drawableMultisample = GLKViewDrawableMultisample4X;
if(App::depth()) view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
if(App::multisample()) view.drawableMultisample = GLKViewDrawableMultisample4X;
[self setupGL];
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, view.frame.size.width, 48);
button.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[button setTitle:@"Change Colours" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:button];
}
- (void)buttonPressed:(UIButton*)sender{
if(app)
app->change_color();
}
- (void)viewDidUnload {
@ -66,7 +79,14 @@
#pragma mark - openGL setup
- (void)setupGL {
[EAGLContext setCurrentContext:self.context];
app = new App;
width = self.view.bounds.size.width;
height = self.view.bounds.size.height;
try {
app = new App(width, height);
} catch (std::exception & e) {
std::cout << e.what() << std::endl;
throw e;
}
}
- (void)tearDownGL {
@ -78,16 +98,30 @@
#pragma mark - GLKView and GLKViewController delegate methods
- (void)update {
if(width != self.view.bounds.size.width || height != self.view.bounds.size.height){
width = self.view.bounds.size.width;
height = self.view.bounds.size.height;
app->resize(width, height);
try {
if(width != self.view.bounds.size.width || height != self.view.bounds.size.height){
width = self.view.bounds.size.width;
height = self.view.bounds.size.height;
app->resize(width, height);
}
app->update(self.timeSinceLastUpdate);
} catch (std::exception & e) {
std::cout << e.what() << std::endl;
throw e;
}
app->update(self.timeSinceLastUpdate);
}
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect {
app->draw();
try {
app->draw();
} catch (std::exception & e) {
std::cout << e.what() << std::endl;
throw e;
}
}
@end

121
GLGameTemplate/statics.h

@ -0,0 +1,121 @@
//
// statics.h
// SkyRoads
//
// Created by Joshua Moerman on 5/4/12.
// Copyright (c) 2012 Vadovas. All rights reserved.
//
#ifndef SkyRoads_statics_h
#define SkyRoads_statics_h
static const unsigned int colors = 7;
static const GLfloat color_transformations[colors][16] = {
{
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
},
{
-0.1, -2.0, -0.9, 1.0,
-0.4, -0.5, -0.9, 1.0,
-2.0, -0.1, -0.9, 1.0,
0.0, 0.0, 0.0, 1.0
},
{
0.1, 0.0, -0.9, 0.4,
0.4, 1.0, 0.0, 0.0,
0.0, 0.1, 0.3, 0.0,
0.0, 0.0, 0.0, 1.0
},
{
0.5, -0.3, -0.5, 0.5,
0.5, 0.0, -0.5, 0.5,
0.5, 1.0, -0.5, 0.5,
0.0, 0.0, 0.0, 1.0
},
{
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.5,
0.0, 0.0, 0.0, 0.1,
0.0, 0.0, 0.0, 1.0
},
{
5.0, -1.0, -5.0, -0.5,
-5.0, 5.0, -1.0, -0.5,
-1.0, -5.0, 5.0, -0.5,
0.0, 0.0, 0.0, 1.0
},
{
1.0, 1.0, 1.0, 0.1,
0.0, 1.0, 0.0, 0.0,
0.0, 1.0, 0.8, 0.2,
0.0, 0.0, 0.0, 1.0
}
};
static const GLfloat quad[] = {
1.0, 1.0,
1.0, -1.0,
-1.0, 1.0,
-1.0, -1.0
};
static const GLfloat tex_quad[] = {
1.0, 1.0,
1.0, 0.0,
0.0, 1.0,
0.0, 0.0
};
static const int level[] = {
1,0,0,0,0,
0,1,0,0,0,
0,0,1,0,0,
0,0,0,1,0,
0,0,0,0,1,
1,1,1,1,1,
1,0,0,0,0,
1,1,0,0,0,
0,1,1,0,0,
0,0,1,1,0,
0,0,0,1,1,
0,0,0,0,1,
0,0,0,1,1,
0,0,1,1,0,
0,1,1,0,0,
1,1,0,0,0,
1,0,0,0,0,
1,1,1,1,1,
0,1,0,1,0,
1,0,1,0,1,
0,1,0,1,0,
1,0,1,0,1,
0,1,0,1,0,
1,1,1,1,1,
1,0,0,0,0,
1,0,0,0,0,
1,0,0,0,0,
1,0,0,0,0,
1,1,0,0,0,
1,1,1,0,0,
1,1,1,1,0,
1,1,1,1,1,
0,1,1,1,1,
0,0,1,1,1,
0,0,0,1,1,
0,0,0,0,1,
0,0,0,0,1,
0,0,0,0,1,
0,0,0,0,1,
1,1,1,1,1,
};
static const size_t level_width = 5;
static const size_t level_height = sizeof(level) / sizeof(level[0]) / level_width;
static const size_t number_of_quads = std::count(level, level+level_height*level_width, 1);
#endif

107
GLGameTemplate.xcodeproj/project.pbxproj → SkyRoads.xcodeproj/project.pbxproj

@ -15,12 +15,22 @@
4280A92A1553DD4C00664DC2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4280A9281553DD4C00664DC2 /* InfoPlist.strings */; };
4280A92C1553DD4C00664DC2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4280A92B1553DD4C00664DC2 /* main.m */; };
4280A9301553DD4C00664DC2 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4280A92F1553DD4C00664DC2 /* AppDelegate.m */; };
4280A9321553DD4C00664DC2 /* Shader.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 4280A9311553DD4C00664DC2 /* Shader.fsh */; };
4280A9341553DD4C00664DC2 /* Shader.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 4280A9331553DD4C00664DC2 /* Shader.vsh */; };
4280A9371553DD4C00664DC2 /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4280A9361553DD4C00664DC2 /* ViewController.mm */; };
4280A93A1553DD4C00664DC2 /* ViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4280A9381553DD4C00664DC2 /* ViewController_iPhone.xib */; };
4280A93D1553DD4C00664DC2 /* ViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4280A93B1553DD4C00664DC2 /* ViewController_iPad.xib */; };
42E092901553DFC2002EA900 /* libJ.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42E0928C1553DFB7002EA900 /* libJ.a */; };
42E092C81553FF6B002EA900 /* effectShader.fsh in Sources */ = {isa = PBXBuildFile; fileRef = 42E092C21553FF6B002EA900 /* effectShader.fsh */; };
42E092C91553FF6B002EA900 /* effectShader.vsh in Sources */ = {isa = PBXBuildFile; fileRef = 42E092C31553FF6B002EA900 /* effectShader.vsh */; };
42E092CA1553FF6B002EA900 /* teaShader.fsh in Sources */ = {isa = PBXBuildFile; fileRef = 42E092C41553FF6B002EA900 /* teaShader.fsh */; };
42E092CB1553FF6B002EA900 /* teaShader.vsh in Sources */ = {isa = PBXBuildFile; fileRef = 42E092C51553FF6B002EA900 /* teaShader.vsh */; };
42E092CC1553FF6B002EA900 /* textureShader.fsh in Sources */ = {isa = PBXBuildFile; fileRef = 42E092C61553FF6B002EA900 /* textureShader.fsh */; };
42E092CD1553FF6B002EA900 /* textureShader.vsh in Sources */ = {isa = PBXBuildFile; fileRef = 42E092C71553FF6B002EA900 /* textureShader.vsh */; };
42E092CF15540857002EA900 /* effectShader.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 42E092C21553FF6B002EA900 /* effectShader.fsh */; };
42E092D015540857002EA900 /* effectShader.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 42E092C31553FF6B002EA900 /* effectShader.vsh */; };
42E092D115540857002EA900 /* teaShader.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 42E092C41553FF6B002EA900 /* teaShader.fsh */; };
42E092D215540857002EA900 /* teaShader.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 42E092C51553FF6B002EA900 /* teaShader.vsh */; };
42E092D315540857002EA900 /* textureShader.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 42E092C61553FF6B002EA900 /* textureShader.fsh */; };
42E092D415540857002EA900 /* textureShader.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 42E092C71553FF6B002EA900 /* textureShader.vsh */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -34,26 +44,31 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
4280A9171553DD4C00664DC2 /* GLGameTemplate.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GLGameTemplate.app; sourceTree = BUILT_PRODUCTS_DIR; };
4280A9171553DD4C00664DC2 /* SkyRoads.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SkyRoads.app; sourceTree = BUILT_PRODUCTS_DIR; };
4280A91B1553DD4C00664DC2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
4280A91D1553DD4C00664DC2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
4280A91F1553DD4C00664DC2 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
4280A9211553DD4C00664DC2 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; };
4280A9231553DD4C00664DC2 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
4280A9271553DD4C00664DC2 /* GLGameTemplate-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GLGameTemplate-Info.plist"; sourceTree = "<group>"; };
4280A9271553DD4C00664DC2 /* SkyRoads-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SkyRoads-Info.plist"; sourceTree = "<group>"; };
4280A9291553DD4C00664DC2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
4280A92B1553DD4C00664DC2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
4280A92D1553DD4C00664DC2 /* GLGameTemplate-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GLGameTemplate-Prefix.pch"; sourceTree = "<group>"; };
4280A92D1553DD4C00664DC2 /* SkyRoads-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SkyRoads-Prefix.pch"; sourceTree = "<group>"; };
4280A92E1553DD4C00664DC2 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
4280A92F1553DD4C00664DC2 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
4280A9311553DD4C00664DC2 /* Shader.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = Shader.fsh; path = Shaders/Shader.fsh; sourceTree = "<group>"; };
4280A9331553DD4C00664DC2 /* Shader.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = Shader.vsh; path = Shaders/Shader.vsh; sourceTree = "<group>"; };
4280A9351553DD4C00664DC2 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
4280A9361553DD4C00664DC2 /* ViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewController.mm; sourceTree = "<group>"; };
4280A9391553DD4C00664DC2 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPhone.xib; sourceTree = "<group>"; };
4280A93C1553DD4C00664DC2 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPad.xib; sourceTree = "<group>"; };
42E092841553DFB7002EA900 /* J.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = J.xcodeproj; path = ../J/J.xcodeproj; sourceTree = "<group>"; };
42E092971553F367002EA900 /* App.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = App.h; sourceTree = "<group>"; };
42E092C21553FF6B002EA900 /* effectShader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = effectShader.fsh; sourceTree = "<group>"; };
42E092C31553FF6B002EA900 /* effectShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = effectShader.vsh; sourceTree = "<group>"; };
42E092C41553FF6B002EA900 /* teaShader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = teaShader.fsh; sourceTree = "<group>"; };
42E092C51553FF6B002EA900 /* teaShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = teaShader.vsh; sourceTree = "<group>"; };
42E092C61553FF6B002EA900 /* textureShader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = textureShader.fsh; sourceTree = "<group>"; };
42E092C71553FF6B002EA900 /* textureShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = textureShader.vsh; sourceTree = "<group>"; };
42E092CE15540515002EA900 /* statics.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = statics.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -76,7 +91,7 @@
4280A90C1553DD4C00664DC2 = {
isa = PBXGroup;
children = (
4280A9251553DD4C00664DC2 /* GLGameTemplate */,
4280A9251553DD4C00664DC2 /* SkyRoads */,
4280A91A1553DD4C00664DC2 /* Frameworks */,
4280A9181553DD4C00664DC2 /* Products */,
);
@ -85,7 +100,7 @@
4280A9181553DD4C00664DC2 /* Products */ = {
isa = PBXGroup;
children = (
4280A9171553DD4C00664DC2 /* GLGameTemplate.app */,
4280A9171553DD4C00664DC2 /* SkyRoads.app */,
);
name = Products;
sourceTree = "<group>";
@ -103,15 +118,16 @@
name = Frameworks;
sourceTree = "<group>";
};
4280A9251553DD4C00664DC2 /* GLGameTemplate */ = {
4280A9251553DD4C00664DC2 /* SkyRoads */ = {
isa = PBXGroup;
children = (
42E092CE15540515002EA900 /* statics.h */,
42E092971553F367002EA900 /* App.h */,
4280A9311553DD4C00664DC2 /* Shader.fsh */,
4280A9331553DD4C00664DC2 /* Shader.vsh */,
42E092A81553FDDB002EA900 /* Shaders */,
42E092981553F7E6002EA900 /* GLViews */,
4280A9261553DD4C00664DC2 /* Supporting Files */,
);
name = SkyRoads;
path = GLGameTemplate;
sourceTree = "<group>";
};
@ -120,10 +136,10 @@
children = (
4280A92E1553DD4C00664DC2 /* AppDelegate.h */,
4280A92F1553DD4C00664DC2 /* AppDelegate.m */,
4280A9271553DD4C00664DC2 /* GLGameTemplate-Info.plist */,
4280A9271553DD4C00664DC2 /* SkyRoads-Info.plist */,
4280A9281553DD4C00664DC2 /* InfoPlist.strings */,
4280A92B1553DD4C00664DC2 /* main.m */,
4280A92D1553DD4C00664DC2 /* GLGameTemplate-Prefix.pch */,
4280A92D1553DD4C00664DC2 /* SkyRoads-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
@ -147,12 +163,33 @@
name = GLViews;
sourceTree = "<group>";
};
42E092A81553FDDB002EA900 /* Shaders */ = {
isa = PBXGroup;
children = (
42E092C11553FF6B002EA900 /* Shaders */,
);
path = Shaders;
sourceTree = "<group>";
};
42E092C11553FF6B002EA900 /* Shaders */ = {
isa = PBXGroup;
children = (
42E092C21553FF6B002EA900 /* effectShader.fsh */,
42E092C31553FF6B002EA900 /* effectShader.vsh */,
42E092C41553FF6B002EA900 /* teaShader.fsh */,
42E092C51553FF6B002EA900 /* teaShader.vsh */,
42E092C61553FF6B002EA900 /* textureShader.fsh */,
42E092C71553FF6B002EA900 /* textureShader.vsh */,
);
name = Shaders;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
4280A9161553DD4C00664DC2 /* GLGameTemplate */ = {
4280A9161553DD4C00664DC2 /* SkyRoads */ = {
isa = PBXNativeTarget;
buildConfigurationList = 4280A9401553DD4C00664DC2 /* Build configuration list for PBXNativeTarget "GLGameTemplate" */;
buildConfigurationList = 4280A9401553DD4C00664DC2 /* Build configuration list for PBXNativeTarget "SkyRoads" */;
buildPhases = (
4280A9131553DD4C00664DC2 /* Sources */,
4280A9141553DD4C00664DC2 /* Frameworks */,
@ -162,9 +199,9 @@
);
dependencies = (
);
name = GLGameTemplate;
name = SkyRoads;
productName = GLGameTemplate;
productReference = 4280A9171553DD4C00664DC2 /* GLGameTemplate.app */;
productReference = 4280A9171553DD4C00664DC2 /* SkyRoads.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
@ -176,7 +213,7 @@
LastUpgradeCheck = 0430;
ORGANIZATIONNAME = Vadovas;
};
buildConfigurationList = 4280A9111553DD4C00664DC2 /* Build configuration list for PBXProject "GLGameTemplate" */;
buildConfigurationList = 4280A9111553DD4C00664DC2 /* Build configuration list for PBXProject "SkyRoads" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
@ -195,7 +232,7 @@
);
projectRoot = "";
targets = (
4280A9161553DD4C00664DC2 /* GLGameTemplate */,
4280A9161553DD4C00664DC2 /* SkyRoads */,
);
};
/* End PBXProject section */
@ -215,9 +252,13 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
42E092CF15540857002EA900 /* effectShader.fsh in Resources */,
42E092D015540857002EA900 /* effectShader.vsh in Resources */,
42E092D115540857002EA900 /* teaShader.fsh in Resources */,
42E092D215540857002EA900 /* teaShader.vsh in Resources */,
42E092D315540857002EA900 /* textureShader.fsh in Resources */,
42E092D415540857002EA900 /* textureShader.vsh in Resources */,
4280A92A1553DD4C00664DC2 /* InfoPlist.strings in Resources */,
4280A9321553DD4C00664DC2 /* Shader.fsh in Resources */,
4280A9341553DD4C00664DC2 /* Shader.vsh in Resources */,
4280A93A1553DD4C00664DC2 /* ViewController_iPhone.xib in Resources */,
4280A93D1553DD4C00664DC2 /* ViewController_iPad.xib in Resources */,
);
@ -233,6 +274,12 @@
4280A92C1553DD4C00664DC2 /* main.m in Sources */,
4280A9301553DD4C00664DC2 /* AppDelegate.m in Sources */,
4280A9371553DD4C00664DC2 /* ViewController.mm in Sources */,
42E092C81553FF6B002EA900 /* effectShader.fsh in Sources */,
42E092C91553FF6B002EA900 /* effectShader.vsh in Sources */,
42E092CA1553FF6B002EA900 /* teaShader.fsh in Sources */,
42E092CB1553FF6B002EA900 /* teaShader.vsh in Sources */,
42E092CC1553FF6B002EA900 /* textureShader.fsh in Sources */,
42E092CD1553FF6B002EA900 /* textureShader.vsh in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -317,11 +364,11 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "GLGameTemplate/GLGameTemplate-Prefix.pch";
GCC_PREFIX_HEADER = "GLGameTemplate/SkyRoads-Prefix.pch";
"GCC_THUMB_SUPPORT[arch=armv6]" = "";
HEADER_SEARCH_PATHS = "../J/**";
INFOPLIST_FILE = "GLGameTemplate/GLGameTemplate-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
INFOPLIST_FILE = "GLGameTemplate/SkyRoads-Info.plist";
PRODUCT_NAME = SkyRoads;
WRAPPER_EXTENSION = app;
};
name = Debug;
@ -332,11 +379,11 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "GLGameTemplate/GLGameTemplate-Prefix.pch";
GCC_PREFIX_HEADER = "GLGameTemplate/SkyRoads-Prefix.pch";
"GCC_THUMB_SUPPORT[arch=armv6]" = "";
HEADER_SEARCH_PATHS = "../J/**";
INFOPLIST_FILE = "GLGameTemplate/GLGameTemplate-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
INFOPLIST_FILE = "GLGameTemplate/SkyRoads-Info.plist";
PRODUCT_NAME = SkyRoads;
WRAPPER_EXTENSION = app;
};
name = Release;
@ -344,7 +391,7 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
4280A9111553DD4C00664DC2 /* Build configuration list for PBXProject "GLGameTemplate" */ = {
4280A9111553DD4C00664DC2 /* Build configuration list for PBXProject "SkyRoads" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4280A93E1553DD4C00664DC2 /* Debug */,
@ -353,7 +400,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
4280A9401553DD4C00664DC2 /* Build configuration list for PBXNativeTarget "GLGameTemplate" */ = {
4280A9401553DD4C00664DC2 /* Build configuration list for PBXNativeTarget "SkyRoads" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4280A9411553DD4C00664DC2 /* Debug */,