//  @ Project : hello eagl ++
//  @ File Name : eglSetup.h
//  @ Date : 2008-9-8
//  @ Author : kongfu.yang
//  @ Company : http://www.play3d.net
//  @ Copyright : 2008-9, Example source license. 
//        By keep this header comment, 
//        you may use this source file in your project for non-commercial or commercial purpose.

#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(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.
extern "C" 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.
extern "C" int swapBuffers(void);

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