Added Integration hints
This commit is contained in:
parent
5d0c2caf78
commit
dd8fbe4c2f
|
@ -1,3 +1,5 @@
|
|||
# Krimi Dinner Engine
|
||||
|
||||
Source code für die Krimi Dinner Engine.
|
||||
In app/src/main/cpp/NativeEngine.cpp sind Kommentare (beginnend mit INTEGRATION), die erklären, wie
|
||||
das Spiel integriert werden kann.
|
|
@ -40,13 +40,28 @@ NativeEngine::NativeEngine(struct android_app *app)
|
|||
|
||||
AssetManager::create(m_app->activity->assetManager);
|
||||
|
||||
|
||||
// INTEGRATION
|
||||
// Hier kannst du Initialisierungscode aufrufen.
|
||||
// Beachte das Renderer noch _nicht_ gültig ist.
|
||||
// Der Renderer wird erst während des ersten Frames erzeugt.
|
||||
//
|
||||
// Du kannst schon Assets laden, da oben der AssetManager erzeugt wurde.
|
||||
|
||||
// BEISPIELCODE
|
||||
m_smiley = StringRepository::global->internString("smiley_PNG42.png");
|
||||
m_smiley_pos = { 100, 100 };
|
||||
// ENDE VOM BEISPIELCODE
|
||||
}
|
||||
|
||||
NativeEngine::~NativeEngine()
|
||||
{
|
||||
ALOGI("NativeEngine: destructor");
|
||||
|
||||
// INTEGRATION
|
||||
// Hier könntest du eine "onExit" funktion aufrufen
|
||||
//
|
||||
|
||||
SwappyGL_destroy();
|
||||
killContext();
|
||||
if (m_jni_env) {
|
||||
|
@ -144,6 +159,21 @@ void NativeEngine::gameLoop()
|
|||
}
|
||||
|
||||
if (isAnimating() && Renderer::ptr) {
|
||||
// INTEGRATION Rufe hier deine "gameloop"/"update" funktion auf, die als Parameter
|
||||
// input_events und input_event_count bekommen sollte.
|
||||
// Außerdem stehen m_display_width und m_display_height zur Verfügung:
|
||||
//
|
||||
// kUpdate(input_events, input_event_count, m_display_width, m_display_height)
|
||||
//
|
||||
//
|
||||
// Die Funktion könnte folgende Definition haben:
|
||||
// void kUpdate(const TouchInputEvent* touch_events,
|
||||
// unsigned int touch_event_count,
|
||||
// float display_width,
|
||||
// float display_height)
|
||||
|
||||
|
||||
// BEISPIELCODE
|
||||
static float x = 1.f;
|
||||
static float d = -0.01f;
|
||||
x += d;
|
||||
|
@ -152,7 +182,6 @@ void NativeEngine::gameLoop()
|
|||
else if (x >= 1.f)
|
||||
d *= -1.f;
|
||||
|
||||
|
||||
if (input_event_count > 0) {
|
||||
m_smiley_pos = input_events[input_event_count - 1].end;
|
||||
m_smiley_pos.x -= 250;
|
||||
|
@ -161,6 +190,7 @@ void NativeEngine::gameLoop()
|
|||
|
||||
Renderer::ptr->addRect(100, 100, 500, 500, 0.3f, 0.3f, 0.3f, 1.f);
|
||||
Renderer::ptr->addRect(m_smiley_pos.x, m_smiley_pos.y, 500, 500, 0.f, x*x, 1.f - x*x, 1.f, m_smiley);
|
||||
// ENDE VOM BEISPIELCODE
|
||||
}
|
||||
|
||||
if (isAnimating()) {
|
||||
|
@ -402,7 +432,10 @@ void NativeEngine::renderFrame()
|
|||
eglQuerySurface(m_egl_display, m_egl_surface, EGL_WIDTH, &width);
|
||||
eglQuerySurface(m_egl_display, m_egl_surface, EGL_HEIGHT, &height);
|
||||
|
||||
Renderer::ptr->renderFrame(static_cast<float>(width), static_cast<float>(height));
|
||||
m_display_width = static_cast<float>(width);
|
||||
m_display_height = static_cast<float>(height);
|
||||
|
||||
Renderer::ptr->renderFrame(m_display_width, m_display_height);
|
||||
|
||||
if (!SwappyGL_swap(m_egl_display, m_egl_surface)) {
|
||||
ALOGW("NativeEngine: SwappyGL_swap failed, EGL error %d", eglGetError());
|
||||
|
|
|
@ -59,6 +59,9 @@ private:
|
|||
EGLContext m_egl_context;
|
||||
EGLConfig m_egl_config;
|
||||
|
||||
float m_display_width;
|
||||
float m_display_height;
|
||||
|
||||
StringHandle m_smiley;
|
||||
Position m_smiley_pos;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user