/*
 *  eglSetup.h
 *  eagl
 *
 *  Created by pin xue on 4/8/08.
 *  Copyright 2008 http://www.play3d.net. All rights reserved.
 *
 */
#define USE_FIXED_POINT
 
#include <OpenGLES/EAGL.h>
#include <OpenGLES/ES1/gl.h>

#ifdef USE_FIXED_POINT
  #define Float2Fixed(fl) ((GLfixed)((fl)*65536.0f))
  #define Fixed2Float(fx) ((float)((fx)/65536.0f))
#else
  #define Float2Fixed(fl) (fl)
  #define Fixed2Float(fx) (fx)
#endif

void rendering(void);

/** 
 * initialize the OpenGL ES, binding to the nativeWindow
 * a default 3D perspective is setup inside.
 * return 0 if success
 *       -1 failed to create window surface
 *       -2 failed to create context
 */
int init_egl(EAGLNativeWindow nativeWindow, int width, int height);

void default3DEnv(void);

// active the context with the surface
// return 0 if success, else use OpenGL call to get error code.
int makeCurrent(void);

// adjust OpenGL viewport to fit window size
void resize(int width, int height);

// swap buffers to show the drawing
// return 0 if success, else use OpenGL call to get error code.
int swapBuffers(void);

// destroy the surface and context
void clean_egl(void);