OpenGL ES cross platform development - opengl-es

I need to develop a small 3D game running on both Android and IOS mobile devices.
1- Should I implement EGL using within 3D logic or left it been implemented in Object-C or Java? which way should I go and why?
2- Should I use C or C++ for game logic? it is said C has better run time performance but harder to design due to it is not OOP C++ and vice versa. I have some experience with Java so I prefer OOP more.

Have you already considered to use a multiplatform library? For example:
libGDX
Especially if you are targeting for both platforms, such a library might be helpful.
I can only speak for Android a bit:
It actually makes no real difference, the Android API just provides calls for the same OpenGL C-functions, but still more comfortable, better supported and the recommended approach. Anyway there is Android NDK which allows to load original C/C++ code given the case you want to port some code from another platform (or develop for several platforms).
In my opinion the performance is mostly limited by the graphics (number of objects, size of textures etc.), usually not much by game logic, so Java would be more convenient.

Related

2D Cross-Platform Game Development Engines [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I've worked for some time with Corona SDK and love how fast and easy I can create powerful apps using Lua. But it can only compile for iOS and Android, which feels like too little now.
My main interest is for it to be able to compile to Desktop AND Mobile. At least for the following:
Windows + Mac for desktop, as standalone applications.
iOS + Android for mobile.
I'd prefer it to lean more towards Lua type scripting instead of ActionScript, but please feel free to post anything that you have worked with and love.
I've found the following engines so far:
Marmalade Quick - After further looking into it, Marmalade Quick can only build for Mobile!
IwGame - Works on top of marmalade and says it can deploy to
desktop and mobile with Lua. Any info is greatly appreciated on this
sio2 - Says "SIO2 is an OpenGLES based cross-platform 2D and 3D
game engine for iOS, Android, MacOS and Windows" and "The engine also
allows you to port your game on the Mac Store and on Windows.", but
their forum and web title is "Game Engine for Mobile Devices". Can't
find any info on if it can deploy to desktop platforms, any info is
greatly appreciated again.
Loom Engine - Loom is similar to Haxe + OpenFL (attempts to attract Flash developers) in that it uses AS3-like of ECMAScript, but it doesn't build native code from it. However it uses Cocos2D for rendering so it should in theory be as fast as Cocos2D. -- Thanks to Bojan.
SDL - I've read in multiple places that SDL can deploy to nearly any platform or device and has a Lua binding. But i can't find how this works as it's not an engine. Any one who can explain how it works and if it's possible is once again, very much appreciated.
SFML - "Windows, Linux, Mac OS X and soon Android & iOS. " doesn't use Lua but can use other languages like Java and Python etc. Anyone have any information on this?
Torgue2D - "Torque 2D was developed with OS X, Windows, and iOS devices in mind and works equally well on all the platforms." uses TorgueScript and no Android =(
Sencha - Seems to compile to all platforms, uses Javascript too which I know. But even with V8 JS would this work well performance wise compared to other options?
GameMaker - own scripting language GML and I actually remember this one as a tool for non-programmers. Has it actually grown into a real engine, I mean for serious development?
Construct2 - Same question as gamemaker
Corona - Lua but mobile only (Android and iOS only as well)
Cocos2D - Seems like it has lots of options but not sure with the same language? Seems like you'd have to re-write your entire code. Any info if cocos2D can deploy to desktop + mobile with almost the same code would be greatly appreciated.
Angel2D - Says it can deploy to everything except Android and uses Lua, anyone ever used this one before?
libgdx --- I've only seen good things about this. Here is a benchmark test for libgdx and is where I saw it reaching 40k sprites at 60fps. http://www.sparkrift.com/2012/1/love2d-vs-allegro-vs-clanlib-vs-libgdx-vs-cocos2d-x-vs-monogame-vs-xna-vs-sfml . It seems libgdx barely goes over 30k actually. But still seems amazing. This is on the same level as Qt for me, almost perfect, except I'm not really worried about performance on it. libgdx can build for everything pretty much.
XNA + MonoGame --- MonoGame's performance seems only slightly lower than libgdx, can build to most platforms. However I don't know much about XNA and I heard it won't be receiving future updates, but is quite stable? More information is welcome.
Citrus --- Don't have much information on Citrus either. AS3 game engine that can build for iOS, Android, Windows, Mac and more.
Haxe + OpenFL --- OpenFL (Haxe) builds to native on many platforms, not just to Flash. Windows, Mac, Linux and Android all get optional native deployment or OpenFL runtime called Neko which is in theory faster than Flash, and SDL 2.0 will enable iOS deployment soon(ish). -- Thanks to Bojan.
Qt-Project --- Just linking Qt project here, can build for everything and has a pretty big community with lots of third party libraries to help you even further.
Moai ---The only Lua engine that I know that can build for Desktop and Mobile. Only downside is the community isn't that big and documentation isn't the best. But if you can get passed those this is a great solution and the one I'm currently using.
Adobe --- Can't forget to add adobe here since it can build to everything that supports flash.
Unity3D --- Recently announced 2D integration looks very promising, should be released Q3-Q4 of 2013.
Cocos2d-x --- An open source engine. Supports JS, Lua, C++ and multiple platforms.
Html5 --- There seem to be a lot of emphasise on html5 mobile apps, here are just a few tools I found that can help port your html5 project to a platform:
Chromium embedded
Sencha
Phonegap
Appcelerator/Titanium
Icenium
So, I'd be happy if you could comment from your experiences with any engines and suggest which one you would recommend.
Thank you for your help!
EDIT: Since this topic is getting popular I'll be adding other options I've found over time. I suggest you choose what is most familiar to you and best for your project needs.
I would recommend V-Play (v-play.net) - it's a cross-platform game engine based on Qt for iOS, Android, Symbian, MeeGo, Blackberry10 and also can export for native desktop applications for Windows, Mac and Linux.
It's based on C++ but has a neat scripting support for QML & JavaScript. QML is a no-brainer to learn and can boost your productivity as less code is needed - just see the comparison with cocos2d-x(60% less Loc) or Corona(15% less LoC) for a comparison of the same games.
(Disclaimer: I'm one of the guys behind V-Play)
If you are into using Python, Kivy is a great solution these days. It compiles to all the platforms you ask for:
Kivy is running on Linux, Windows, MacOSX, Android and IOS. You can
run the same code on all supported platforms. It can use natively most
inputs protocols and devices like WM_Touch, WM_Pen, Mac OS X Trackpad
and Magic Mouse, Mtdev, Linux Kernel HID, TUIO. A multi-touch mouse
simulator is included.
Kivy uses lots of optimized code for graphics rendering (via Cython) so it is fast too.
Here is a speakerdeck that gives you some background and an overview (android specific).
How about HaxeFlixel? We have a great selection of demos, and of course support cross platform development via Haxe + OpenFL. This is an open source project hosted on GitHub. We support all major platforms (including iOS).
Here is my game framework Oxygine.
It is open source modern hardware accelerated 2D C++ framework for mobile and PC platforms.
Features: OpenGL(ES) 2, compressed textures, atlases, complex animations/tweens/sprites, scene graph, fonts, event handling, build tools, and others.
Can be built on top of SDL2 or Marmalade SDK.
In the basis of the engine there is a scene graph, that is similar to Flash one. To be short, You can call this as Flash for C++, but more comfortable and way faster. Initially it was developed for mobile platforms (iOS, Android), but can be also used for PC games.
No mention of App Game Kit (AGK) here so let me fill in the gap. It's a mainly 2D cross platform SDK allowing you to code once in either C++ or it's own "Basic" language. Version 2 just got over 400% funding on Kickstarter and will have full 3D support, Spine support (for 2D animated characters), bullet physics and whole bunch of other new features.
It already has Facebook, Twitter, a bunch of Ultrabook sensor commands, Box2D and more. I've been using it from the start and love it (can you tell?). No, I don't work for The Game Creators (the company that created it) although I admit I did do for a while making some apps.
One of the best features from my point of view is you can develop on Windows and broadcast from the IDE over Wi-Fi to any supported device, so while I'm coding I can (within seconds) test my code on iPad, Android, Windows, Mac or Blackberry Playbook.
If you have C# background. Have a look at Duality.
Duality is a flexible 2D game framework written entirely in C# –
and it’s here to make things a little easier for you. It provides both
an extensible game engine and a visual editor to match. There will be
no need for a level editor, testing environment or content manager
because Duality is all that by itself. And best of all: It’s free.
I'm just answering to give you some insights on how the SDL is used. As you said before it's not a game engine (it's just a library actually). Furthermore, it is not object oriented at all and you don't have some easy animation facilities (you have to code them by yourself).
How it works (I used the C version but I guess the Lua binding should be similar):
Include the headers needed to build the project on the platform you want.
Design your own game loop in which you will set up (at least) a whole event processing system, frame rate manager and a "screen cleaner (or updater)" (I'm insisting on the fact that you have to manually refresh your screen using the SDL_flip_screen routine which is something that is not one of your concerns at all with Corona).
Then, code your game using all the "mechanics" you made before.
The SDL is a low level library (don't expect to have an easy to use GUI framework or the storyboard framework of Corona for instance).
Finally, this library was used to port Civilization III to Linux, so yes it works but it will ask you a lot of energy to have something like you had with Corona ;)
PS: I am not a native English speaker, so please let me know if I wasn't clear :)
Gideros is a great Lua based 2d cross platforms engine, currently supporting both Android and IOS platforms, but more to come.
And it also has some great features as instant on device testing, auto scaling and auto image resolution to easily target various of screen sizes, as well as the option to extend each platform through native plugins.
You also have ShiVa3D, a serious competitor of Unity3D.
It uses Lua and supports many platforms from mobile to game consoles and web browsers.
Very intuitive to use and very nice UI to work with.

Prototyping and simulating embedded software on Windows

I am looking for tools and techniques for prototyping (virtual prototyping), simulation, and testing of deeply embedded C code on desktop Windows, including building realistic embedded front panels consisting of buttons, LEDs, and LCD displays (both segmented and graphic).
I'm specifically interested in a possibly low-level approach, using pure C code and raw Win32 API rather than MFC, .NET/C#, vxWidgets or Qt. I'd also like to use free development tools, such as Visual C++ Express with Platform SDK and ResEdit for editing resources.
I'm looking for code examples to render graphic LCDs (from monochrome to 24-bit color) with efficient pixel-level interface, multi-segment LCDs, and owner-drawn buttons that respond both to "depressed" and "released" events.
I am surprised that my original question triggered so many misunderstandings and adverse comments. The strategy of developing deeply embedded C code on one machine (e.g., a PC) and running it on another (the embedded microcontroller) is called "dual targeting" and is really quite common. For example, developing and testing deeply embedded code on the PC is the cornerstone of the recent book "Test-Driven Development for Embedded C" by James Grenning.
Avoiding Target Hardware Bottleneck with Dual Targeting
Please note that dual targeting does not mean that the embedded device has anything to do with the PC. Neither it means that the simulation must be cycle-exact with the embedded target CPU.
Dual targeting simply means that from day one, your embedded code (typically in C) is designed to run on at least two platforms: the final target hardware and your PC. All you really need for this is two C compilers: one for the PC and another for the embedded device.
However, the dual targeting strategy does require a specific way of designing the embedded software such that any target hardware dependencies are handled through a well-defined interface often called the Board Support Package (BSP). This interface has at least two implementations: one for the actual target and one for the PC, for example running Windows. With such interface in place, the bulk of the embedded code can remain completely unaware which BSP implementation it is linked to and so it can be developed quickly on the PC, but can also run on the target hardware without any changes.
While some embedded programmers can view dual targeting as a self-inflicted burden, the more experienced developers generally agree that paying attention to the boundaries between software and hardware is actually beneficial, because it results in more modular, more portable, and more maintainable software with much longer useful lifetime. The investment in dual targeting has also an immediate payback in the vastly accelerated compile-run-debug cycle, which is much faster and more productive on the powerful PC compared to much slower, recourse-constrained deeply embedded target with limited visibility into the running code.
Front Panel Win32 GUI Toolkit
When developing embedded code for devices with non-trivial user interfaces, one often runs into the problem of representing the embedded front panels as GUI elements on the PC. The problem is so common, that I'm really surprised that nobody here could recommend an existing library or an open source project, which would provide a simple C-only interface to the basic elements, such as LCDs, buttons, and LEDs. This is really not that complicated, yet it seems that every embedded developer has to re-invent this wheel over and over again.
So, to help embedded developers interested in prototyping embedded devices on Windows, I have created a "Front Panel Win32 GUI Toolkit" and have posted it online under the GPL open source license (see http://www.state-machine.com/win32). This toolkit relies only on the raw Win32 API in C and currently provides the following elements:
Dot-matrix display for an efficient, pixel-addressable displays such as graphical LCDs, OLEDs, etc. with up to 24-bit color
Segment display for segmented display such as segment LCDs, and segment LEDs with generic, custom bitmaps for the segments.
Owner-drawn buttons with custom “depressed” and “released” bitmaps and capable of generating separate events when depressed and when released.
The toolkit comes with an example and an App Note (see http://www.state-machine.com/win32/AN_Win32-GUI.pdf), showing how to handle input from the owner-drawn buttons, regular buttons, keyboard, and the mouse. You can also view an animated demo at http://www.state-machine.com/win32/front_panel.html.
Regarding the size and complexity of the "Front Panel Win32 GUI Toolkit", the implementation of the aforementioned GUI elements takes only about 250 lines of C. The example with all sources of input and a lot of comments amounts to some 300 lines of C. The toolkit has been tested with the free Visual C++ Express 2010 (with the Express Edition Platform SDK) and the free ResEdit resource editor.
Enjoy!
The appliances you mention in your comment clarification to the question will never be using a windows PC, so low level windows programming is not a requirement in that case. In fact, I'd say its undesirable. Prototyping is about speed. It's about how fast you can put something together to show potential investors or upper management or some other decision maker.
You wouldn't want to spend the extra time with low level C and Win32 api until the project requirements were flushed out enough that you knew that was an absolute requirement for the final project deliverables (perhaps a server/PC monitoring tool?). Until then you want speed of development. Lucky for you the industry has tools for rapid prototyping and development of hardware like you describe.
My Preference for Prototyping with Embedded Development
As for my opinion as a developer, I like the .net microframework (.netmf) simply because I'm already a Microsoft .Net developer and can transfer a lot of my existing skills. Therefor I prototype with a FEZ microcontroller using C# under Visual C# Express 2010 (free as you required). Its fast, easy and you are working on the core of your project in minutes.
If your experience as a developer is different, you may look for a micro controller which is programmed using BASIC, Java or some other language to help with the speed of development by reusing your core skill set.
Addressing your Question Bounty Comments
Astonishingly large portions of the embedded software can be developed
on the desktop computer as opposed on the deeply embedded target. This
avoidance of the "target system bottleneck" can potentially improve
productivity by an order of magnitude, if done right. However, to
develop embedded software on the desktop, one needs to simulate the UI
components, such as displays (both segmented and increasingly
graphical), LEDs, knobs, and buttons. I'm looking for such UI
components written in plain Win32 API in C for easy integration with
embedded code to be developed and tested on the desktop Windows.
I did embedded development full time professionally for well over 4 years as well as many years surrounding that part time. While what you said above is somewhat true, it will not save you time or money which is why everyone is confused about the motivation for this strategy. We spent years trying to put out a windows emulator for this company's hardware devices that would theoretically save time for prototyping. It was always a pain and we spent many more hours of work trying to emulate the experience than if we just went straight from sketched UI drawing specs to real development. The emulator lagged behind hardware development and often wouldn't support the latest features until 6 months or more after the hardware was released. It was a lot of extra work for very little value.
You will spend more of your time developing non-reusable win32 platform code and hardware emulation components than actually writing the code for the core project itself. This only ever makes sense for hardware vendors who provide this emulator as a 'value add' tool to potential 3rd party developers, but it does not make sense for prototyping new hardware designs.
Modern development environments like Visual C# Express 2010 with a FEZ microcontroller can compile, push the project output to the microcontroller, and then begin debugging just as fast or faster than you could compile and run a low level windows app in C emulating LCDs or LEDs or switches, etc... So your comment, "improve productivity by an order of magnitude", is simply no longer true with modern tools. (It may have been prior to the last 10 years or so.)
If you really, truly just want to simulate the embedded hardware visually on a PC use something like adobe flash to mock up a UI. But don't duplicate code by coding for windows when the final device you are prototyping won't be running windows (maybe it will be, but you didn't say that). Use the fastest most reliable prototyping tools available today, which is unequivocally not low level C and win32 api!
Maybe use StackExchange for Electronics?
Because this is a development oriented site, discussion about the merits of specific embedded hardware isn't really relevant. If you decide to refocus on using microcontroller electronics for prototyping (Arduino, FEZ, Propeller, Basic Stamp, Pololu, etc) you might ask for electronics hardware advice on stackexchange for electronics. I will say that most of those platforms are designed to facilitate the prototyping of LCDs, LEDs, buttons and interfaces as you outlined. You can usually assemble a few pre-built modules in a matter of minutes and be ready to start coding your project. Huge time savings can be had here.
You are asking for too much you need to take a look # proteus.
http://www.labcenter.com/products/vsm_overview.cfm
As Mahmoud said, you may find your code solution with prototyping example in proteus professional. It is one of popular software for prototyping, simulation and coding, you can download proteus professional for free and check their manual.
Best of luck

Doing native GUI with Ruby

I'd like to develop a desktop app with Ruby. However, I'd like to have a native GUI on every platform (as opposed to a cross-platform GUI Toolkit that looks consistently awful across all platforms).
I expect to have to do different GUIs for each platform (as it's not just looks but also behaviors and idioms that are different), but I wonder what my options are? Especially wondering if there is a clean way to separate front and backend and bind the data properly?
Target Platforms are Windows (Vista & 7, XP is a Bonus), Mac OS X (Cocoa) and Linux (GTK? Qt? No idea).
The Ruby language has excellent Qt library bindings and your scripts will be cross-platform.
Two Kinds of Cross-Platform
It turns out there are two kinds of cross-platform UI toolkits.
One kind draws its own controls, and, like you said, looks equally bad on all platforms. Even worse: it looks out-of-place on all except one.
But there is another kind that just provides a harmonized interface to the native widgets. The best of example of this kind of toolkit is SWT1.. It looks, it is, approximately fully native on each platform, yet it has but a single API.
So you shouldn't simply rule-out all cross-platform toolkits, just rule out the ones that fake the native UI.
Develop the Wrapper Interface
There is a second way. If your program's interface with the user can be directed through a relatively narrow interface, you can simply develop to that interface and then implement the bottom part of it for each platform you want to support. Yes, you have to rewrite one module, but all the other modules stay exactly the same and you get native widgets. You also get the smallest possible executable without lots of bloat.
Perhaps most importantly, you don't have a complex and opaque software layer between your code and the native windowing system. You will probably save as much time debugging as you spend writing the extra module for your first port.
1. I know my Java examples won't help you much unless you are using jRuby, but SWT vs Swing is a really pure example of the right-vs-wrong (IMHO) UI toolkit divide.
The WxWidgets interface claims to use the native interface on Windows, OS X, Linux and UNIX through one API.
Coworkers who have used it in the past enjoyed it well enough, but I've not used it myself.

is pure c/c++ code possible in webOs intead of javascript?

HP webOS needs javascript,HTML to develop applications.but is it possible whatever we can do through javascript in c++ or c? have they given any API list for it?I found PDK is for openGL game porting .Have they given any option for C++ developers?
If using C/C++, you are essentially on-your-own when it comes to the interface unless you build a plugin in for a hybrid PDK app that uses HTML and JavaScript for the UI. You are provided with APIs for system services and accessing the hardware (drawing to the screen, keyboard presses, etc.) in C++. The intention is that you'll use C/C++ when you need speed, and JavaScript the rest of the time when speed is less critical (as in, you're not doing anything that the user will notice as slower than if you had written the code in C/C++).
To answer the question I sense lies beneath your question, you're probably going to have to learn JavaScript to program for webOS unless you want to develop openGL games only.

opengl dependencies

I am new to opengl and using C#,opentk for development. My Application is very light weight (just 2d graphics) and i am planning to use software rendering when hardware rendering is not available.
How do i make sure software rendering works on all computers ? (when hardware rendering is not available.)
Should i distribute Software rendering libraries like Mesa, myself. or it will already available on all (Windows) OS ?
in other words, opengl32.dll is always available on all modern windows OS ( > XP SP2 ) or should i distribute that also ?
( My Application is very simple (simple 2d graphics) as of now. I selected opengl instead of GDI+/WPF because, i may extend it to 3D in future. )
OpenGL is a system library. You should not distribute it with your application. Especially on Unix/Linux systems, where it should be installed using the distribution's package manager.
Since opengl32.dll is included in Windows, it falls back to Software Rendering automatically if the pixel format you chose in your application isn't hardware accelerated by the graphics driver.
I tried leveraging OpenTk as well, but in itself creates a dependency and - particularly as a newbie - doesn't really do anything but confuse learning OpenGL versus learning someone else's interpretation of the framework.
OpenGL is - as the other answerer suggested - a system library. With this, it's a functions contained in a C DLL which you import through the API.
OpenTK imports these functions for you, that's the only real benefit it adds, but in doing so, many of the types are reinterpreted as are the function calls as per the author of OpenTK.
This creates an additional learning curve - as most of the internet references you're going to find are going to be OpenGL - so not only will you be struggling with understanding OpenGL - which isn't easy - but you're also going to be dealing with OpenTK interpretations of the OpenGL standards.
Now keep in mind that MANY open source projects such as OpenTK start as open source until they get sufficient enough user base, when they convert over to a for profit model. So let's say you learn and become dependent on OpenTK, well if/when they switch to a for profit model and you're tapped on cash, you are SOL (Shit outta luck). Or you have to pay their price.
What I did was - I took the source for API mapping for OpenTK's OpenGL mapping and renamed everything as per my tastes. it's a bit of work, but it's worth the labor and it helped me get to understand OpenGL.
As for distribution. I have absolutely no external dependencies I rely on other than the OpenGL DLL which should already be on the system.
ALL the DLLs you need for OpenGl will ALREADY be preinstalled on any windows OS you're dealing with. I can't speak for other OS flavors, but I suspect this may be the case.
On a final note: OpenGL handles 'toggling between software and hardware rendering' innately. So libraries like MESA and OpenTK add VERY little value at HIGH potential costs.
What are those costs?
1) Redistributable packaging and licensing. They still come with a license and most license are subject to change at any time.
2) Conversion from open source or free distribution to a for profit model.
Invest in yourself. OpenGL documentation is vast and at times confusing, and my advice is to avoid the knee jerk temptation to 'take the easy' path versus the leverage other's models - for one simple reason.
I know you're using this for a 2d application. And even if you're using Orthogonal view, the fact of the matter is you're learning OpenGL with is a patterned with 3d in mind. So give yourself the gift up front of teaching yourself because there really is no 'easy path' to understanding 3d - and thus no real value add to the external dependencies you're leaning towards using.
One thing to keep in mind: Modeling. IF/when you switch to 3d modeling, doing vertex creation through hand coding in opengl is a bitch. I use Blender to create my obj models in and read those into my own c# application which reads in the 3d models and lets me manipulate them from there.
I HAD been using C++, which sure is faster, but once I converted the APIs to c# code and started managing my own memory leveraging the garbage collection model, it became SO much easier than having to learn someone else's library.
Dont use redistributeables. And leverage the code from OpenTK, with modification, but don't include OpenTK as a redistributeable.
That's my advice.

Resources