bool opengles_init(int width, int height, EGLDisplay* peglDisplay, EGLSurface* peglSurface, EGLContext* peglContext) { NativeDisplayType display = (NativeDisplayType)EGL_DEFAULT_DISPLAY; NativeWindowType window; setup_egl(display, window, peglDisplay, peglSurface, peglContext); return true; }
int main(int argc, char *argv[]) { EGLDisplay display = EGL_NO_DISPLAY; EGLSurface surface = EGL_NO_SURFACE; EGLContext context = EGL_NO_CONTEXT; GLfloat rotation_x = 0; /* angle for rotation in x direction */ GLfloat rotation_y = 0; /* angle for rotation in y direction */ GLuint vertexShaderId = 0; /* vertex shader id */ GLuint fragmentShaderId = 0; /* fragment shader id */ GLuint programId = 0; /* program id */ int mvpLoc = 0; /* for the uniform varible index value of mvp matrix */ int status; /* function call's return value */ unsigned int frame_count = 0; gdl_init(0); setup_plane(GDL_PLANE_ID_UPP_B, true); status = setup_egl(GDL_PLANE_ID_UPP_B, &display, &surface, &context); if (status != GL_TRUE) { printf("error setting egl\n"); return 1; } status = setup_gl(&programId, &vertexShaderId, &fragmentShaderId, &mvpLoc); if (status != GL_TRUE) { printf("error setting gl\n"); return 1; } int frame = 0; struct timeval start; gettimeofday(&start, NULL); struct timeval now; struct timeval sub; int duration; while (1) { render(rotation_x, rotation_y, mvpLoc); eglSwapBuffers(display, surface); frame++; rotation_x += 5.0f; if (rotation_x > 360.0f) { rotation_x = 0.0f; } rotation_y += 2.0f; if (rotation_y > 360.0f) { rotation_y = 0.0f; } gettimeofday(&now, NULL); timeval_subtract(&sub, &now, &start); duration = (sub.tv_usec + sub.tv_sec*1000000) / 1000; if (duration > 5000) { printf("CUBE FPS = %d\n", duration / frame); frame = 0; start = now; } } }