67
67
/* *
68
68
* Our saved state data.
69
69
*/
70
- struct saved_state {
70
+ struct SavedState {
71
71
float angle;
72
72
int32_t x;
73
73
int32_t y;
@@ -76,7 +76,7 @@ struct saved_state {
76
76
/* *
77
77
* Shared state for our app.
78
78
*/
79
- struct engine {
79
+ struct Engine {
80
80
struct android_app * app;
81
81
82
82
ASensorManager* sensorManager;
@@ -89,7 +89,7 @@ struct engine {
89
89
EGLContext context;
90
90
int32_t width;
91
91
int32_t height;
92
- struct saved_state state;
92
+ struct 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 (struct 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 (struct 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 (struct 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);
@@ -249,7 +249,7 @@ static void engine_term_display(struct engine* engine) {
249
249
*/
250
250
static int32_t engine_handle_input (struct android_app * app,
251
251
AInputEvent* event) {
252
- auto * engine = (struct engine *)app->userData ;
252
+ auto * engine = (struct 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 );
@@ -263,13 +263,13 @@ static int32_t engine_handle_input(struct android_app* app,
263
263
* Process the next main command.
264
264
*/
265
265
static void engine_handle_cmd (struct android_app * app, int32_t cmd) {
266
- auto * engine = (struct engine *)app->userData ;
266
+ auto * engine = (struct 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 saved_state ));
271
- *((struct saved_state *)engine->app ->savedState ) = engine->state ;
272
- engine->app ->savedStateSize = sizeof (struct saved_state );
270
+ engine->app ->savedState = malloc (sizeof (struct SavedState ));
271
+ *((struct SavedState *)engine->app ->savedState ) = engine->state ;
272
+ engine->app ->savedStateSize = sizeof (struct 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 <struct Engine *>(data);
315
315
316
316
CHECK_NOT_NULL (engine->accelerometerSensor );
317
317
ASensorEvent event;
@@ -333,7 +333,7 @@ int OnSensorEvent(int /* fd */, int /* events */, void* data) {
333
333
* event loop for receiving input events and doing other things.
334
334
*/
335
335
void android_main (struct android_app * state) {
336
- struct engine engine {};
336
+ struct Engine engine {};
337
337
338
338
memset (&engine, 0 , sizeof (engine));
339
339
state->userData = &engine;
@@ -346,7 +346,7 @@ 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 saved_state *)state->savedState ;
349
+ engine.state = *(struct SavedState *)state->savedState ;
350
350
}
351
351
352
352
// loop waiting for stuff to do.
0 commit comments