Skip to content

Commit f054a91

Browse files
committed
add xcode support
- tested ok in max os x 10.8 (Mountain Lion) by xcode 4.4 using openGL framework - but remove some feature in main.cpp. Maybe add them someday, because I do't need them today.
1 parent c57048a commit f054a91

File tree

6 files changed

+433
-1
lines changed

6 files changed

+433
-1
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.o
2+
.DS_Store

Diff for: README

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ TODO list:
1616
3 User control from keyboard, so user can play with computer.
1717
4 ...
1818

19+
------------------------<faryang>------------------------
20+
21+
- 2012/7/31 Add Xcode Project files
22+

Diff for: build/Basketball_Demo_osx.xcodeproj/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project.xcworkspace/
2+
xcuserdata/

Diff for: build/Basketball_Demo_osx.xcodeproj/project.pbxproj

+351
Large diffs are not rendered by default.

Diff for: src/Entry.cpp

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// main.cpp
2+
// BasketBall
3+
//
4+
// Created by FarYang on 7/31/12.
5+
// Copyright (c) 2012 FarYang. All rights reserved.
6+
//
7+
8+
#include <iostream>
9+
#include <stdlib.h>
10+
#include <math.h>
11+
#include <GLUT/glut.h>
12+
#include "Game.h"
13+
14+
using namespace std;
15+
16+
const int tick = 50;/*ms*/
17+
18+
int main_window, bottom_window, right_window;
19+
20+
float obj_pos[] = { 2.0, 0.0, -50.0 };
21+
int last_x,last_y;
22+
23+
24+
void display()
25+
{
26+
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
27+
glPushMatrix();
28+
glTranslatef(-obj_pos[0],-obj_pos[1],-obj_pos[2] );
29+
GAME->Render();
30+
//draw the secen
31+
glPopMatrix();
32+
glutSwapBuffers();
33+
}
34+
35+
void reshape(int w, int h)
36+
{
37+
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
38+
glMatrixMode(GL_PROJECTION);
39+
glLoadIdentity();
40+
gluPerspective(65.0, (GLfloat) w/(GLfloat) h, 1.0, 20000.0);
41+
glMatrixMode(GL_MODELVIEW);
42+
glLoadIdentity();
43+
gluLookAt(0.0f,0.0f,70.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f);
44+
glutPostRedisplay();
45+
}
46+
47+
void update()
48+
{
49+
if ( glutGetWindow() != main_window )
50+
glutSetWindow(main_window);
51+
usleep(tick * 1000);
52+
GAME->Update();
53+
glutPostRedisplay();
54+
}
55+
56+
int main(int argc, char **argv)
57+
{
58+
glutInit( &argc, argv );
59+
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB |GLUT_DEPTH );
60+
glutInitWindowSize( 800, 600 );
61+
glutInitWindowPosition(800, 500);
62+
main_window = glutCreateWindow( "BasketBall - keywords: AI, FSM, Steering Behaviors" );
63+
glClearColor(0.0, 00.0, 0.0, 0.0);
64+
glShadeModel(GL_FLAT);
65+
srand((unsigned)time(NULL));
66+
glutDisplayFunc( display );
67+
glutReshapeFunc(reshape);
68+
69+
glutIdleFunc(update);
70+
71+
glutMainLoop();
72+
return 0;
73+
}
74+

Diff for: src/Grapic.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include <stdio.h>
88
#include <cstring>
99
#include <stdarg.h>
10-
#include <GL/glut.h>
1110
#include "Vec2D.h"
11+
#include <GLUT/glut.h>
1212

1313

1414
//------------------------------- define some colors

0 commit comments

Comments
 (0)