-
Notifications
You must be signed in to change notification settings - Fork 637
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Platform Context * fix sample warning * reset open_cl_interop * fix android build * review changes * macro fixes
- Loading branch information
1 parent
8ea55cc
commit 4a18567
Showing
37 changed files
with
868 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (c) 2023, Thomas Atkinson | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 the "License"; | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
vkb__register_component( | ||
NAME android_platform | ||
HEADERS | ||
include/android/context.hpp | ||
SRC | ||
src/context.cpp | ||
src/entrypoint.cpp | ||
LINK_LIBS | ||
vkb__core | ||
) | ||
|
||
add_definitions(-DVULKAN_HPP_TYPESAFE_CONVERSION=1) | ||
|
||
# Import game-activity static lib inside the game-activity_static prefab module. | ||
find_package(game-activity REQUIRED CONFIG) | ||
target_link_libraries(vkb__android_platform PUBLIC log android game-activity::game-activity_static) | ||
|
||
# attach to core | ||
target_link_libraries(vkb__core INTERFACE vkb__android_platform) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* Copyright (c) 2023, Thomas Atkinson | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 the "License"; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include <core/platform/context.hpp> | ||
|
||
#include <game-activity/native_app_glue/android_native_app_glue.h> | ||
|
||
namespace vkb | ||
{ | ||
/** | ||
* @brief Android platform context | ||
* | ||
* @warning Use in extreme circumstances with code guarded by the PLATFORM__ANDROID define | ||
*/ | ||
class AndroidPlatformContext final : public PlatformContext | ||
{ | ||
public: | ||
AndroidPlatformContext(android_app *app); | ||
~AndroidPlatformContext() override = default; | ||
|
||
android_app *app{nullptr}; | ||
|
||
static std::string android_external_storage_directory; | ||
static std::string android_temp_directory; | ||
static std::vector<std::string> android_arguments; | ||
}; | ||
} // namespace vkb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* Copyright (c) 2023, Thomas Atkinson | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 the "License"; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "android/context.hpp" | ||
|
||
#include <jni.h> | ||
|
||
extern "C" | ||
{ | ||
JNIEXPORT void JNICALL | ||
Java_com_khronos_vulkan_1samples_SampleLauncherActivity_initFilePath(JNIEnv *env, jobject thiz, jstring external_dir, jstring temp_dir) | ||
{ | ||
const char *external_dir_cstr = env->GetStringUTFChars(external_dir, 0); | ||
vkb::AndroidPlatformContext::android_external_storage_directory = std::string(external_dir_cstr) + "/"; | ||
env->ReleaseStringUTFChars(external_dir, external_dir_cstr); | ||
|
||
const char *temp_dir_cstr = env->GetStringUTFChars(temp_dir, 0); | ||
vkb::AndroidPlatformContext::android_temp_directory = std::string(temp_dir_cstr) + "/"; | ||
env->ReleaseStringUTFChars(temp_dir, temp_dir_cstr); | ||
} | ||
|
||
JNIEXPORT void JNICALL | ||
Java_com_khronos_vulkan_1samples_SampleLauncherActivity_sendArgumentsToPlatform(JNIEnv *env, jobject thiz, jobjectArray arg_strings) | ||
{ | ||
std::vector<std::string> args; | ||
|
||
for (int i = 0; i < env->GetArrayLength(arg_strings); i++) | ||
{ | ||
jstring arg_string = (jstring) (env->GetObjectArrayElement(arg_strings, i)); | ||
|
||
const char *arg = env->GetStringUTFChars(arg_string, 0); | ||
|
||
args.push_back(std::string(arg)); | ||
|
||
env->ReleaseStringUTFChars(arg_string, arg); | ||
} | ||
|
||
vkb::AndroidPlatformContext::android_arguments = args; | ||
} | ||
} | ||
|
||
namespace vkb | ||
{ | ||
std::string AndroidPlatformContext::android_external_storage_directory = {}; | ||
std::string AndroidPlatformContext::android_temp_directory = {}; | ||
std::vector<std::string> AndroidPlatformContext::android_arguments = {}; | ||
|
||
AndroidPlatformContext::AndroidPlatformContext(android_app *app) : | ||
PlatformContext{}, app{app} | ||
{ | ||
_external_storage_directory = android_external_storage_directory; | ||
_temp_directory = android_temp_directory; | ||
_arguments = android_arguments; | ||
} | ||
} // namespace vkb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* Copyright (c) 2023, Thomas Atkinson | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 the "License"; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <core/platform/entrypoint.hpp> | ||
|
||
#include "android/context.hpp" | ||
|
||
std::unique_ptr<vkb::PlatformContext> create_platform_context(android_app *app) | ||
{ | ||
return std::make_unique<vkb::AndroidPlatformContext>(app); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.