added asset loading class, zoom factor, vbo switch, shader version
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "pch.h"
|
||||
#include "app.h"
|
||||
#include "..\..\..\..\engine\asset.h"
|
||||
|
||||
/**
|
||||
* Our saved state data.
|
||||
@@ -150,15 +151,13 @@ static int engine_init_display(struct engine* engine) {
|
||||
//glShadeModel(GL_SMOOTH);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
//glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
Asset::m_am = engine->app->activity->assetManager;
|
||||
App::I.width = w;
|
||||
App::I.height = h;
|
||||
App::I.initShaders();
|
||||
|
||||
if (!plane.create<1>(1,1))
|
||||
LOG("Failed to create the plane mesh");
|
||||
App::I.init();
|
||||
|
||||
LOG("All ready");
|
||||
engine->animating = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -167,22 +166,10 @@ static int engine_init_display(struct engine* engine) {
|
||||
* Just the current frame in the display.
|
||||
*/
|
||||
static void engine_draw_frame(struct engine* engine) {
|
||||
if (engine->display == NULL) {
|
||||
// No display.
|
||||
if (engine->display == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
// Just fill the screen with a color.
|
||||
glClearColor(((float)engine->state.x)/engine->width, engine->state.angle,
|
||||
((float)engine->state.y)/engine->height, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glm::mat4 mvp = glm::ortho<float>(-1, 1, -1, 1, -1, 1);
|
||||
//App::I.update(now - _prevTime);
|
||||
ShaderManager::use(kShader::Color);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||
ShaderManager::u_vec4(kShaderUniform::Col, glm::vec4(1, 0, 0, 1));
|
||||
plane.draw_fill();
|
||||
App::I.update(0);
|
||||
|
||||
eglSwapBuffers(engine->display, engine->surface);
|
||||
}
|
||||
@@ -212,12 +199,33 @@ static void engine_term_display(struct engine* engine) {
|
||||
*/
|
||||
static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {
|
||||
struct engine* engine = (struct engine*)app->userData;
|
||||
if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
|
||||
engine->animating = 1;
|
||||
engine->state.x = AMotionEvent_getX(event, 0);
|
||||
engine->state.y = AMotionEvent_getY(event, 0);
|
||||
return 1;
|
||||
}
|
||||
float x = AMotionEvent_getX(event, 0);
|
||||
float y = AMotionEvent_getY(event, 0);
|
||||
MouseEvent e;
|
||||
int32_t eventType = AInputEvent_getType(event);
|
||||
switch (eventType) {
|
||||
case AINPUT_EVENT_TYPE_MOTION:
|
||||
switch (AInputEvent_getSource(event)) {
|
||||
case AINPUT_SOURCE_TOUCHSCREEN:
|
||||
int action = AKeyEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK;
|
||||
switch (action) {
|
||||
case AMOTION_EVENT_ACTION_DOWN:
|
||||
App::I.mouse_down(0, x, y);
|
||||
return 1;
|
||||
case AMOTION_EVENT_ACTION_UP:
|
||||
App::I.mouse_up(0, x, y);
|
||||
return 1;
|
||||
case AMOTION_EVENT_ACTION_MOVE:
|
||||
App::I.mouse_move(x, y);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
} // end switch
|
||||
break;
|
||||
case AINPUT_EVENT_TYPE_KEY:
|
||||
// handle key input...
|
||||
break;
|
||||
} // end switch
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user