Merge branch 'master' into project_setup_refactor
# Conflicts: # 3rdParty/CMakeLists.txt # 3rdParty/libarchive/CMakeLists.txt # CMakeLists.txt
This commit is contained in:
@@ -3,15 +3,42 @@ cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
|
||||
include(SetupVulkan)
|
||||
include(Utils)
|
||||
|
||||
file(GLOB_RECURSE SUBDIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SUBDIRECTORIES})
|
||||
add_executable(examples main.cpp ${SUBDIRECTORIES})
|
||||
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
|
||||
if (IOS)
|
||||
file(GLOB_RECURSE SRC_IOS "${CMAKE_CURRENT_SOURCE_DIR}/Host/iOS/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/Host/iOS/*.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/Host/iOS/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Host/iOS/*.m" "${CMAKE_CURRENT_SOURCE_DIR}/Host/iOS/*.mm")
|
||||
list(APPEND SOURCES ${SRC_IOS})
|
||||
endif ()
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCES})
|
||||
|
||||
target_include_directories(examples PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(MAIN_FILE main.cpp)
|
||||
if (IOS)
|
||||
set(MAIN_FILE Host/iOS/main.mm)
|
||||
endif ()
|
||||
add_executable(OpenVulkano_Examples ${MAIN_FILE} ${SOURCES})
|
||||
set_property(TARGET OpenVulkano_Examples PROPERTY CXX_STANDARD 20)
|
||||
|
||||
target_include_directories(examples PRIVATE openVulkanoCpp)
|
||||
target_link_libraries(examples PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,openVulkanoCpp>")
|
||||
SetupVulkan(examples)
|
||||
SetGlmDefines(examples)
|
||||
SetWarningSettings(examples)
|
||||
LinkCurl(openVulkanoCpp)
|
||||
# Setup IOS
|
||||
if(IOS)
|
||||
set(APP_BUNDLE_IDENTIFIER "eu.georgh93.openVulkano")
|
||||
set(MACOSX_BUNDLE_INFO_STRING ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_BUNDLE_NAME ${APP_BUNDLE_IDENTIFIER})
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET})
|
||||
|
||||
set(CMAKE_XCODE_EMBED_FRAMEWORKS ON)
|
||||
|
||||
set_target_properties(OpenVulkano_Examples PROPERTIES XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "466MGSD624")
|
||||
endif()
|
||||
if(APPLE)
|
||||
LinkAppleFrameworks(OpenVulkano_Examples)
|
||||
endif ()
|
||||
|
||||
|
||||
|
||||
target_include_directories(OpenVulkano_Examples PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(OpenVulkano_Examples PRIVATE openVulkanoCpp)
|
||||
|
||||
target_link_libraries(OpenVulkano_Examples PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,openVulkanoCpp>")
|
||||
SetupVulkan(OpenVulkano_Examples)
|
||||
SetGlmDefines(OpenVulkano_Examples)
|
||||
SetWarningSettings(OpenVulkano_Examples)
|
||||
23
examples/ExampleAppList.hpp
Normal file
23
examples/ExampleAppList.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ExampleApps/CubesExampleApp.hpp"
|
||||
#include "ExampleApps/MovingCubeApp.hpp"
|
||||
#include "ExampleApps/TexturedCubeExampleApp.hpp"
|
||||
#include "ExampleApps/BillboardExampleApp.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
const std::vector<std::pair<const char*, IGraphicsApp*(*)()>> EXAMPLE_APPS = {
|
||||
{ "Cubes Example App", &CubesExampleApp::Create },
|
||||
{ "Moving Cube Example App", &MovingCubeApp::Create },
|
||||
{ "Textured Cube Example App", &TexturedCubeExampleApp::Create },
|
||||
{ "Billboard Example App", &BillboardExampleApp::Create }
|
||||
};
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace OpenVulkano
|
||||
|
||||
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::VERTEX, "Shader/billboardFromSinglePoint");
|
||||
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::GEOMETRY, "Shader/billboardFromSinglePoint");
|
||||
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/basicTexture");
|
||||
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/basic");
|
||||
m_quadBillboardShader.AddVertexInputDescription(OpenVulkano::Vertex::GetVertexInputDescription());
|
||||
m_quadBillboardShader.AddDescriptorSetLayoutBinding(Texture::DESCRIPTOR_SET_LAYOUT_BINDING);
|
||||
m_quadBillboardShader.AddDescriptorSetLayoutBinding(UniformBuffer::DESCRIPTOR_SET_LAYOUT_BINDING);
|
||||
|
||||
19
examples/Host/iOS/ExampleViewController.h
Normal file
19
examples/Host/iOS/ExampleViewController.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "Host/iOS/OpenVulkanoViewController.h"
|
||||
|
||||
@interface MainMenuViewController : UIViewController
|
||||
@end
|
||||
|
||||
@interface ExampleViewController : OpenVulkanoViewController
|
||||
@property(nonatomic, strong)OpenVulkanoView* renderView;
|
||||
@property size_t exampleId;
|
||||
@end
|
||||
75
examples/Host/iOS/ExampleViewController.mm
Normal file
75
examples/Host/iOS/ExampleViewController.mm
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#import "ExampleViewController.h"
|
||||
|
||||
#include "../../ExampleAppList.hpp"
|
||||
|
||||
@implementation MainMenuViewController
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
CGFloat buttonHeight = 50;
|
||||
CGFloat buttonSpacing = 10;
|
||||
CGFloat topMargin = 50;
|
||||
|
||||
int i = 0;
|
||||
for (const auto& app : OpenVulkano::EXAMPLE_APPS)
|
||||
{
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
button.frame = CGRectMake(20,
|
||||
topMargin + i * (buttonHeight + buttonSpacing),
|
||||
self.view.bounds.size.width - 40,
|
||||
buttonHeight);
|
||||
[button setTitle:[NSString stringWithUTF8String:app.first] forState:UIControlStateNormal];
|
||||
button.tag = i;
|
||||
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:button];
|
||||
i++;
|
||||
}
|
||||
|
||||
self.view.frame = [UIScreen mainScreen].bounds;
|
||||
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
}
|
||||
|
||||
- (void)buttonPressed:(UIButton *)sender {
|
||||
ExampleViewController* example = [[ExampleViewController alloc] init];
|
||||
example.exampleId = sender.tag;
|
||||
example.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
[self presentViewController:example animated:true completion:nil];
|
||||
}
|
||||
|
||||
- (void)viewDidLayoutSubviews {
|
||||
[super viewDidLayoutSubviews];
|
||||
self.view.frame = self.view.superview.bounds;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation ExampleViewController
|
||||
- (void)viewDidLoad {
|
||||
self.renderView = [[OpenVulkanoView alloc] initWithFrame:self.view.frame];
|
||||
self.openVulkanoView = self.renderView;
|
||||
[self.view addSubview:self.renderView];
|
||||
[super viewDidLoad];
|
||||
|
||||
self.view.frame = [UIScreen mainScreen].bounds;
|
||||
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
}
|
||||
|
||||
- (void)viewDidLayoutSubviews {
|
||||
[super viewDidLayoutSubviews];
|
||||
self.view.frame = self.view.superview.bounds;
|
||||
self.renderView.frame = self.view.frame;
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden { return true; }
|
||||
|
||||
- (void *)makeGraphicsApp {
|
||||
return OpenVulkano::EXAMPLE_APPS[self.exampleId].second();
|
||||
}
|
||||
@end
|
||||
57
examples/Host/iOS/main.mm
Normal file
57
examples/Host/iOS/main.mm
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ExampleViewController.h"
|
||||
#import "Host/iOS/OpenVulkanoAppDelegate.h"
|
||||
|
||||
#include "Base/Logger.hpp"
|
||||
|
||||
@interface SceneDelegate : UIResponder<UIWindowSceneDelegate>
|
||||
@end
|
||||
|
||||
@implementation SceneDelegate
|
||||
@synthesize window = _window;
|
||||
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
|
||||
if ([scene isKindOfClass:[UIWindowScene class]]) {
|
||||
UIWindowScene* wScene = (UIWindowScene*)scene;
|
||||
self.window = [[UIWindow alloc] initWithWindowScene:wScene];
|
||||
|
||||
MainMenuViewController* rootViewController = [[MainMenuViewController alloc] init];
|
||||
UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
|
||||
|
||||
self.window.rootViewController = navigationController;
|
||||
[self.window makeKeyAndVisible];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@interface AppDelegate : OpenVulkanoAppDelegate
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
|
||||
UISceneConfiguration *configuration = [[UISceneConfiguration alloc] initWithName:nil sessionRole:UIWindowSceneSessionRoleApplication];
|
||||
configuration.delegateClass = SceneDelegate.class;
|
||||
return configuration;
|
||||
}
|
||||
@end
|
||||
|
||||
int main(int argCount, char** args)
|
||||
{
|
||||
using namespace OpenVulkano;
|
||||
Logger::SetupLogger();
|
||||
@autoreleasepool
|
||||
{
|
||||
return UIApplicationMain(argCount, args, nil, NSStringFromClass([AppDelegate class]));
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "Host/GraphicsAppManager.hpp"
|
||||
#include "ExampleApps/CubesExampleApp.hpp"
|
||||
#include "ExampleApps/MovingCubeApp.hpp"
|
||||
#include "ExampleApps/TexturedCubeExampleApp.hpp"
|
||||
#include "ExampleApps/BillboardExampleApp.hpp"
|
||||
#include "ExampleAppList.hpp"
|
||||
|
||||
#include <ftxui/component/captured_mouse.hpp>
|
||||
#include <ftxui/component/component.hpp>
|
||||
@@ -22,12 +19,11 @@ using namespace OpenVulkano;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::vector<std::string> examples = {
|
||||
"Cubes Example App",
|
||||
"Moving Cube Example App",
|
||||
"Textured Cube Example App",
|
||||
"Billboard Example App"
|
||||
};
|
||||
std::vector<std::string> examples;
|
||||
for (const auto& e : EXAMPLE_APPS)
|
||||
{
|
||||
examples.emplace_back(e.first);
|
||||
}
|
||||
|
||||
int selectedExample = 0;
|
||||
ftxui::MenuOption option;
|
||||
@@ -37,15 +33,9 @@ int main(int argc, char** argv)
|
||||
|
||||
screen.Loop(menu);
|
||||
|
||||
std::unique_ptr<IGraphicsApp> app;
|
||||
switch (selectedExample)
|
||||
{
|
||||
case 0: app = CubesExampleApp::CreateUnique(); break;
|
||||
case 1: app = MovingCubeApp::CreateUnique(); break;
|
||||
case 2: app = TexturedCubeExampleApp::CreateUnique(); break;
|
||||
case 3: app = BillboardExampleApp::CreateUnique(); break;
|
||||
default: throw std::runtime_error("Invalid menu selection!"); break;
|
||||
}
|
||||
if (selectedExample >= examples.size()) throw std::runtime_error("Invalid menu selection!");
|
||||
|
||||
std::unique_ptr<IGraphicsApp> app( EXAMPLE_APPS[selectedExample].second() );
|
||||
|
||||
GraphicsAppManager manager(app.get());
|
||||
manager.Run();
|
||||
|
||||
Reference in New Issue
Block a user