Git Product home page Git Product logo

okui's Introduction

โœจ OkUI โœจ Build Status Apache 2.0 License

OkUI is an OpenGL-based framework for creating portable user interfaces, with a focus on performance and portability. We think it's pretty okay. ๐Ÿ‘Œ

Features

  • ๐Ÿš€ Fast: Intelligently caches and efficiently renders views to ensure that your UI remains fast regardless of complexity. If you aren't getting 60 FPS on anything remotely modern, open an issue.
  • ๐Ÿ‘œ Portable: At its core, OkUI is a collection of OpenGL abstractions and shaders. Supporting new platforms should require very few code changes.
  • ๐Ÿ’ซ Markup Language: Implement interfaces with an XML language instead of code. You'll still get the same great performance, but be able to iterate on designs without recompiling or remotely deploy interface updates!
  • โ™ ๏ธ Distance Field Rendering: Render icons, glyphs, and text with signed distance fields that scale beautifully to large sizes and enable effects such as outlines and glows. See the Valve paper.

Platform Support

Officially, Android, iOS, tvOS, and MacOS are supported, but it can probably be made to work on anything that you can build for in a linux-like environment. Official Windows support is a work-in-progress.

Quick Start

Prerequisites

You'll need to install these yourself if you don't have them already.

  • The pyyaml and jinja2 Python packages are used by Needy for our dependency configuration.
  • git is used to retrieve several of our dependencies.
  • pkg-config is used to integrate our dependencies.
  • clang and libc++ are required to compile.
  • libz is required by Curl.
  • OpenGL is required by OkUI.

These things must be installed before continuing.

Compiling

First, make sure you initialize all of the submodules: git submodule update --recursive --init

We use a three-step build system:

  • ๐Ÿ“ฆ ./build-deps will download and build all of OkUI's dependencies.
  • ๐Ÿ“‹ ./configure will generate some essential build files based on your environment and the result of the previous step.
  • ๐Ÿ’ฅ ./b2 will build the library. If you'd like, you can install it via ./b2 install --prefix=./my/okui/destination. See the Boost.Build documentation for more help.

Hello World

There is a "hello world" project in the examples directory. You can compile it like so:

./b2 ./examples/hello-world

The output binary will be placed in examples/hello-world/bin:

$(find examples/hello-world/bin -name hello-world)

This will open up a new window that renders the text "Hello, world!" using a signed distance field bitmap font:

Hello, world!

Project Structure

Generally, projects that use OkUI are structured like this:

int main(int argc, const char* argv[]) {
    /**
    * All application state is managed by an object that implements
    * okui::Application. This application class is where you customize
    * application-wide behavior including such as resource management and
    * rendering engine.
    */
    MyApplication application;

    /**
    * Windows are implementations of okui::Window. They create the OpenGL view
    * that your UI will be rendered in.
    */
    MyWindow window{&application};
    window.open();

    /**
    * okui::Application::run executes the main run loop and returns only when
    * the application is shutting down.
    */
    application.run();

    return 0;
}

Once you have a window, you can implement your UI by creating instances of okui::View. They follow this sort of structure:

class MyView : public okui::View {
public:
    /**
    * Constructors can create and add subviews.
    */
    MyView() {
        _logo.setTexture("logo.png");
        addSubview(&_logo);
    }

    /**
    * The okui::View::layout method can be overridden to define the layout of
    * the view's subviews. This method is invoked whenever any ancestor is
    * resized and the layout may need to be recomputed.
    */
    virtual void layout() override {
        _logo.setBounds(0, 0, bounds().width, bounds().height);
    }
private:
    okui::views::ImageView _logo;
}

Your topmost views can be added to a window by adding them to the window's content view:

MyWindow(okui::Application* application) : okui::Window{application} {
    contentView()->addSubview(&myView);
}

See the examples directory for more sample code.

Generating Bitmap Fonts

It's recommended that bitmap fonts be generated with Hiero, a tool distributed with libGDX.

Generating SDF Images

Distance field images can be generated by this tool:

https://github.com/Chlumsky/msdfgen

OkUI expects the distance field to be in the alpha channel, so you'll need to convert the output of that to the alpha channel of a white image (In Pixelmator, all you have to do is double click the "Mask to Alpha" effect.).

okui's People

Contributors

ccbrown avatar mnbittorrent avatar

Watchers

 avatar  avatar

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.