Git Product home page Git Product logo

nielsbishere / core Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 33.35 MB

Oxsomi Core - A basic library for (graphic) engines and applications. It is focussed on cross platform/API compatibility and providing a portable C++17 programming environment.

Home Page: https://core.osomi.com

License: Other

C++ 96.17% C 0.01% GLSL 0.73% CMake 1.53% Shell 1.57%
android vulkan graphics shaders glsl hlsl framework abstraction windows cross-platform cpp cmake-files

core's Introduction

OCore (Osomi Core)

Osomi Core - A basic framework for graphics and engines.

Build status & quality

Codacy Badge

Device Platform Status
Windows x86, x64, ARM32, ARM64 Build status
Android x86, x86_64, armeabi-v7a, arm64-v8a Build Status
Linux none no
Mac OS none no

Fetching from git

For fetching this repo and dependencies:

git clone --recurse-submodules -j8 git://github.com/osomilunar/ocore.git

Or for already cloned repos:

git submodule update --init --recursive 

Dependencies

The following dependencies are required for the entire project:

CMake 3.13.0 or later
Vulkan SDK 1.1.92.1 or later (ogc dependency)
Python 3.7.1 or later (SPIRV-Tools-opt dependency)

Windows

The project uses bash; Unix's built in scripting language. This means that you need to emulate Unix's functions and Unix Makefiles. This can be done by installing the Git BASH and Mingw-w64. Make sure that you use the Git BASH client, not Cygwin's bash; to force this, you can use bash -c "$cmd" where cmd is your command and bash is Git BASH; either through path variable or an absolute path.

Building using CMake

This project uses CMake and a few tools to help the user setup their environment.

Setting up a Windows environment

Dependencies

Visual Studio 2017

Environment variables

If you want to distribute the zip with x64 and x86 binaries, you require to have the msbuild command from vs17 available from command line. This means that you require to add the following path to your path environment variable:

<vs17dir>/MSBuild/15.0/Bin

Where vs17dir is the installation directory for Visual Studio 2017.

make_windows.sh

Packaging a Windows build will ensure that both x64 and x86 binaries are in the final zip. It will pull all required resources and put them next to the exe so it can run. This requires you to have access to msbuild.

# Don't package .fbx, .obj and .glsl/.hlsl/.vert/.frag./.comp/.geom files (only .oiSH and .oiRM)
# Release build without console (x64 & x86)
make_windows.sh -cmake -release -exclude_ext_formats -no_console

# Also strip debug info (so the shader source can't be reversed as easily)
# This saves disk space as well as securing the SPV-side of the oiSH file.
make_windows.sh -cmake -release -exclude_ext_formats -no_console -strip_debug_info

# Debug build; with all external formats & console & debug info (x64 & x86)
make_windows.sh -cmake

# Release build; with all external formats (x64 only; no console)
make_windows.sh -cmake -env=x64 -no_console

# Get more info about the command
make_windows.sh -help

This will generate a folder; builds/Windows/build, which includes the x86 and x64 binaries. If you include the -cmake flag, it will reload/initialize the CMake data; while adding -run will automatically run the project when it is done building. Don't include the CMake flag if you don't change the environment (you don't add source or include files or change build flags), since it will require the project to rebuild entirely or partly.

Setting up an Android environment

Dependencies

Android SDK & NDK
Java
Enable developer mode and USB debugging

Environment variables

Before you can use Android, you have to ensure that all variables are set correctly;

ANDROID_NDK (ndk directory)
ANDROID_SDK (sdk directory)
JAVA_HOME (jdk directory)

Setting up build env

# Setup a debug environment for all android ABIs, API lvl 24, windows environment
# Builds apk too
make_android.sh -cmake -apk -abi=windows-x86_64

# Setup for linux environment
# Which only compiles (doesn't create APK)
make_android.sh -cmake

# Release apk environment for windows; with only .oiRM models, .oiSH shaders, textures and settings and runs on connected device or emulator
make_android.sh -cmake -apk -run -abi=windows-x86_64 -release -exclude_ext_formats

# Exclude debug info from shaders
make_android.sh -cmake -apk -strip_debug_info

# Only build arm64-v8a debug for linux-x86_64
make_android.sh -cmake -apk -abi=arm64-v8a

# Get more info about the command
make_android.sh -help

On Linux, this might require you to chmod +x make_android.sh before you use it. The cmake flag is only needed when you need to update the CMake files; so either the environment changed (build flags & vars) or there were source files added; otherwise specifying it will cost extra compile time.

Running & building apk

Building a full APK file requires you to build architectures; arm64-v8a, armeabi-v7a, x86_64, x86, which means long compile times. Try to pick the ABI of your choosing (check your emulator or phone) and set the environment to build for that. When you specify -abi=x; it will mean that the APK will not run on all Android 7.0+ environments. By adding -run to the make_android command, it will try to run it automatically on a device; this could be an attached device or an emulator that is currently active. The apk flag will build your resources and sources into an apk file; without this it will only compile.

At the end of creating an APK; it will require you to create your own private cert for signing. Please make sure to make a backup of your ".keystore" file located in "builds/Android" if you want to keep updating this app and using the cert for release builds (like if you accidently remove the keystore). This step is required when you want to run your apk on any device, or publish it on the Play Store. Unsigned apks can't run on most devices (security) and won't get accepted into the Play Store. When you lose this cert, you can't update your apps anymore!

If there is no keystore setup yet, it will take you through the steps of setting it up. If you want to use an existing keystore, you can do that as well; as long as it has 1 entry.

# Step one; set your keystore password (at least 6 chars)
Enter keystore password: This is a test
Re-enter new password: This is a test

# Step two; enter the following info
What is your first and last name?
  [Unknown]:  John Doe
What is the name of your organizational unit?
  [Unknown]:  Lunar
What is the name of your organization?
  [Unknown]:  Osomi
What is the name of your City or Locality?
  [Unknown]:  Central City
What is the name of your State or Province?
  [Unknown]:  Ohio
What is the two-letter country code for this unit?
  [Unknown]:  OH
Is CN=John Doe, OU=Osomi, O=Osomi, L=Central City, ST=Ohio, C=OH correct?
  [no]:  yes
  
# Step three; set the password for the cert
Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
        for: CN=John Doe, OU=Osomi, O=Osomi, L=Central City, ST=Ohio, C=OH
Enter key password for <mykey>
        (RETURN if same as keystore password):
[Storing ../../.keystore]

If the keystore is setup (or you copied your own keystore inside of the Android build directory and named it .keystore). It will ask you for the password for the keystore.

Keystore password for signer #1:
This is a test

Baking all resources

If you want to bake the resources of your project (to get native resources), you can use the prepare_resources command:

# script
./prepare_resources.sh

# manual
cd app
"../oibaker.exe"
cd ../

oibaker compiles GLSL/HLSL files into oiSH (SPIRV and reflection) and fbx/obj to oiRM.

Note: oibaker is currently only available on Windows; but the baked resources are already uploaded to git.

How to use ocore in a project

If you want to use Osomi core for your project, you can go to your repo root directory. From there, you can add this repo as a dependency:

git submodule add https://github.com/osomilunar/ocore ocore
git submodule update --init --recursive 

This will fetch ocore into your project dir. Now you can include the subdirectory in CMake.

Please do yourself and us a favor and don't push this directory onto your repo, but instead use the submodule, so everyone gets ocore using our repo.

If you want to use ocore cross platform, it is recommended that you use the app entrypoints (app_pc, app_android, etc.).

Getting started

There is documentation on Osomi Graphics Core (ogc; rendering), Osomi Window Core (owc; window/app and input), Osomi STandard Library Core (ostlc; main data types and utils) and the top level entry app.

There's also documentation about the file formats used; oiSL (String List), oiSB (Shader Buffer), oiSH (SHader), oiRM (Raw Model), oiBM (BakeManager).

Shaders can be written through both GLSL, HLSL and our own shading format ogsl (Osomi Graphics Shading Language). ogsl allows transpiling shading languages to one-another and re-using the same shader code in hlsl/glsl files. ogsl might even allow compiling to C++ (for debugging) in the future.

Viewing progress

You can view progress and planned features on our trello board.

Special thanks

Koen for helping out with with Vulkan versioning/synchronization and GPU allocation.
Lagmeester4000 for reviewing CPU memory allocation code.
Velddev for creating a new logo.

core's People

Contributors

nielsbishere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

core's Issues

UEnum

UEnum class is bad; it just exists to supply the need for runtime enums. It should be changed ASAP; as running Release doesn't work. Since I'm using const char*, it crashes when trying to recreate the string that has already been deleted. It also doesn't allow for flexible referencing in compile time.

Integrade oish_gen into runtime version

oish_gen should be both compile and runtime; so hot loading is supported. Also; so any online source can be immediately converted. This will require the glslValidator to be added as well as the oish_gen base. Shader::compile(std::vector source) will be the runtime version; where 'source' contains every stages ShaderSource; a shader type bound to a String.

Design (security) flaw

Window::pause is used to determine if the window shouldn't continue updating. However, isFocus is called on pause, allowing the user of WindowInterface to call Window::pause(false) and prevent the update from stopping.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.