@@ -77,7 +77,7 @@ struct SavedState {
77
77
* Shared state for our app.
78
78
*/
79
79
struct Engine {
80
- struct android_app * app;
80
+ android_app* app;
81
81
82
82
ASensorManager* sensorManager;
83
83
const ASensor* accelerometerSensor;
@@ -89,7 +89,7 @@ struct Engine {
89
89
EGLContext context;
90
90
int32_t width;
91
91
int32_t height;
92
- struct SavedState state;
92
+ SavedState state;
93
93
94
94
void CreateSensorListener (ALooper_callbackFunc callback) {
95
95
CHECK_NOT_NULL (app);
@@ -109,7 +109,7 @@ struct Engine {
109
109
/* *
110
110
* Initialize an EGL context for the current display.
111
111
*/
112
- static int engine_init_display (struct Engine * engine) {
112
+ static int engine_init_display (Engine* engine) {
113
113
// initialize OpenGL ES and EGL
114
114
115
115
/*
@@ -209,7 +209,7 @@ static int engine_init_display(struct Engine* engine) {
209
209
/* *
210
210
* Just the current frame in the display.
211
211
*/
212
- static void engine_draw_frame (struct Engine * engine) {
212
+ static void engine_draw_frame (Engine* engine) {
213
213
if (engine->display == nullptr ) {
214
214
// No display.
215
215
return ;
@@ -226,7 +226,7 @@ static void engine_draw_frame(struct Engine* engine) {
226
226
/* *
227
227
* Tear down the EGL context currently associated with the display.
228
228
*/
229
- static void engine_term_display (struct Engine * engine) {
229
+ static void engine_term_display (Engine* engine) {
230
230
if (engine->display != EGL_NO_DISPLAY) {
231
231
eglMakeCurrent (engine->display , EGL_NO_SURFACE, EGL_NO_SURFACE,
232
232
EGL_NO_CONTEXT);
@@ -247,9 +247,9 @@ static void engine_term_display(struct Engine* engine) {
247
247
/* *
248
248
* Process the next input event.
249
249
*/
250
- static int32_t engine_handle_input (struct android_app * app,
250
+ static int32_t engine_handle_input (android_app* app,
251
251
AInputEvent* event) {
252
- auto * engine = (struct Engine *)app->userData ;
252
+ auto * engine = (Engine*)app->userData ;
253
253
if (AInputEvent_getType (event) == AINPUT_EVENT_TYPE_MOTION) {
254
254
engine->animating = 1 ;
255
255
engine->state .x = AMotionEvent_getX (event, 0 );
@@ -262,14 +262,14 @@ static int32_t engine_handle_input(struct android_app* app,
262
262
/* *
263
263
* Process the next main command.
264
264
*/
265
- static void engine_handle_cmd (struct android_app * app, int32_t cmd) {
266
- auto * engine = (struct Engine *)app->userData ;
265
+ static void engine_handle_cmd (android_app* app, int32_t cmd) {
266
+ auto * engine = (Engine*)app->userData ;
267
267
switch (cmd) {
268
268
case APP_CMD_SAVE_STATE:
269
269
// The system has asked us to save our current state. Do so.
270
- engine->app ->savedState = malloc (sizeof (struct SavedState ));
271
- *((struct SavedState *)engine->app ->savedState ) = engine->state ;
272
- engine->app ->savedStateSize = sizeof (struct SavedState );
270
+ engine->app ->savedState = malloc (sizeof (SavedState));
271
+ *((SavedState*)engine->app ->savedState ) = engine->state ;
272
+ engine->app ->savedStateSize = sizeof (SavedState);
273
273
break ;
274
274
case APP_CMD_INIT_WINDOW:
275
275
// The window is being shown, get it ready.
@@ -311,7 +311,7 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
311
311
312
312
int OnSensorEvent (int /* fd */ , int /* events */ , void * data) {
313
313
CHECK_NOT_NULL (data);
314
- Engine* engine = reinterpret_cast <struct Engine *>(data);
314
+ Engine* engine = reinterpret_cast <Engine*>(data);
315
315
316
316
CHECK_NOT_NULL (engine->accelerometerSensor );
317
317
ASensorEvent event;
@@ -332,8 +332,8 @@ int OnSensorEvent(int /* fd */, int /* events */, void* data) {
332
332
* android_native_app_glue. It runs in its own thread, with its own
333
333
* event loop for receiving input events and doing other things.
334
334
*/
335
- void android_main (struct android_app * state) {
336
- struct Engine engine {};
335
+ void android_main (android_app* state) {
336
+ Engine engine {};
337
337
338
338
memset (&engine, 0 , sizeof (engine));
339
339
state->userData = &engine;
@@ -346,15 +346,15 @@ void android_main(struct android_app* state) {
346
346
347
347
if (state->savedState != nullptr ) {
348
348
// We are starting with a previous saved state; restore from it.
349
- engine.state = *(struct SavedState *)state->savedState ;
349
+ engine.state = *(SavedState*)state->savedState ;
350
350
}
351
351
352
352
// loop waiting for stuff to do.
353
353
354
354
while (true ) {
355
355
// Read all pending events.
356
356
int events;
357
- struct android_poll_source * source;
357
+ android_poll_source* source;
358
358
359
359
// If not animating, we will block forever waiting for events.
360
360
// If animating, we loop until all events are read, then continue
0 commit comments