Tag Archives: java

Soruces for simple OpenGL 2.0 HUD/GUI for android

device-2014-07-18-210940As I’m currently prototyping a new game for Android, I was in need of a quick (and simple) way of adding some selectable text elements on top of my 3D OpenGL ES scene. So I created a simple demonstration with full source (you can get them from my OpenGL ES git repository) that renders a 3D scene and a basic hud with clickable text elements on top of it in orthogonal mode.

The text elements are rendered to an OpenGL ES texture, using android’s canvas, making this a very flexible way of drawing text on top of an OpenGL ES scene. Note that this isn’t very fast, so the texture should only be updated when necessary. The demo has a menu along with a fps counter, so the texture will be updated every second, and the elements can be clicked and the hud’s observers will be notified with the clicked element’s id so you can easily react on user input.

Though this isn’t something you’d use in a production app where performance is crucial, it should be good start for rapid prototyping needs where you need to have some basic gui or hud to issue commands. And you’re always free to improve the sources (feel free to fork) to make it perform better, by e.g. only updating the areas of the texture where text changed, instead of updating every time if one of the elements is changed.

2013 – Final posting – Dwelling in randomly generated mobile Dungeons

Another year has (almost) passed, and as with the previous years I’ll keep up the tradition of publishing a final posting before heading into 2014. From a personal point-of-view, 2013 wasn’t thad bad (though still far from perfect) like some of the years before. I still earn my money as a sofware developer using delphi and love my job, and recently I even bought the house I’ve been spending most of my 32 years in (though there is still a bit of renovation to be done, but the house itself is in a good shape).

As far as my personal programming stuff goes, those of you that follow my blog may have (hopefully) noticed that I moved away from Delphi and went over to Java, mainly because of mobile development for Android devices. I’ve been wanting to develop for smartphones and tablets for some time and the move was easier than I expected. It didn’t take long to get a gripe of the Java syntax, and together with Eclipse I’m pouring out lines of code like never before. The more I work with Java (and Eclipse), the more I realize how far behind Delphi has fallen. It’s sad to see that Embarcadero seems to focus on the wrong areas of Delphi, and instead of fixing their base and giving the community a free Delphi version they hold onto stuff like FireMonkey and decided to release a new Delphi version every 6 months. Though quick release cycles can be good, I don’t think they’re suited for such an expensive development tool. But well, if you take a look around the hobbyist community you’ll quickly notice that nobody cares about Delphi anymore. Especially for OpenGL development, people either moved to Lazarus and/or Free Pascal or (like me) moved over to another programming language. The sad thing about this is that communites I’ve used to be active an have gotten pretty quit over the past few years.

And no posting without any programming stuff! Since I’m totally not into that christmas and holiday stuff I had plenty of time for coding during the recent days, and so I decided to do something gaming / OpenGL related for Android. And therefore I ported the random dungeon generator I described in this article over to Java, and though it’s still in it’s very early stages, you can already walk around randomly generated dungeons on a mobile device.

dungeoncrawler_2013-12-29-204317 dungeoncrawler_2013-12-29-204526 dungeoncrawler_2013-12-29-204538

This is my first Java project that uses several different techniques. It’s based on OpenGL ES 2.0, uses different shaders for e.g. per-pixel lighting (which makes for easy flickering torches), a texture loader, a (yet simple) touchbased OpenGL GUI and much more. I don’t know if I’ll make it into a complete game, but I want to at least release a techdemo. I’ve got plenty of ideas and want to make heavy use of gestures for e.g. solving puzzles, making attacks, etc. I’m also not sure about the setting yet and still swaying between a more common theme (medieval, like the Eye of the Beholder-Series), something in the future (maybe a trapped cyborg in a futuristic factory) or something dark, psychologic and eerie in the vein of Trugbild. Maybe I’ll even open-source it 😉

And thus ends 2013, may 2014 bring forth more Android-related stuff (as long as Cthulhu won’t wake up from it’s eternal slumber cthulhu)

In addition to wishing all of my readers and friends a happy and healthy 2014 I’d like to dedicate this posting to a very special person that’s going through a hard time, seing that makes me pretty sad and it’s even harder not knowing how to really help 🙁

From Delphi, Windows, OpenGL and Newton to…

box2dtest_01 …Java , Android, OpenGL ES and Box2D. That’s what I’ve been doing the last few days during my (currently rather rare) coding sessions. I wrote a simple physics playground using JBox2D for my phone that allows me to drop different objects by the touch of a finger and also uses the orientation sensor to change the gravity vectors. Putting lots of dynamic objects inside a confined box, and seeing them fall over by just tilting the phone is a fun affair 😉

I also wrote a (very simple) OpenGL ES renderer to display the physics bodies. Luckily OpenGL ES is pretty close to recent OpenGL versions (if you skip all the legacy immediate functions), and getting the renderer up-and-running only took a few hours.

And I actually don’t miss Delphi that much for my hobby development (Though I’m still earning my money with it), Java has come a long way, is a modern language that actually evolves (whereas Delphi, in terms of the language hasn’t changed a lot in the recent years) and writing quality code kinda seems easier, even though I’ve actually just started writing code with Java. I’m not yet feeling as comfortable with it as with Delphi, but writing Java code gets easier and easier by every line of code.

So for the next few weeks (or months) I plan on playing around with realtime physics on Android, and especially with all the different input methods and sensors that simply aren’t present on PCs. I’m still not sure about what type of game I’m gonna do for Android, but I have some initial ideas that I’d like to implement. Maybe I’ll even port Trugbild to android, just to get some more experience developing for mobile platforms using OpenGL ES.

 

New target : Android

I’ve been using a symbian “smartphone” (a Samsung SGH-i560) for ages now, but finally decided to swap it for a new and shiny Android device, mainly to code on.
So I recently bought myself a Huawei Ascend G510. It’s a middle class Android handset with a dual-core CPU (1,2GHz) and a 4.5″ screen that supports OpenGL ES 2.0 that doesn’t cost a fortune (~140€) and condidering the pricetag it’s a pretty good phone.
So once the battery was loaded I attached it to my PC and started to develop on it right away. I started off with the native FPC armv7-cross compiler using native Android Controls, went over to integrating Free Pascal (JVM) into Eclipse and did some basic OpenGL ES demos with both of them.

And though it may be appealing to code in pascal for the Android platform, I decided to go with Eclipse and Java. Java has a lot in common with Delphi, and getting used to it’s syntax only took me a few days and I’m already creating productive sources. Actually I kinda like coding with Java (and Eclipse). You get lots of modern language features that Delphi has been lacking for years, and the code features (auto completion, correcting problems, etc.) are just great. And best of all is that you get it for free, which is no comparsion to the expensive entry into the Android world with Delphi XE5 (which btw. forces you to use FireMonkey).

So after getting used to Java and Eclipse (in the form of ADT) I started work on an Android version of the glCapsViewer, called “glESCapsViewer”. It’s already up and running, getting the implementation details. It reads out information on the device, the renderer, all available extensions and all supported texture compression formats. Next on the line is generating XML files for the repots and then uploading them to my online database.

I’m not sure yet on wether to just add the mobile OpenGL ES reports to the current caps database, or to add a sparate database. But I guess I’ll go for the latter way, as it’ll allow for more flexibility. This would allow me to e.g. also add information on the device iteself and wouldn’t inflate the desktop report database with OpenGL ES versions and extensions.

It’s not quite ready yet, but expect an Android version of the glCapsViwer in the near future. And also expect to read lots of postings on Android and Java. Once the glESCapsViewer ist done, I plan on creating my first mobile game, and it may be a port of Trugbild, as the gameplay itself is perfect for touch based devices. I’m even thinking about using the motion sensors to move along the scenery 😉