PDA

View Full Version : WebGL Module for GoogleWebToolkit



Coolcat
12-26-2009, 09:00 AM
When using GoogleWebToolkit (http://code.google.com/webtoolkit/) (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
WebGL wrapper, including some related overlay types[/*:m:18h67gtc]
Canvas2D wrapper, including some related overlay types[/*:m:18h67gtc]
Mathlibrary, optimized for computer graphics purpose. Provided classes: BoundingSphere, Matrix22d, Matrix33d, Matrix44d, MatrixStack, Plane, Ray, Vector2d, Vector2i, Vector3d, Vector3i, Vector4d, Vector4i[/*:m:18h67gtc]
extendible ResourceManager with JSON-based file format. Provided resources: Library, Mesh, Texture2D, Shader, Simple3D, Sky, CompositeResource[/*:m:18h67gtc]
InputManager for mouse and keyboard input[/*:m:18h67gtc]
Simple (but extendible) log system.[/*:m:18h67gtc]
Simple (but extendible) SceneManager provides visibility detection and software picking.[/*:m:18h67gtc]
Point and Line renderer. However, points are not very useful yet since no browser supports points larger than 1 pixel.[/*:m:18h67gtc]

Requirements
GoogleWebToolkit 2.0.0 or later[/*:m:18h67gtc]
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]
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! (http://www-users.rwth-aachen.de/Martin.Weusten/develop/uc/wgt091226/) <<

(*) or Ultimate Conquest style... :P

http://www-users.rwth-aachen.de/martin.weusten/develop/uc/wgt-0.1-091226.jpg

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]
Controls:
[list:18h67gtc] LMB on Planet : center Camera on Planet[/*:m:18h67gtc]
RMB + MouseMove : rotate Camera. If you have problems with the popup menu, try STRG + MouseMove[/*:m:18h67gtc]
MouseWheel : zoom Camera[/*:m:18h67gtc]
W,S,A,D,Q,E : move Camera[/*:m:18h67gtc]
LMB + MouseMove on title: move toolwindow[/*:m:18h67gtc][/*:m:18h67gtc]
JSON library is located at wgt-0.1/war/r/library.json[/*:m:18h67gtc]
Sourcecode is located at wgt-0.1/src/example/gwt[/*:m:18h67gtc]
A look at the JavaDoc documentation at wgt-0.1/javadoc/index.html will also prove helpful.[/*:m:18h67gtc][/list:u:18h67gtc]


Download
>> wgt-0.1-091226.zip (http://www-users.rwth-aachen.de/Martin.Weusten/count.php?file=develop/uc/wgt-0.1-091226.zip) <<




Ultimate Conquest
Ultimate Conquest (UC) is a clone of the popular KDE game “Konquest” (http://en.wikipedia.org/wiki/GNUlactic_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.

Demo version uc091214 (http://www-users.rwth-aachen.de/martin.weusten/develop/uc/uc091214/UltimateConquest.html)[/*:m:18h67gtc]
Youtube video (http://www.youtube.com/watch?v=JDTiq3RWfTc)[/*:m:18h67gtc]
German project site (http://www.delphigl.com/forum/viewtopic.php?f=13&t=8827) with some screenshots, if you don't speak German try google translation (http://translate.google.com/translate?js=y&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Fwww.delphigl.com%2Fforum%2Fviewtopi c.php%3Ff%3D13%26t%3D8827&sl=de&tl=en).[/*:m:18h67gtc]

Coolcat
12-27-2009, 03:04 AM
Sorry, "STRG" key is "CTRL" in english. :roll:
For some reason it is not possible to edit posts here... :?

youdonotexist
01-08-2010, 02:10 PM
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

youdonotexist
01-08-2010, 04:27 PM
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.

Coolcat
01-09-2010, 04:31 AM
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? :) )

Cork
01-12-2010, 12:59 PM
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 :)

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 :)

youdonotexist
01-12-2010, 01:59 PM
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.

youdonotexist
01-12-2010, 02:07 PM
@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

Coolcat
01-13-2010, 09:56 AM
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 :)
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.

Coolcat
01-18-2010, 06:30 AM
Ok, I have created an project at sourceforge:
https://sourceforge.net/projects/wgt/files/

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

ice box
08-02-2011, 02:10 AM
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.