Coder Social home page Coder Social logo

linecode / xo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bmharper/xo

0.0 2.0 0.0 5.23 MB

A GPU-based cross-platform UI library

License: Other

Ruby 4.81% Shell 0.03% Batchfile 0.17% Lua 1.44% C 0.57% C++ 88.64% GLSL 2.76% HLSL 1.57%

xo's Introduction

xo

The idea behind xo is to take inspiration from the good parts of HTML/CSS, and use those to build a small cross-platform GUI framework that is usable from a compiled language, and statically linkable to build native applications for a wide range of platforms.

Some "native" applications actually use a browser as their presentation system, and many of these applications seem to use substantially more memory and CPU than I think is necessary. Part of the goal with this project is to allow you to build a lightweight application that launches instantly, consumes next to zero resources when idle, and has a small size footprint.

Using xo

The only platform that I'm actively working on right now is Windows Desktop. Every few months I make sure that Android and Linux (X11) still runs.

The easiest way to use xo is to build with the "amalgamation". The amalgamation is a set of 3 files:

  • xo-amalgamation.h
  • xo-amalgamation.cpp
  • xo-amalgamation-freetype.c

Simply add xo-amalgamation.cpp and xo-amalgamation-freetype.c into your project. If you are building a cross-platform application, and you want xo to handle the event loop for you, then you will need to include at least one other file (xoWinMain.cpp). On Android, there is a bit more stuff to add, such as JNI bindings.

The amalgamation is hosted here, but you can also build it yourself by running build\create-amalgamation.rb.

Building from full source

  • Install Visual Studio 2015, or GCC on Linux.
  • Install tundra2.

You should now be able to build and run:

tundra2 HelloWorld
t2-output\win64-msvc2015-debug-default\HelloWorld.exe

If you move the cursor around on the screen, then the green square and text will move with it.

There is another sample application called KitchenSink that stresses the layout system more.

If you change shaders, then you must run build\shaders.rb before building again.

Using Visual Studio

Tundra can generate Visual Studio IDE projects for you.
Use build\genide.bat to generate IDE projects that you can open in Visual Studio.

Design goals

  • Keep the entire library small. At last count, xo compiles to 220 KB of code, but dependencies such as Freetype bring the size up to around 2 MB.
  • Render the entire scene through the GPU (OpenGL ES 2.0, or DirectX 11).
  • Parallelize layout and rendering (the pre-GPU phases).
  • Strive to keep latency low.
  • Make it easy for games to integrate xo.
  • Separate the DOM manipulation and render threads. This allows animations to run on the render thread at 60 hz, while you're free to take significantly more time than 16ms to perform your computation and update the DOM. While a moot point for games, this has material benefits for non-realtime applications.
  • Try to come up with a re-imagined layout language that is simple and predictable.

Target platforms

  • Android
  • Linux
  • Windows Desktop
  • Windows Apps (not yet)
  • iOS (not yet)
  • OSX (not yet)

xo is written in C++, but it would be nice to have bindings from other languages.

Sample

auto btn = root->ParseAppendNode("<div class='button'>Click Me</div>");
btn->OnClick([btn]() { btn->SetText("You clicked me"); });

Status

You can build some basic things with xo. I have gone through three iterations of the layout system, and I think the current design is going to be OK. Windows Desktop support is good, but I haven't built Linux or Android in a long time, although there's nothing in principle preventing me reviving those platforms.

There is an OpenGL and a DirectX 11 backend, but when I moved over to an uber-shader, I only ported OpenGL, so DirectX needs work there.

  • Purely horizontal text is rendered well on Windows, where you typically have low resolution (< 100 dpi) monitors.

Why?

We want to write an application once, and have it run on many platforms. GUI is often the hardest thing to make cross platform. Browsers have become an excellent GUI system, but every now and then you're better suited by building a native application.

xo's People

Contributors

bmharper 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.