4

I'm working on a browser based game atm and already looking into options porting it to other platforms such as consoles or devices where playing in a web browser may not be suitable.

The game is pretty much all JavaScript with rendering done via a 2d canvas context.

What i was hoping for is that there is already a c++ library/api that will work in conjunction with maybe google's v8 engine to handle the canvas calls in JavaScript and render them with opengl or something similar

Does anyone know of a project out there that may be providing this functionality?

Otherwise how would you suppose I go about embedding my javascript in c++ with as little changes required to the javascript as possible as I don't really want to have to maintain too many differences between platforms?

Tristan
  • 3,845
  • 5
  • 35
  • 58
  • 2
    Qt seems a reasonable solution (includes Webkit) – 6502 Aug 01 '11 at 12:52
  • [fluff](https://github.com/BonsaiDen/Fluff.js) is a start at opengl and v8. However the API exposed is not a canvas API so you need to write your own js level proxy – Raynos Aug 01 '11 at 13:22
  • Both of these look very interesting, Qt looks rather good I hadn't thought of just embedding something like webkit, would be nice though if there was a direct implementation of the canvas api in c++ though – Tristan Aug 01 '11 at 13:55
  • @6502 if you want to add an answer with Qt being the solution I will mark it solved for you, this is what I will be using cheers for that – Tristan Aug 10 '11 at 20:33
  • @Tristan: I've added the answer. I think Qt should get more attention from the developers as it's really a nice framework with a fantastic quality of documentation. – 6502 Aug 11 '11 at 05:53

4 Answers4

4

Qt is a very nice C++ library compatible with LGPL licensing that among other things includes a webkit based widget with javascript support. Also as scripting language Qt uses javascript with a tight integration with C++ (it's easy to write a C++ class and and make it visible at the javascript level).

Qt is multi platform and comes with an highly sophisticated IDE.

Qt is not currently using V8 but the porting is in progress and they aim at providing a 100% backward compatible solution.

The only "problems" of Qt are IMO that:

  • It's huge
  • It's a framework, not a library. You cannot just "use" Qt easily, you should embrace the view (the documentation is however of excellent quality).
  • The long term prospects are a bit fuzzy (not as bad as a few months ago, tho)
6502
  • 112,025
  • 15
  • 165
  • 265
  • 1
    I Would not reccomend using QT for game development, I read somewhere that it was quite unsuitable for that because it wants to hold the reins -- And when you make a game you want to decide what happens and when. But on the other hand, going from the browser, this might not feel any differnet. – Frank Jun 28 '12 at 20:56
3

I guess I'm a bit late here, but I'm searching for a similar solution. I found node-canvas and I do not know if it is feasible to hook that so it renders into something like an SDL or SFML-managed window or not.

But for my own purposes, I will port my code over to C++ and use Cairo directly with SFML and OpenGL.

Frank
  • 2,640
  • 2
  • 21
  • 21
0

Interesting idea - another possibility is using Adobe Air, and rendering the game via StageWebView and Flex 4. Here's some example code for using the thing if you're interested:

https://github.com/JustinBeckwith/frink/blob/master/frink-flex/src/controls/WebBrowser.as

Justin Beckwith
  • 7,686
  • 1
  • 33
  • 55
0

An interesting Project that I have uses id FireBreath(firebreath.org). This is not exactly what you are looking for, but in some ways it would get you close. Firebreath allows the creation of browser plugins in C++. One of the features of Firebreath is it allows you to access and modify the DOM from the C++ in you browser plugin as well as create methods and properties in C++ that can be accessed from JavaScript on your page.

James
  • 933
  • 1
  • 7
  • 14