WebGL Module for GoogleWebToolkit

When using GoogleWebToolkit (GWT) you can code you WebGL application in Java! GWT does compile your code to JavaScript, so end users will not notice a difference. You gain things like type-safety, class hierarchy, a nice widget system and code optimization though the compiler.

My module has the boring name ‘WebGL Toolkit’ (WGT), but provides WebGL support for GWT. This project is part of my Ultimate Conquest project (see below). WGT is licenced under GNU General Public License (Version 3).

Features

  • [li] WebGL wrapper, including some related overlay types[/:m:18h67gtc][/li][li] Canvas2D wrapper, including some related overlay types[/:m:18h67gtc][/li][li] Mathlibrary, optimized for computer graphics purpose. Provided classes: BoundingSphere, Matrix22d, Matrix33d, Matrix44d, MatrixStack, Plane, Ray, Vector2d, Vector2i, Vector3d, Vector3i, Vector4d, Vector4i[/:m:18h67gtc][/li][li] extendible ResourceManager with JSON-based file format. Provided resources: Library, Mesh, Texture2D, Shader, Simple3D, Sky, CompositeResource[/:m:18h67gtc][/li][li] InputManager for mouse and keyboard input[/:m:18h67gtc][/li][li] Simple (but extendible) log system.[/:m:18h67gtc][/li][li] Simple (but extendible) SceneManager provides visibility detection and software picking.[/:m:18h67gtc][/li][li] Point and Line renderer. However, points are not very useful yet since no browser supports points larger than 1 pixel.[/:m:18h67gtc]

Requirements

  • [li] GoogleWebToolkit 2.0.0 or later[/:m:18h67gtc][/li][li] When ResourceManager class is used a HTTP-Server is required. It will not work on local filesystem since internally HTTP-requests are used to load resources.[/:m:18h67gtc][/li][li] Obviously a WebGL capable browser is required.[/*:m:18h67gtc]

Example
Together with WGT comes a small example which shows how to use all major classes. It’s a simple animated planet scene with Homeworld-style (*) camera system. You can disable the Glow-effect in the options menu.

>> Try Live demo! <<

(*) or Ultimate Conquest style… :stuck_out_tongue:

  • [li] To try it make the directory content of wgt-0.1/war available via HTTP. Access using local filesystem will not work. A local HTTP-Server (e.g. Apache) is very helpful during development.[/:m:18h67gtc][/li][li] Controls:[/li][list:18h67gtc][li] LMB on Planet : center Camera on Planet[/:m:18h67gtc][/li][li] RMB + MouseMove : rotate Camera. If you have problems with the popup menu, try STRG + MouseMove[/:m:18h67gtc][/li][li] MouseWheel : zoom Camera[/:m:18h67gtc][/li][li] W,S,A,D,Q,E : move Camera[/:m:18h67gtc][/li][li] LMB + MouseMove on title: move toolwindow[/:m:18h67gtc]

Download
>> wgt-0.1-091226.zip <<

Ultimate Conquest
Ultimate Conquest (UC) is a clone of the popular KDE game “Konquest” in development. WGT is a subproject which does collect all components that are general enough to be useful in other projects. UC is closed source, but WGT is available under GPLv3.

Sorry, “STRG” key is “CTRL” in english. :roll:
For some reason it is not possible to edit posts here… :?

I’m very interested in using this library. I am able to run the 091214 flawlessly on both WebKit and Minefield. However, when I try to run the 091226 version, I receive the following errors (in both browsers):

15:05:22.897 Error while compiling shader ‘default.lib/glow-blur.fs’:
ERROR: 0:7: ‘array of float’ : array type not supported here in glsl < 120
ERROR: 0:7: ‘array of float’ : constructor not supported for type
ERROR: 0:9: ‘array of float’ : no matching overloaded function found
ERROR: 0:7: ‘const float’ : cannot declare arrays of this type
ERROR: 0:7: ‘gaussFilter’ : redefinition
ERROR: 0:15: ‘expression’ : left of ‘[’ is not of type array, matrix, or vector
15:05:22.898 Error while compiling shaders ‘glow.vs’ and ‘glow-blur.fs’ in library ‘default.lib’

Is this something you’re aware of? Also, do you have a public GIT (or other) for this project? I’d very much like to use WGT in my current project and help out with future releases. Thanks again for your contributions.

Thanks,
Mike

Disregard this, this is a problem on my side. Looks like my graphics card doesn’t support float arrays. Nothing wrong with the new version.

Looks like my graphics card doesn’t support float arrays. Nothing wrong with the new version.

Correctly, float arrays are part of the GLSL ES spec. If have switched in that version to an new/better/faster blur shader used for the glow effect.

Also, do you have a public GIT (or other) for this project? I’d very much like to use WGT in my current project and help out with future releases. Thanks again for your contributions.

I have switched from using simple TAR-balls to GIT a week ago or so. However, currently the repository is just locally on my hard disk and does contain only UC/WGT as single project.

I’m not really experienced in using GIT. Actually this is my first project using GIT. Is it possible to maintain multiple projects that share parts, where only the some parts (WGT, WGT-Example) are public? In that case we could both have our projects locally and develop WGT together.

(P.S.: What kind of project do you have in mind? :slight_smile: )

Wow! I’m very excited to see people working on this topic. I’m a heavy Java user and would love to be able to do more OpenGL on the web. So far I’ve been using JOGL2 for this, but the concept of plugin-less deployment with WebGL is a big draw for me, and being able to continue developing in Java kinda essential :slight_smile:

My only concern is that there seem to be 3 distinct projects already now trying to do the same thing, ie bring WebGL to GWT, although this project looks the most mature thus far. Hopefully everyone can pull together to really make this work.

Is there any chance of using the same API that JOGL2 is using for their ES2 binding? That would make migrating code from the Java+OpenGL world to Java+WebGL world so much easier. Or even allow developers to target web and desktop from the almost the same codebase.

As far as I know JOGL uses gluegen to autogenerate the binding based on the OpenGL headers. Maybe a similar approach could be used here? Ideally with the core binding layer as a seperate package from all the nice utilities and effects engines etc. So we’d have a single binding, and then a number of additions libs offering extra functions that can co-exist depending on what a project needs.

I was tempted to have a go myself until I came across this group :slight_smile:

I finally successfully deployed the example project and ran it (after removing the Glow shader effect from code). So, far things are looking alright. Obviously, at 1920x1200, I was suffering from poor framerates (< 15 FPS). This was on a nVidia 8600M GT, so nothing too old. At 1280x1024, I was working at a steady 60+ FPS.

It doesn’t seem like the frame rate should be suffering that much, since there isn’t much on the screen, but WebGL is not bare to the metal like native OpenGL apps. I’ll do some profiling to see what the bottlenecks are.

As for GIT, I haven’t used it either, myself. I’ve been using Assembla (SVN + tickets + time management) for any of my personal projects, but GIT has been gaining support in the Open Source community, so I figured it might be a better place for it. From what I understand, most implementations of a public/private repository have multiple branches, one public branch and a bunch of private branches that merge into the public as code becomes stable. I believe this is possible with both GIT and SVN.

As for my personal project(s), I’m primarily working on a project for the smallish company I work for. I’m doing a little research into interfaces to display information to customers in unique and interesting ways. Unfortunately, I can’t say too much more than that until I get further along in the project. But, anything I add to WGT would obviously belong to the WGT library.

But, in my free time, I’m an indie game developer at heart. I’m currently working on an action/adventure game using Torque, but what I really would like to use WGT/WebGL for is my smaller experimental game projects. I’ve, for the most part, worked with 2D games, but 3D is also something I’d like the pursue.

I really think WebGL is going to open up many doors for game developers. Personally, I’m not the biggest fan of Flash, but for the longest time, it’s been a great medium for getting games out there in front of people easily. Once browsers get WebGL integrated into their public releases, we’ll see many more developers choosing WebGL over Flash.

@Cork: I was in the same boat. There were two other libraries that had put up Google Code pages, but seemed like they had given up or hadn’t updated in a while. Coolcat’s seemed like the only one with life in it. After looking at the code, it’s coded very well and isn’t very difficult to understand. Coolcat’s done a great job so far, in my opinion.

As far as JOGL, that’s out of my realm of experience.

Mike

After looking at the code, it’s coded very well and isn’t very difficult to understand. Coolcat’s done a great job so far, in my opinion.

Thanks :slight_smile:
I think I will create an public GIT repo as soon as I find time to do that.

Coolcat’s seemed like the only one with life in it.

I can work on UC/WGT only in my sparse free time, so I can’t guarantee it will stay alive, especially because I have also some other projects.

As far as JOGL, that’s out of my realm of experience.

I have also never worked with JOGL. Most of the time I’m developing with C++/OpenGL on Linux.

I’ve, for the most part, worked with 2D games, but 3D is also something I’d like the pursue.

Doing 2D with WebGL might be also a good idea, since the 2D canvas has no hardware acceleration yet.

Ok, I have created an project at sourceforge:
https://sourceforge.net/projects/wgt/files/

GIT repository:
git://wgt.git.sourceforge.net/gitroot/wgt/wgt

I think you can’t. It should be a massive work. I have no idea about how
bullet works, but tricking it to use a webgl context must be hard, next to
imposible.

GWT is a Java to Javascript compiler. It is no magic java in a webpage. The
java code must comply various constraint to be able to translate to
javascript. Something as simple as awt.Color doesn’t work.