• R/O
  • HTTP
  • SSH
  • HTTPS

android: Commit

FermiSurfer for android


Commit MetaInfo

Revision1d364cf694a7368e1f894fc6a58b03b5476a865f (tree)
Zeit2019-08-30 19:34:23
Autormitsuaki1987 <kawamitsuaki@gmai...>
Commitermitsuaki1987

Log Message

backup

Ändern Zusammenfassung

Diff

--- a/Android1.NativeActivity/main.cpp
+++ b/Android1.NativeActivity/main.cpp
@@ -67,6 +67,7 @@ static int engine_init_display(struct engine* engine) {
6767 EGL_BLUE_SIZE, 8,
6868 EGL_GREEN_SIZE, 8,
6969 EGL_RED_SIZE, 8,
70+ EGL_DEPTH_SIZE, 16,
7071 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
7172 EGL_NONE
7273 };
@@ -114,26 +115,20 @@ static int engine_init_display(struct engine* engine) {
114115 glShadeModel(GL_SMOOTH);
115116 glEnable(GL_DEPTH_TEST);
116117
117- //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
118- //glShadeModel(GL_SMOOTH);
119-
120- //glClearColor(0.0, 0.0, 0.0, 0.0);
121- //glEnable(GL_DEPTH_TEST);
122- //glDisable(GL_DEPTH_TEST);
123118 glEnable(GL_LIGHTING);
124119 glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
125120 glEnable(GL_LIGHT0);
126121 glEnable(GL_LIGHT1);
127122 glEnable(GL_NORMALIZE);
128123 glEnable(GL_COLOR_MATERIAL);
124+ glEnableClientState(GL_VERTEX_ARRAY);
129125 glViewport(0, 0, engine->width, engine->height);
130126 GLfloat ratio = (GLfloat)engine->width/ (GLfloat)engine->height;
131127 glMatrixMode(GL_PROJECTION);
132128 glLoadIdentity();
133129 glFrustumf(-ratio, ratio, -1, 1, 1, 10);
134- glEnableClientState(GL_VERTEX_ARRAY);
135130
136- // glMatrixMode(GL_MODELVIEW);
131+ glMatrixMode(GL_MODELVIEW);
137132 return 0;
138133 }
139134 /**
@@ -164,14 +159,14 @@ static void engine_draw_frame(struct engine* engine) {
164159 {{-1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, {0.0, 0.0, -1.0}}
165160 };
166161 GLfloat clr[8][3][4] = {
167- {{1.0, 0.0, 0.0, 1.0}, {0.0, 1.0, 0.0, 1.0}, {0.0, 0.0, 1.0, 1.0}},
168- {{1.0, 0.0, 0.0, 1.0}, {0.0, 1.0, 0.0, 1.0}, {1.0, 1.0, 0.0, 1.0}},
169- {{1.0, 0.0, 0.0, 1.0}, {1.0, 0.0, 1.0, 1.0}, {0.0, 0.0, 1.0, 1.0}},
170- {{1.0, 0.0, 0.0, 1.0}, {1.0, 0.0, 1.0, 1.0}, {1.0, 1.0, 0.0, 1.0}},
171- {{0.0, 1.0, 1.0, 1.0}, {0.0, 1.0, 0.0, 1.0}, {0.0, 0.0, 1.0, 1.0}},
172- {{0.0, 1.0, 1.0, 1.0}, {0.0, 1.0, 0.0, 1.0}, {1.0, 1.0, 0.0, 1.0}},
173- {{0.0, 1.0, 1.0, 1.0}, {1.0, 0.0, 1.0, 1.0}, {0.0, 0.0, 1.0, 1.0}},
174- {{0.0, 1.0, 1.0, 1.0}, {1.0, 0.0, 1.0, 1.0}, {1.0, 1.0, 0.0, 1.0}}
162+ {{1.0, 0.0, 0.0, 0.0}, {0.0, 1.0, 0.0, 0.0}, {0.0, 0.0, 1.0, 0.0}},
163+ {{1.0, 0.0, 0.0, 0.0}, {0.0, 1.0, 0.0, 0.0}, {1.0, 1.0, 0.0, 0.0}},
164+ {{1.0, 0.0, 0.0, 0.0}, {1.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 1.0, 0.0}},
165+ {{1.0, 0.0, 0.0, 0.0}, {1.0, 0.0, 1.0, 0.0}, {1.0, 1.0, 0.0, 0.0}},
166+ {{0.0, 1.0, 1.0, 0.0}, {0.0, 1.0, 0.0, 0.0}, {0.0, 0.0, 1.0, 0.0}},
167+ {{0.0, 1.0, 1.0, 0.0}, {0.0, 1.0, 0.0, 0.0}, {1.0, 1.0, 0.0, 0.0}},
168+ {{0.0, 1.0, 1.0, 0.0}, {1.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 1.0, 0.0}},
169+ {{0.0, 1.0, 1.0, 0.0}, {1.0, 0.0, 1.0, 0.0}, {1.0, 1.0, 0.0, 0.0}}
175170 };
176171 GLfloat pos[] = { 1.0f, 1.0f, 1.0f, 0.0f };
177172 GLfloat amb[] = { 0.2f, 0.2f, 0.2f, 0.0f };
@@ -240,12 +235,11 @@ static void engine_draw_frame(struct engine* engine) {
240235 glClearColor(0.0, 0.0, 0.0, 1);
241236 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
242237
243- glMatrixMode(GL_MODELVIEW);
244238 glLoadIdentity();
245239 glTranslatef(0.0, 0.0, -5.0);
246240 glLightfv(GL_LIGHT0, GL_POSITION, pos);
247241 glLightfv(GL_LIGHT1, GL_AMBIENT, amb);
248- //glScalef(1.0, 1.0, 1.0);
242+ glScalef(2.0, 2.0, 2.0);
249243
250244 glEnableClientState(GL_NORMAL_ARRAY);
251245 glEnableClientState(GL_COLOR_ARRAY);
@@ -282,11 +276,17 @@ static void engine_term_display(struct engine* engine) {
282276 static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {
283277 struct engine* engine = (struct engine*)app->userData;
284278 if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
285- engine->state.x0 = engine->state.x;
286- engine->state.y0 = engine->state.y;
287- engine->state.x = AMotionEvent_getX(event, 0);
288- engine->state.y = AMotionEvent_getY(event, 0);
289- engine_draw_frame(engine);
279+ if (AMotionEvent_getAction(event) == AMOTION_EVENT_ACTION_DOWN) {
280+ engine->state.x = AMotionEvent_getX(event, 0);
281+ engine->state.y = AMotionEvent_getY(event, 0);
282+ }
283+ else if (AMotionEvent_getAction(event) == AMOTION_EVENT_ACTION_MOVE) {
284+ engine->state.x0 = engine->state.x;
285+ engine->state.y0 = engine->state.y;
286+ engine->state.x = AMotionEvent_getX(event, 0);
287+ engine->state.y = AMotionEvent_getY(event, 0);
288+ engine_draw_frame(engine);
289+ }
290290 return 1;
291291 }
292292 return 0;
Show on old repository browser