Fixed ifdefs (#91), added preliminary android support to vulkan example base (#97)

This commit is contained in:
saschawillems 2016-03-20 14:55:46 +01:00
parent 92cdb2060e
commit f13614e6d2
2 changed files with 64 additions and 27 deletions

View file

@ -13,8 +13,10 @@
#include <windows.h>
#include <fcntl.h>
#include <io.h>
#else
// todo : split linux xcb/x11 and android
#elif defined(__ANDROID__)
#include <android/native_activity.h>
#include "vulkanandroid.h"
#elif defined(__linux__)
#include <xcb/xcb.h>
#endif
@ -34,7 +36,9 @@
#include "vulkanswapchain.hpp"
#include "vulkanTextureLoader.hpp"
#ifndef __ANDROID__
#include "vulkanMeshLoader.hpp"
#endif
class VulkanExampleBase
{
@ -146,10 +150,12 @@ public:
} depthStencil;
// OS specific
#ifdef _WIN32
#if defined(_WIN32)
HWND window;
HINSTANCE windowInstance;
#else
#elif defined(__ANDROID__)
ANativeWindow* window;
#elif defined(__linux__)
struct {
bool left = false;
bool right = false;
@ -159,7 +165,7 @@ public:
xcb_screen_t *screen;
xcb_window_t window;
xcb_intern_atom_reply_t *atom_wm_delete_window;
#endif
#endif
VulkanExampleBase(bool enableValidation);
VulkanExampleBase() : VulkanExampleBase(false) {};
@ -168,15 +174,18 @@ public:
// Setup the vulkan instance, enable required extensions and connect to the physical device (GPU)
void initVulkan(bool enableValidation);
#ifdef _WIN32
#if defined(_WIN32)
void setupConsole(std::string title);
HWND setupWindow(HINSTANCE hinstance, WNDPROC wndproc);
void handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
#else
#elif defined(__ANDROID__)
// todo : add event handler for Android
#elif defined(__linux__)
xcb_window_t setupWindow();
void initxcbConnection();
void handleEvent(const xcb_generic_event_t *event);
#endif
// Pure virtual render function (override in derived class)
virtual void render() = 0;
// Called when view change occurs
@ -243,12 +252,14 @@ public:
VkDescriptorBufferInfo *descriptor);
// Load a mesh (using ASSIMP) and create vulkan vertex and index buffers with given vertex layout
// todo : mesh loader not yet enabled for Android
#ifndef __ANDROID__
void loadMesh(
const char *filename,
vkMeshLoader::MeshBuffer *meshBuffer,
std::vector<vkMeshLoader::VertexLayout> vertexLayout,
float scale);
#endif
// Start the main render loop
void renderLoop();