Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good platform for building a game framework targeting both web and native languages? [closed]

I would like to develop (or find, if one is already in development) a framework with support for accelerated graphics and sound built on a system flexible enough to compile to the following:

  • native ppc/x86/x86_64/arm binaries or a language which compiles to them
  • JavaScript
  • ActionScript bytecode or a language which compiles to it (ActionScript 3, Haxe)
  • optionally Java

I imagine, for example, creating an API where I can open windows and make OpenGL-like calls and the framework maps this in a relatively efficient manner to either WebGL with a canvas object, 3d graphics in Flash, OpenGL ES 2 with EGL, or desktop OpenGL in an X11, Windows, or Cocoa window.

I have so far looked into these avenues:

  • Building the game library in Haxe
    • Pros:
      • Targets exist for PHP, JavaScript, ActionScript bytecode, C++
      • High level, object oriented language
    • Cons:
      • No support for finally{} blocks or destructors, making resource cleanup difficult
      • C++ target does not allow room for producing highly optimized libraries -- the foreign function interface requires all primitive types be boxed in a wrapper object, as if writing bindings for a scripting language; these feel unideal for real-time graphics and audio, especially exporting low-level functions.
      • Doesn't seem quite yet mature
  • Using the C preprocessor to create a translator, writing programs entirely with macros
    • Pros:
      • CPP is widespread and simple to use
    • Cons:
      • This is an arduous task and probably the wrong tool for the job
      • CPP implementations differ widely in support for features (e.g. xcode cpp has no variadic macros despite claiming C99 compliance)
      • There is little-to-no room for optimization in this route
  • Using llvm's support for multiple backends to target c/c++ to web languages
    • Pros:
      • Can code in c/c++
      • LLVM is a very mature highly optimizing compiler performing e.g. global inlining
      • Targets exist for actionscript (alchemy) and javascript (emscripten)
    • Cons:
      • Actionscript target is closed source, unmaintained, and buggy.
      • Javascript targets do not use features of HTML5 for appropriate optimization (e.g. linear memory with typed arrays) and are immature
      • An LLVM target must convert from low-level bytecode, so high-level constructs are lost and bloated unreadable code is created from translating individual instructions, which may be more difficult for an unprepared JIT to optimize. "jump" instructions cause problems for languages with no "goto" statements.
  • Using libclang to write a translator from C/C++ to web languages
    • Pros:
      • A beautiful parsing library providing easy access to the code structure
      • Can code in C/C++
      • Has sponsored developer effort from Apple
    • Cons:
      • Incomplete; current feature set targets IDEs. Basic operators are unexposed and must be manually parsed from the returned AST element to be identified.
      • Translating code prior to compilation may forgo optimizations assumed in c/c++ such as inlining.
  • Creating new code generators for clang to translate into web languages
    • Pros:
      • Can code in C/C++ as libclang
    • Cons:
      • There is no API; code structure is unstable
      • A much larger job than using libclang; the innards of clang are complex
  • Building the game library in Common Lisp
    • Pros:
      • Flexible, well-developed language
      • Extensive introspection should ease writing translators
      • Translators exist for at least javascript
    • Cons:
      • Unfamiliar language
      • No standardized library functions, widely varying implementations

Which of these avenues should I pursue? Do you know of any others, or any systems that might be useful?

Does a general project like this exist somewhere already?

Thank you for any input.

like image 829
fuzzyTew Avatar asked Jan 06 '11 17:01

fuzzyTew


2 Answers

I think Unity is what you're looking for.

  • The some paying versions allow you to access, modification and extension of the Unity C++ code.
  • It's web-mobile-desktop cross-platform.
  • It allows using high level languages by default (.Net languages -but not .Net platform-, Javascript, etc)
like image 120
Klaim Avatar answered Sep 27 '22 18:09

Klaim


Haxe has gotten much more powerful with the introduction of a complex macro language in version 2.07. I think this goal would be achievable with Haxe right now, and will only get moreso in future releases. The cons I mentioned still stand, but the language is open source and macros are powerful.

like image 24
fuzzyTew Avatar answered Sep 27 '22 18:09

fuzzyTew