//
// GraphicsView.h
// iphone-gl-app
//
// Created by John Ryland on 7/06/09.
// Copyright InvertedLogic 2009. All rights reserved.
//
// EGL_SUPPORT not implemented yet, but idea is to make the code
// portable to other platforms like symbian more easily
// #define EGL_SUPPORT
#include <UIKit/UIKit.h>
#include <OpenGLES/EAGL.h>
#include <OpenGLES/ES1/gl.h>
#include <OpenGLES/ES1/glext.h>
#include "Context.h"
#ifdef EGL_SUPPORT
#include <GLES/egl.h>
#include <GLES/gl.h>
#endif
/*
This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
The view content is basically an EAGL surface you render your OpenGL scene into.
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
*/
@interface GraphicsView : UIView <UIAccelerometerDelegate>
{
@private
/* The pixel dimensions of the backbuffer */
GLint backingWidth;
GLint backingHeight;
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
GLuint viewRenderbuffer, viewFramebuffer;
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
GLuint depthRenderbuffer;
Context *cpp_context;
#ifdef EGL_SUPPORT
EGLDisplay eglDisplay;
EGLConfig eglConfig;
EGLContext eglContext;
EGLSurface eglSurface;
#else
EAGLContext *context;
#endif
NSTimer *animationTimer;
NSTimeInterval animationInterval;
}
- (id) initWithFrame:(CGRect)frame;
- (void) startAnimation;
- (void) stopAnimation;
- (void) drawView;
- (void) setupView;
- (BOOL) createFramebuffer;
- (void) destroyFramebuffer;
- (void) setAnimationInterval:(NSTimeInterval)interval;
@end