Thursday, May 15, 2008

Porting monolithandroid from m3 to m5


The application that I am developing, monolithandroid, currently does not run under m5 series SDK. Why? My app uses OpenGL/ES and there have been significant changes to the way OpenGL/ES works under android from m3 to m5. In a nutshell, in m3 you can use a plain view and intermix OpenGL and Canvas calls. In m5 this is not currently allowed. This was a major problem because the onPaint method of the View Object was used to draw text such as score and level information, as well as the application backdrop (a picture of the moon). There are ways to circumvent these problems and fix the application so that it works on m5. How? You can use a SurfaceView to draw the OpenGL objects, and you can use an overlay to draw text on top of the SurfaceView. And the backdrop? Actually you can use a textured image (an OpenGL object) to draw the backdrop, with the added bonus that you can easily rotate and scale the image. To sum up, monolithandroid under m3 used a class named GLView to draw everything on screen. For m5, 4 new classes were introduced in place of GLView:
  1. GameOverlay (used for drawing status text and scores)
  2. GameSurfaceView (used for holding a surface for OpenGL drawing)
  3. GLThread (used for actually drawing OpenGL objects)
  4. Square (used to load a textured square for the backdrop image of the moon)
In order to create an overlay, you can use the following code


public void onCreate(Bundle icicle) {
super.onCreate(icicle);
overlay = new GameOverlay(this);
optionsView = new OptionsView(getApplication());
android.content.AssetManager mgr = getApplication().getAssets();
gsf = new GameSurfaceView(this,overlay);
gsf.setViewType(GLThread.VIEW_GAME);
gsf.setGameType(Monolith.GAME_MONOLITH);
setContentView(gsf);
gsf.setVisibility(View.VISIBLE);
this.addContentView(overlay,new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,android.view.ViewGroup.LayoutParams.FILL_PARENT));
}
You can browse the full code at http://code.google.com/p/monolithandroid/source/browse

It is under svn->trunk->monolithandroid->src->org->teacake->monolith
So after I made these changes, monolithandroid sort of works. However, there are some problems to be addressed, like the time it takes on startup to load the moon image and convert it into a texture.
I would like to take the opportunity to thank Ed Burnette for sending me a preview PDF of his forthcoming android book, "HelloAndroid", and I must say that it looks very, very promising. Way to go, Ed! You can find out more about it at: http://www.pragprog.com/categories/upcoming
I admit that I shamelessly copied some code (the code for loading textures) from it.
Also I would like to thank plusminus and all the guys at http://www.anddev.org where you can find many interesting tutorials, like the following: http://www.anddev.org/textured_cube_opengl_code_sample-t813.html
Excellent work, guys.

Friday, May 9, 2008

I did not win Android Developer Challenge but it's OK

A couple of hours ago I received an email from google that informed me that I am not one of the winner of Android Developer Challenge. To tell you the truth I was not dissapointed. I did not put a lot of hours behind my application, it did not exploit a lot of the platform features and more importantly, it was unoriginal. I am sure that Google's intent behind Android Developer Challenge is to promote original applications, that showcase their platforms strengths. MonolithAndroid (my app) on the contrary only shows OpenGL/ES and touch screen functionality.
To sum up (monolithandroid versus the winning apps):

So from the above, it is easy to see why my poor tiny app did not win ADC, and why I am not whining about it. The question is, can this meek app be transformed into a winner? I don't know, but I will do my best to make it better. And since it is open source, you can take a shot at it!
On Monday we will probably have more information about the winning applications, and see how good they are. Until then, congratulations to the winners (for winning!) and the loosers (for trying). Cheers, guys.

Monday, April 14, 2008

Android Developer Challenge Part One Ends Today

Today the first part of Android Developer Challenge (ADC) ends. Good luck to all the folks who submitted an application! So in a few days or weeks we should have a new version of the SDK released, because Google did not want to release another SDK release before ADC ended, not to further confuse developers. As a lone developer, I depend on a stable SDK and toolchain and I think that the next releases of the SDK will fix things without breaking existing stuff. As you may have noticed, I did not update MonolithAndroid for the m5 series SDK, because I got an error message that informed me that the functionality I intended to use is currently broken and will be fixed in a future version of the SDK. I decided to wait for the fix, because I didn't have the time to change my code. Also, out of laziness and being put down by the major SDK changes of m5 series, I did not add any of the originally planned functionality to MonolithAndroid. Now that ADC is over, I will take my time in developing this little baby project of mine.

Wednesday, February 13, 2008

The new SDK killed my app, well almost :-(

Finally the new Android SDK (named m5-rc14) is here! So I eagerly downloaded it. Well the good news is that now Android has a brand new UI, and some enhancements. The bad news is that monolithandroid refuses to work. Hmm... you might think, maybe with a little bit of tweaking here and there you are only a few lines of code away from your app working again. Well, that maybe the case for most android apps written with the previous SDK, but not with mine.
Yes I have made the necessary changes to android.xml, and to various other xml files, and I even replaced a few method calls here and there, but the problem is that when I run my app in the emulator I get the following window.

That means, my fellow androids, that without major code changes, my app is not going to work with the current version of the android SDK! For now, if you want to use OpenGL/ES you HAVE to use surface view! Ouch! So back to the drawing board! I hope that I will be able to update my code soon. But I shouldn't complain! That's the price that an early adopter has to pay...

Waiting for the new android SDK

As some of you may have noticed I've put monolithandroid development on hiatus. The reasons: Some personal mishaps (which include my broken elbow, my desktop computer dying of old age and increased workload in my dayjob). But the main reason is that I am waiting for the brand new release of the Android SDK. I hope that the new SDK will correct a few bugs and that an increased number of API's and documentation will become available (for example javax.sound.sampled and javax.sound midi). The new SDK will sport a new UI as I hear (designed by TAT?). In the meantime, in Barcelona, Mobile World Congress is taking place. I wish I was there because I hear that a few manufacturers are demoing android powered devices and the first reviews are really positive! But no sign of monolithandoid so far ;-). Hey guys, monolithandroid is free software, load it up to your devices, I want to see it running in real hardware!

Thursday, January 3, 2008

Coding slows down when you have a fractured elbow.

Programming in the Android platform is very exciting. Unfortunately for me, it can be very slow, because from Saturday I have a fractured elbow. I went to the countryside to help my girl to handpick the olives from her olive trees. Where I live (that is Kalamata, Greece), everyone has at least one field planted with olive trees. And from November till February most folks are handpicking their olives. While I was at the field, I slipped and I unconsciously used my left arm (which is the one I use the most) to stop my fall. But in the process, I hit my elbow pretty hard. I went to the hospital and the X-Rays showed that I broke a bone near my elbow. So now my hand is tied and I can only move my fingers. The doctor said that my arm should remain tied for 15 days. So coding for MonolithAndroid will be slower. Arrgh!

Wednesday, January 2, 2008

MonolithAndroid. Block game for the android platform.

It's been a while since I created this blog. The fact that I made no posts since October does not mean that I sat idle. On the contrary the end of 2007 has been very active programming-wise. I was experimenting with the SDL library, when I realized that it would be nice to build a game in order to learn a few things. Two weeks later, I had an SDL version of tetris, with the added bonus that the rendering was done using open GL. Some of the code for the tetris game came from a tetris version I created 4 years ago, during a hot Greek August for the Mobile Windows Platform (Written in Visual C++). Creating the SDL rewrite of the app was easy, and using openGL made possible the rotation of the playfield using the mouse. I added a crude explosion effect when the player completed lines, and I came up with a rough 3d font rendering routine. All in all a nice programming project (done with Visual Studio 2005).

In parallel, I was toying with the sony PSP (playstation portable). I was trying to install and learn the open source pspsdk. After several attempts, I had an almost working version on my laptop. The next step was: "Wouldn't be cool, if I ported the sdltetris game to the psp?" PSP supposedly has SDL support so that would be a breeze eh? Well no it wasn't because I couldn't make the pspSDK SDL library work properly. The OpenGL part was misconfigured, or I don't know what. So I decided to bite the bullet and rewrite the game using psp sdk calls. It was coded in c++ using the gcc compiler and notepad++ as the editor. That took almost two weeks and the result is monolithpsp found in here: http://monolithpsp.googlecode.com

What's next? The launch of the Android platform, of course. Google launched the Android platform on November. When I read the first details, I decided to take a look at the Android SDK. After a few skimming on the API details, I saw that the platform supported OpenGL, so I decided to port my monolithpsp game to the Android Platform. I must confess that Android Developer Challenge gave me one additional reason to do so. So after a week of programming, the first version of the game became reality.(I am much more proficient in java than in C++ arghhh!). For more details, check this blog again. Oh and go check out
http://monolithandroid.googlecode.com for the monolith android game. See you soon!

Search the web