added asset loading class, zoom factor, vbo switch, shader version
This commit is contained in:
@@ -27,6 +27,7 @@ add_library(
|
||||
src/main/cpp/main.cpp
|
||||
../engine/pch.cpp
|
||||
../engine/util.cpp
|
||||
../engine/asset.cpp
|
||||
../engine/image.cpp
|
||||
../engine/texture.cpp
|
||||
../engine/font.cpp
|
||||
|
||||
3
android/build-run.bat
Normal file
3
android/build-run.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
call gradlew installDebug
|
||||
call adb shell am start -n com.omigamedev/android.app.NativeActivity
|
||||
pause
|
||||
@@ -9,10 +9,13 @@ buildscript {
|
||||
apply plugin: 'android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 'android-19'
|
||||
buildToolsVersion '24.0.3'
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '23.0.2'
|
||||
|
||||
defaultConfig {
|
||||
applicationId = 'com.omigamedev'
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 23
|
||||
// This block is different from the one you use to link Gradle
|
||||
// to your CMake or ndk-build script.
|
||||
externalNativeBuild {
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must *NOT* be checked into Version Control Systems,
|
||||
# as it contains information specific to your local configuration.
|
||||
|
||||
# location of the SDK. This is only used by Ant
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
sdk.dir=/Users/omimac/android-sdk-macosx
|
||||
ndk.dir=/Users/omimac/android-ndk-r13
|
||||
@@ -3,11 +3,17 @@
|
||||
package="com.omigamedev"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:allowBackup="false"
|
||||
android:hasCode="false"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
|
||||
<activity android:name="android.app.NativeActivity"
|
||||
android:label="@string/app_name">
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:screenOrientation="sensorLandscape">
|
||||
<meta-data android:name="android.app.lib_name"
|
||||
android:value="native-lib" />
|
||||
android:value="native-lib" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">DummyActivity</string>
|
||||
<string name="app_name">LayoutEngine</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user