Git Product home page Git Product logo

glesjs's Introduction

GLES.JS - Fast and small Android WebGL bindings for V8

Copyright (c) 2015 by Boris van Schooten ( tmtg.net / [email protected]). Released under revised BSD license. See LICENSE for details.

Gles.js provides Android WebGL bindings for the Javascript V8 engine (ARMv7 architecture). WebGL is directly translated to OpenGL ES, providing what is probably the fastest and smallest engine for running HTML5 games currently available on Android. APK footprint is about 1.5 Mb.

A minimalist HTML5 API emulation is provided. While only a single Canvas element is fully emulated, there is limited support for handling HTML and XML structures and a fake API for the most common things that HTML5 apps do.

Workflow

  1. put your webpage and all resources, like scripts and images, in assets/. Gles.js expects index.html to be present, from which the rest is loaded. html5.js must be present in assets/, which is the bootloader for everything else.

  2. compile using the standard Android SDK method, 'ant release'. This will package everything into an APK, which is found in bin/.

Setting up (command line)

These instructions assume you are using the command line to build. For now you will need an old version of the Android SDK (before Ant support was removed). To set it up, install Apache Ant and the latest version of Android SDK with Ant support (which is R25-2.5).

Linux Windows Mac

Within the Android SDK package manager, install API level 17, which is the minimum that handles leanback/TV applications. If you don't use this, you can go down to API level 14, which is the minimum that guarantees ARMv7 architecture, but you'll need to change the API level in project.properties and Application.mk. Then, make sure that the following is in your PATH:

[ANT_DIR]/bin
[ANDROIDSDK_DIR]/platform-tools
[ANDROIDSDK_DIR]/tools

Also define the following variable:

ANDROID_HOME=[ANDROIDSDKROOT]

Now, initialise the SDK skeleton by running:

android update project --name GlesJSDemo --target android-17 --path .

Once you've done this, you should be able to execute step (1) and (2) above.

Compiling libglesjs.so

The procecure above assumes you just use the compiled object file, libglesjs.so. If you want to tinker with the gles.js native code, you will need the Android NDK as well. Download/unzip the NDK (no install is required, version r16b was used to compile this package). Make sure your PATH points to the NDK root dir.

Directory structure

/            - Standard Android build files
res/         - Standard Android resources
assets/      - HTML5 bootloader (html5.js) and your webpage resources
src/         - Java classes
jni/         - Main source (main.cpp) and makefiles
jni/include/ - Static include files
jni/gluegen/ - Generated OpenGL ES bindings and definitions used by main.cpp
jni/lib/     - Precompiled V8 linkables
libs/        - Precompiled libs used by SDK, including libglesjs

Compile procedure

  1. Patch and build V8. This is quite a mess, and currently not included in this package, so you'll have to do with the precompiled V8 binaries in jni/lib/ for now.

  2. Generate the OpenGL ES bindings by running `php jni/gluegen/gluegen.php'. Yes, PHP is a very useful command-line string processing language, and is used here for the string processing involved in parsing the OpenGL header file and generating the bindings files.

  3. Run ndk-build to build libs/armeabi/libglesjs.so

  4. Run ant release (this is normally the only step) to compile the Java classes and put everything in an APK.

Depending on how deep you want to dig with development, you can do just the later steps, using the precompiled and pregenerated stuff already included in the package.

Features

  • HTML and XML structure manipulation

  • OUYA support (controller and payment)

  • Multitouch support

  • Audio element support. Web audio API NOT supported. For just playing samples, the Audio element is actually more convenient. Also, JS apps need to support Audio element anyway, in order to be compatible with IE.

  • HTML5 gamepad support. Currently implemented for OUYA only.

  • Features a simple JS payment API of my own devising, which should be conceptually compatible with multiple payment systems. Only OUYA implementation is currently provided. See src/net/tmtg/glesjs/PaymentSystem.java for more info.

  • runs most Pixi demos, some after minor hacking of the html file

  • runs jgame.js (for me, this is its main purpose)

Known issues

  • There is a bug which sometimes produces spurious mouse coordinates

  • Pixi XML fonts don't work yet

  • Some OpenGL ES functions are not yet implemented, in particular some of the delete and free functions, and a couple of complex functions for which no test code is available yet. Generally, OpenGL functions need to be tested with more test code.

  • There are some minor differences between WebGL and individual implementations of OpenGL ES. Some of these differences are just bugs. WebGL as featured in Chrome tries to emulate correct WebGL behaviour for known differences. In contrast, gles.js is designed to work without emulation layer. This means you will have to test your app on more devices to make sure it works everywhere.

glesjs's People

Contributors

borisvanschooten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glesjs's Issues

Examples throw OpenGL error in onSurfaceChanged

Hi,
Good job on glesjs first of all. I can see some improvements happening in some places, but it's quite cool as it is! It performs much better than a regular WebView.
Here to file a bug report: I run one of your basic examples (the bunnies) with the latest master revision, nothing altered. I notice it throws an OpenGL error (1282, I haven't found exactly where yet, can investigate further).
This is problematic for me, as in my own application it seems the bug leads to rendering trouble.
I figure the problem is in the Javascript code, so I will try another example as well.

Edit:
Just now found the source of the problem in GlesJSLib.onSurfaceChanged(width, height);
Could this be caused by changes in revisions of html5.js?

Notably the examples run fine when ignoring the examples, but when I integrate glesjs in my own project it causes problems (because of the error).

Cheers,
Kaj

source of the examples

Can you please share the source code of the pixi examples shared here: (http://tmtg.net/glesjs/). Are they working in webview? Also i want to update the code for latest opengl es and pixijs. How should i go about it?

three.js example?

Nice job, looks really interesting!

I did a quick test with three.js and a simple cube as a test. It seemed to compile fine, but it just exits when I test on a device. (Not really used to android development , so have not debugged).

So I was wondering if it should work, and/or if there are any examples that I could look at?

Thanks!

Phaser, Ionic and gles.js

Hi man,

Is possible to improve my template IonPhaser using gles.js?
If is possible, do you want work with me? (Create more examples to sell in the store ๐Ÿ‘ฏ)

Regards, Nicholls

Working pixi.js version?

Anyone knows which exact pixi.js version is compatible with this? I'm having problems with master and latest v4.

Scaling in Phaser does not work

The following code in Phaser does not work. The standard Phaser tutorials look tiny in the bottom left corner of a mobile phone or tablet and need to be scalable to fill the whole screen.

game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
game.scale.setScreenSize( true );

The fate of the project

Is this project abandoned?
Can you find out why? Faced with some difficulties or found a better alternative?

android_native_app_glue.h: No such file or directory error

First of all, thank you for this great project. With a little more work, this could be a killer project and a great complement to Ejecta.

We have found several bugs we would like to debug. However, when building this project straight from the repo, we get the following error:

main.cpp "android_native_app_glue.h: No such file or directory"

This is the same error mentioned in this post:

http://www.html5gamedevs.com/topic/7501-wip-glesjs-opengl-es-bindings-for-js-aka-fast-webgl-for-android/?do=findComment&comment=123482

We probably will need this to rebuild libgles.js to fix the audio bug described here:

http://www.html5gamedevs.com/topic/7501-wip-glesjs-opengl-es-bindings-for-js-aka-fast-webgl-for-android/?do=findComment&comment=124938

(And also to implement video element which we need).

Please give some suggestions how to get build working.

Note: we can successfully build Bdr76's project from here but it has no audio (nor video, of course):

https://github.com/BdR76/GLES.JS-Android-Studio-project

libv8_libbase.arm.a is a thin archive

Great project, but I can't build the libglesjs.so file and I think it is because the libv8_libbase.arm.a contains references to object files on your personal disk rather than the actual object code. Please check this. Thanks.

Without red channel

I try find which version of phaser work with glesjs. Same way as pixijs old phaser in example still working. Expect one error : alll graphics looks in wierd blue.
screenshot_2015-09-16-10-41-18
tested on Samsung galaxy trend plus : GT-S7580 .. android : 4.2.2

this error also present with pixijs but is not every times.

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.