All Projects → alaingalvan → Crosswindow

alaingalvan / Crosswindow

Licence: mit
💻📱 A cross platform system abstraction library written in C++ for managing windows and performing OS tasks.

Projects that are alternatives of or similar to Crosswindow

Engine
A basic cross-platform 3D game engine
Stars: ✭ 208 (+34.19%)
Mutual labels:  cmake, emscripten, cross-platform
Wxwidgets
wxWidgets is a free and open source cross-platform C++ framework for writing advanced GUI applications using native controls.
Stars: ✭ 3,994 (+2476.77%)
Mutual labels:  cross-platform, win32, cocoa
Imguizmo.quat
ImGui GIZMO widget - 3D object manipulator / orientator
Stars: ✭ 187 (+20.65%)
Mutual labels:  cmake, emscripten, webassembly
Dcmjs
dcmjs is a javascript cross-compile of dcmtk (dcmtk.org).
Stars: ✭ 92 (-40.65%)
Mutual labels:  cmake, emscripten, webassembly
Magnum Bootstrap
Bootstrap projects for Magnum C++11/C++14 graphics engine
Stars: ✭ 69 (-55.48%)
Mutual labels:  cmake, emscripten, webassembly
Magnum Examples
Examples for the Magnum C++11/C++14 graphics engine
Stars: ✭ 180 (+16.13%)
Mutual labels:  cmake, emscripten, webassembly
Magnum
Lightweight and modular C++11 graphics middleware for games and data visualization
Stars: ✭ 3,728 (+2305.16%)
Mutual labels:  cmake, emscripten, webassembly
Uikit Cross Platform
Cross-platform Swift implementation of UIKit, mostly for Android
Stars: ✭ 421 (+171.61%)
Mutual labels:  cmake, cross-platform, uikit
Magnum Plugins
Plugins for the Magnum C++11/C++14 graphics engine
Stars: ✭ 66 (-57.42%)
Mutual labels:  cmake, emscripten, webassembly
Uno
Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
Stars: ✭ 6,029 (+3789.68%)
Mutual labels:  cross-platform, webassembly, uwp
Opengl cmake skeleton
❤️ A ready to use cmake skeleton using GLFW, Glew and glm. 👍
Stars: ✭ 118 (-23.87%)
Mutual labels:  cmake, emscripten, webassembly
Arcgis Appstudio Samples
Collection of samples available in AppStudio for ArcGIS desktop to learn and help build your next app.
Stars: ✭ 78 (-49.68%)
Mutual labels:  cross-platform, uwp, win32
Modern Wasm Starter
🛸 Run C++ code on web and create blazingly fast websites! A starter template to easily create WebAssembly packages using type-safe C++ bindings with automatic TypeScript declarations.
Stars: ✭ 140 (-9.68%)
Mutual labels:  cmake, emscripten, webassembly
Assortedwidgets
OpenGL GUI library
Stars: ✭ 92 (-40.65%)
Mutual labels:  emscripten, webassembly
Reactivemvvm
Cross-platform ReactiveUI sample app built for a talk at MSK .NET conf.
Stars: ✭ 94 (-39.35%)
Mutual labels:  cross-platform, uwp
Cobol Js Emscripten
Stars: ✭ 101 (-34.84%)
Mutual labels:  emscripten, webassembly
Emscripten Docker
Docker image with Emscripten to compile ASM.js and WebAssembly
Stars: ✭ 92 (-40.65%)
Mutual labels:  emscripten, webassembly
Essentials
Essential cross platform APIs for your mobile apps.
Stars: ✭ 1,344 (+767.1%)
Mutual labels:  cross-platform, uwp
Webassembly Raytracer
a performance comparison of a simple raytracer in JavaScript, asm.js, WebAssembly, and GLSL
Stars: ✭ 102 (-34.19%)
Mutual labels:  emscripten, webassembly
Caveexpress
CaveExpress is a classic 2D platformer with physics-based gameplay and dozens of levels. CavePacker is a Sokoban game.
Stars: ✭ 111 (-28.39%)
Mutual labels:  cmake, emscripten

Logo

CrossWindow

cmake-img License Travis Tests Appveyor Tests Coverage Tests

A basic cross platform system abstraction library for managing windows and performing OS tasks.

Features

  • 🌟 Simple Window, File Dialog, and Message Dialog Creation

  • ⌨️ 🖱️ 👆 🎮 Basic Input (Keyboard, Mouse, Touch, and Gamepad)

  • 👻 Platform specific features (Mac Transparency, Mobile Accelerometer, etc.)

  • 💊 Unit Tests + Test Coverage (Appveyor for Windows, CircleCI for Android / MacOS / iOS, Travis for Linux/Noop)

  • 😎 Well maintained C++ 11, with a promise to evolve as the standard evolves. (C++ Modules, Package Managers, etc.)

Supported Platforms

  • 🖼️ Windows (Win32)

  • 🍎 Mac (Cocoa)

  • 📱 iOS (UIKit) (Currently working, but missing some functionality)

  • 🐧 Linux (XCB) (In Progress)

  • 🤖 Android (In Progress)

  • 🌐 WebAssembly (Currently working, but missing some functionality)

  • ❌ Noop (Headless)

Installation

First add the repo as a submodule in your dependencies folder such as external/:

cd external
git submodule add https://github.com/alaingalvan/crosswindow.git

Then in your CMakeLists.txt file, include the following:

# ⬇ Add your dependency:
add_subdirectories(external/crosswindow)

# ❎ When creating your executable use CrossWindow's abstraction function:
xwin_add_executable(
    # Target
    ${PROJECT_NAME}
    # Source Files (make sure to surround in quotations so CMake treats it as a list)
    "${SOURCE_FILES}"
)

# 🔗 Link CrossWindow to your project:
target_link_libraries(
    ${PROJECT_NAME}
    CrossWindow
)

Fill out the rest of your CMakeLists.txt file with any other source files and dependencies you may have, then in your project root:

# 👷 Make a build folder
mkdir build
cd build

# 🖼️ To build your Visual Studio solution on Windows x64
cmake .. -A x64

# 🍎 To build your XCode project On Mac OS for Mac OS
cmake .. -G Xcode

# 📱 To build your XCode project on Mac OS for iOS / iPad OS / tvOS / watchOS
cmake .. -G Xcode -DCMAKE_SYSTEM_NAME=iOS

# 🐧 To build your .make file on Linux
cmake ..

# 🔨 Build on any platform:
cmake --build .

For WebAssembly you'll need to have Emscripten installed. Assuming you have the SDK installed, do the following to build a WebAssembly project:

# 🌐 For WebAssembly Projects
mkdir webassembly
cd webassembly
cmake .. -DXWIN_OS=WASM -DCMAKE_TOOLCHAIN_FILE="$EMSDK/emscripten/1.38.1/cmake/Modules/Platform/Emscripten.cmake" -DCMAKE_BUILD_TYPE=Release

# Run emconfigure with the normal configure command as an argument.
$EMSDK/emscripten/emconfigure ./configure

# Run emmake with the normal make to generate linked LLVM bitcode.
$EMSDK/emscripten/emmake make

# Compile the linked bitcode generated by make (project.bc) to JavaScript.
#  'project.bc' should be replaced with the make output for your project (e.g. 'yourproject.so')
$EMSDK/emscripten/emcc project.bc -o project.js

For more information visit the Emscripten Docs on CMake.

For Android Studio you'll need to make a project, then edit your build.gradle file.

// 🤖 To build your Android Studio project
android {
    ...
    externalNativeBuild {
        cmake {
            ...
            // Use the following syntax when passing arguments to variables:
            // arguments "-DVAR_NAME=ARGUMENT".
            arguments "-DXWIN_OS=ANDROID",
            // The following line passes 'rtti' and 'exceptions' to 'ANDROID_CPP_FEATURES'.
            "-DANDROID_CPP_FEATURES=rtti exceptions"
        }
    }
  buildTypes {...}

  // Use this block to link Gradle to your CMake build script.
  externalNativeBuild {
    cmake {...}
  }
}

for more information visit Android Studio's docs on CMake.

Usage

Then create a main delegate function void xmain(int argc, const char** argv) in a .cpp file in your project (for example "XMain.cpp") where you'll put your application logic:

#include "CrossWindow/CrossWindow.h"

void xmain(int argc, const char** argv)
{
    // 🖼️ Create Window Description
    xwin::WindowDesc windowDesc;
    windowDesc.name = "Test";
    windowDesc.title = "My Title";
    windowDesc.visible = true;
    windowDesc.width = 1280;
    windowDesc.height = 720;

    bool closed = false;

    // 🌟 Initialize
    xwin::Window window;
    xwin::EventQueue eventQueue;

    if (!window.create(windowDesc, eventQueue))
    { return; }

    // 🏁 Engine loop
    bool isRunning = true;

    while (isRunning)
    {
        // ♻️ Update the event queue
        eventQueue.update();

        // 🎈 Iterate through that queue:
        while (!eventQueue.empty())
        {
            const xwin::Event& event = eventQueue.front();

            if (event.type == xwin::EventType::Mouse)
            {
                const xwin::MouseData mouse = event.data.mouse;
            }
            if (event.type == xwin::EventType::Close)
            {
                window.close();
                isRunning = false;
            }

            eventQueue.pop();
        }
    }
}

This xmain function will be called from a platform specific main function that will be included in your main project by CMake. If you ever need to access something from the platform specific main function for whatever reason, you'll find it in xwin::getXWinState().

For more examples visit the Documentation or try out the examples.

Development

Be sure to have CMake Installed.

CMake Options Description
XWIN_TESTS Whether or not unit tests are enabled. Defaults to OFF, Can be ON or OFF.
XWIN_API The OS API to use for window generation, defaults to AUTO, can be can be NOOP, WIN32, COCOA, UIKIT, XCB , ANDROID, or WASM.
XWIN_OS Optional - What Operating System to build for, functions as a quicker way of setting target platforms. Defaults to AUTO, can be NOOP, WINDOWS, MACOS, LINUX, ANDROID, IOS, WASM. If your platform supports multiple apis, the final api will be automatically set to CrossWindow defaults ( WIN32 on Windows, XCB on Linux ). If XWIN_API is set this option is ignored.

First install Git, then open any terminal such as Hyper in any folder and type:

# 🐑 Clone the repo
git clone https://github.com/alaingalvan/crosswindow.git --recurse-submodules

# 💿 go inside the folder
cd crosswindow

# 👯 If you forget to `recurse-submodules` you can always run:
git submodule update --init

From there we'll need to set up our build files. Be sure to have the following installed:

Then type the following in your terminal from the repo folder:

# 👷 Make a build folder
mkdir build
cd build

# 🖼️ To build your Visual Studio solution on Windows x64
cmake .. -A x64 -DXWIN_TESTS=ON

# 🍎 To build your XCode project on Mac OS
cmake .. -G Xcode -DXWIN_TESTS=ON

# 🐧 To build your .make file on Linux
cmake .. -DXWIN_TESTS=ON

# 🔨 Build on any platform:
cmake --build .

Whenever you add new files to the project, run cmake .. from your solution/project folder, and if you edit the CMakeLists.txt file be sure to delete the generated files and run Cmake again.

Project Goals

  • [ ] 🚜 XLib / Wayland support for Linux

  • [ ] ❎ Windows 10 Apps / Window 10 Arm / Xbox One support with Universal Windows Platform (WMP).

  • [ ] 🍭 Linux flavor OS targets (XWIN_OS can be UBUNTU, DEBIAN, FEDORA, etc.)

  • [ ] 🅿️ Playstation support

  • [ ] 💞 Nintendo support

License

CrossWindow is licensed as either MIT or Apache-2.0, whichever you would prefer.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].