Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!

We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Member Since 22 May 2004
Offline Last Active Yesterday, 12:45 PM

Topics I've Started

ScummVM running on the web!

10 June 2013 - 09:27 AM




Games programmers here might be interested in this project I have been working on the past few weeks. Have a look here:







Emscripten is a compiler that compiles C/C++ code to JavaScript for running on the web. As a test/proof-of-concept of its maturity and applicability to C++ codebases that weren't originally designed for the web in mind, I had a go at porting the ScummVM codebase to HTML5 with it.


The maturity and robustness is commendable, and Emscripten has become a viable alternative to Flash and Native Client. I develop a graphics system called gfxapi, which targets both Emscripten and PNaCl targets. With GLES2 and EGL support, developing 3D graphics against Emscripten is very similar to developing 3D gaphics for Android. Also recently, Unreal Engine 3 was ported over to the web, which goes to show that Mozilla's approach has the capability to scale as well.


The technical details of the ScummVM port can be discussed at the Emscripten mailing list.


Enjoy! smile.png

Try Angelscript live!

08 December 2012 - 12:48 PM


here's something cool I wrote up this weekend. With your modern browser with WebGL enabled, visit this page: MathGeoLib live test site. It is a project consisting of a few parts:
  • Uses my native C++ graphics rendering engine gfxapi. Utilizes the emscripten compiler to deploy the application to HTML5.
  • Integrates Angelscript as the live scripting engine.
  • Uses my MathGeoLib library for scripting primitives and geometry manipulation.
  • Interop between C++ MathGeoLib classes and Angelscript is achieved using an automatic bindings generator based on juj/CodeStructure.
The application allows writing Angelscript live on a web page, and render stuff on the screen by using constructs from MathGeoLib and gfxapi. I really must congratulate Andreas Jönsson for the Angelscript project - it is a very fine piece of technology! I have previously written C++ - script bindings interop for MathGeoLib for QtScript and Javascript, and using Angelscript is the most mature, easist and convenient one of them to work with! I evaluated Python, Lua and Mono to replace my previous JavaScript-based scripting engines, but Angelscript is the king of the hill. The support for strong typing and ability to do value types with function and operator overloading is exactly what is needed for good interop and convenient games scripting, and something where the whole competition falls short :)

Compile C++ to JavaScript for Web Pages from Visual Studio?

26 April 2012 - 02:15 AM


I think some people here might be interested to know about my latest project, called vs-tool. It is a plugin for Visual Studio 2010 which enables the integration of external compiler/linker toolchains into VS. The hard work was done by Gavin Pugh, the author of vs-android, who developed a MSBuild task plugin to allow invoking GCC from VS. For vs-tool, the following toolchains are now supported:

- Build with MinGW: http://dl.dropbox.co...de/vs-mingw.png

Allows building Windows applications if you have installed the MinGW compiler.

- Build with llvm-clang: http://dl.dropbox.co...de/vs-clang.png

Allows compiling with the clang compiler. Note however, that clang does not yet fully support building windows applications, but I have tested that simple hello world code at least builds and runs ok.

- Build with Emscripten: http://dl.dropbox.co...ode/vs-emcc.png

Emscripten is a wonderfully geeky and absurd project, where LLVM bytecode is translated into executable .js for the web. This means one can compile C++ code directly into .js. The project is developed by Alon Zakai from Mozilla, find the homepage at https://github.com/k...emscripten/wiki , and a technical paper at https://raw.github.c.../docs/paper.pdf . The main motivation that had me start building vs-tool was to add support for Emscripten directly into Visual Studio, which is now working quite nicely (adding MinGW and Clang support was a bit of a side tour). Rather insanely, Emscripten supports translating GLES2 code directly into WebGL code, which allows me to work on converting my Android GLES2 engine directly for the web, from Visual Studio! This is so hackish, insane, fun, and crazy, at the same time.

The homepage for vs-tool is at github: https://github.com/juj/vs-tool

If you give it a go, let me know how it goes!


23 October 2011 - 12:32 PM


one of the more common topics on the math forums here at GD is about 3D mathematics, geometry manipulation or primitive testing. A lot of people have written their own libraries for doing vector/matrix/quaternion math and geometric primitive intersection testing. There does not seem to exist a single library that would be specifically tuned for these purposes.

Along the years, I have accumulated tons of different utility functions for performing games-related geometric tests. Recently, I was faced by a task of implementing a script API for math and geometry handling, and that script API would be used by people who are very unfamiliar with scripting and mathematics in general. I started collecting all the code I had scattered all over, and bundled it up to a very object-oriented manner, so that I could create an automatic script bindings generator for exposing this functionality to a JavaScript engine.

The result is now called MathGeoLib, which is a C++ library for games-oriented 3D mathematics and geometry manipulation:

I am not overly interested in "preaching" people to start using this library, since I am not that big fan of open source development in general and I have little time to do free maintenance work or tech support on the library ("you are on your own"). Instead, I hope that the documentation and online source code will function as a useful repository to anyone looking for code snippets on how certain intersection tests or mathematical constructs are often implemented.

Any thoughts? Spot obvious bugs? Criticism? Am I good at drawing diagrams or what? :)

View-independent "presorting" of triangles in a vertex buffer.

04 March 2011 - 07:41 AM


When rendering a transparent object (in a single vertex buffer) on a GPU, depending on the ordering of the triangles inside the vertex buffer, you may get artifacts due to overlapping triangles being rendered in wrong order.

A solution to this is to treat the vertex buffer as dynamic, and to sort the contents per-frame (or use a BSP to produce a proper sorted order). Another solution is to use depth peeling. These both have performance limitations which in my case are unacceptable.

I've been toying with the idea of implementing a method referred to as "presorting", in which you sort the triangles in the vertex buffer in such an order, that rendering the triangles in that order give correct results view-independently. This kind of sort order does not always exist.

The difficulty with this method is that I'm very unsure how robust the mechanism would be, and if there might be some pathological (but perhaps common?) cases that are problematic. I've been trying to find some material about this method of presorting, to know if someone has investigated this method further. Unfortunately, I can't seem to find any good publications on it, perhaps my search skills are failing? Or perhaps this method is so obvious, that it is regarded as a folklore method?

The only sources I found is a video from Assembly 2002 talk on optimizing a software renderer by Paul Endresen, where he describes this method. This video is available at http://www.scene.org/file.php?file=%2Fresources%2Fseminars%2Fcode%2Fasm02_-_paul_lone_starr_endresen_-_software_3d_rendering.wmv&fileinfo .See time 16:34 - 26:00. At 24:00 he says "We didn't put too much effort in to finding out where to split". Does anyone know if there's some source where this kind of splitting method has been investigated?

At 24:47 a person from the audience refers to this algorithm having been implemented in "already in 1979 or something", "by a guy Schumacher or similar". Do you know of an academic paper or a book that describes this method?

Another source where this method is described can be found on this web page: http://www.mindcontrol.org/~hplus/graphics/sort-alpha.html . But this page also doesn't talk about its robustness, or about the possibility of splitting to reduce visual artifacts. I'd be interested in seeing some real case data, to see what kind of artifacts I might have expect.

Do you implement this method? How well does it work?