My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
////////////////////////////////////////////////////////////////////////////////
// UIGLView.h
//
// Provides UIView for OpenGL drawing on iPhone
//
// Andrew Willmott, September 2007
////////////////////////////////////////////////////////////////////////////////

#import <UIKit/UIView.h>
#import <CoreSurface/CoreSurface.h>
#include <OpenGLES/egl.h>
#include <OpenGLES/gl.h>



void gluLookAt(float eyeX, float eyeY, float eyeZ, float lookAtX, float lookAtY, float lookAtZ, float upX, float upY, float upZ) ;



////////////////////////////////////////////////////////////////////////////////
// UIGLView
//
// Provides an OpenGL view.
//
// You should override drawRect with something like:
// [self beginScene];
// glBlah...
// [self endScene];
//
// and then call [view setNeedsUpdate]
@interface UIGLView : UIView
{
EGLDisplay mEGLDisplay;
EGLContext mEGLContext;
EGLSurface mEGLSurface;
CoreSurfaceBufferRef mScreenSurface;
}

- (id)initWithFrame:(CGRect)frame;

- (void)beginScene;
// call in drawRect, before OpenGL rendering statements
- (void)endScene;
// call in drawRect, after OpenGL rendering statements

@end

////////////////////////////////////////////////////////////////////////////////
// Provides a UIGLView with built-in view controls:
//
// single-finger drag: rotate around and up/down
// double-finger drag (or anchor one finger and drag the second up and down): zoom in/out
// triple-finger drag (anchor two fingers, drag the other left/right or up/down): translate viewpoint
// two-finger tap: reset view
//
// In drawRect, call positionCamera when you need to set the camera matrices.
@interface UIGLCameraView : UIGLView
{
bool mZUp; // Set to 0 or 1 to indicate whether we do Z-up or Y-up

// Camera internals
GLfloat mCameraTheta;
GLfloat mCameraPhi;
GLfloat mCameraDistance;
GLfloat mCameraOffsetX;
GLfloat mCameraOffsetY;
GLfloat mCameraFOV;

// dragging internals
GLfloat mStartCameraTheta;
GLfloat mStartCameraPhi;
GLfloat mStartCameraDistance;
GLfloat mStartCameraOffsetX;
GLfloat mStartCameraOffsetY;

int mButtonDown;

float mMouseX;
float mMouseY;
float mMouseDownX;
float mMouseDownY;
}

- (void) positionCamera;
// Call to set camera matrices

- (void) resetView;
// override this to provide your own initial settings for mCamera* above.
// also, call to manually reset the view.
@end

Show details Hide details

Change log

r29 by azinman on Jan 24, 2008   Diff
now it even makes!
Go to: 
Project members, sign in to write a code review

Older revisions

r20 by azinman on Nov 06, 2007   Diff
moved back to 3d
All revisions of this file

File info

Size: 2492 bytes, 91 lines
Hosted by Google Code