Slashdot Mirror


A Look at Java 3D Programming for Mobile Devices

An anonymous reader writes "IBM developerworks is running an article that describes the Mobile 3D Graphics API and introduces you to 3D programming for Java mobile devices. Sony's PSP has shown the graphics power you can put into a mobile device and mobile gaming. Although the average mobile phone is technologically behind this specialized game machine, Java seems to be helping to drive the market in a very definite direction."

34 of 196 comments (clear)

  1. Hello World by deltalimasierralima · · Score: 4, Funny

    Wow! Finally I can code 'Hello World' in full 3D glory with realistic 3D shadows!

    1. Re:Hello World by Jekler · · Score: 4, Insightful

      It's a common myth that Java is slow. Modernly, Java applications are (on average) only 10% slower than an equivilant C++ application. With appropriate optimization, that margin is even smaller. Even then, when it comes to 3D rendering, the application is usually running at the speed of the hardware, with the Java code not really even coming into play. In a 3D environment you could say the performance margin can be less than 1% difference.

    2. Re:Hello World by flithm · · Score: 2, Interesting

      Actually these days it's a myth that java isn't slow.  Especially for things like games which are very processor (and math) intensive, java is EXTREMELY slow.  Anyone who does a lot of programming (other than app programming, ie games, scientific, etc) knows this.  It's really only the java zealots (who don't understand that every tool has its purpose -- including java! but also including other languages -- probably because they only know one language) who push this idea, when it simply isn't true... it never has been, and never will be, it's simply not possible (without an instruction set that directly implements java bytecode, or a truly optimizing native java compiler -- and no gcj does not fit this bill).

      Don't believe me?  Try the following experiment:

      public class jprog
      {
              public static void main (String args[]) {
                      double t = 0, lp, ilp;
                      for (lp = 0; lp < 1000000000; lp ++)
                              for (ilp = 5; ilp >= 0; ilp --)
                                      t ++;
              }
      }

      Obviously it's slightly akin to the bogomip, but it does illustrate an important point.  All this does is do some floating point math, in a loop, 5 billion times.

      Quickly port this code to C, compile with gcc, and on my machine its execution takes 16.8 seconds.

      Compile and run this code with Sun's latest java release and it takes 1 minute 18 seconds.  That's approximately 1/5 the speed of C!

      Java is just plain really really slow.  It's not so bad if you're just doing GUI stuff, or simple application programming since that's not processor intensive, and yeah I could see a general slow down of 10% being reasonable.

      But for anything else, especially games, java is not a smart choice.

      Please java zealots stop spreading lies.  Take the time to learn many languages, and stop trying use a single tool for every purpose!  Java is great for certain things, but execution speed is not one of them.

    3. Re:Hello World by Jekler · · Score: 4, Insightful

      I'm far from a Java zealot. I'm a programmer, language is an insignificant issue. The fact is, I've done most of my programming in C++. I avoided Java for precisely the reason that I thought it was much slower, and as it turned out a lot of my assumptions were wrong. It's even fast enough for 3d games, like Megacorps Online http://www.megacorpsonline.com/game/

      I know how to use plenty of languages, I learn new ones all the time. I wasn't just guessing the execution speed of Java, I was speaking from experience. As for the test code you use to show Java is slower, that's a huge mistake. You've composed a test which is ideal for C++ to execute. That's like proving a jeep is faster than a porche by doing time trials in offroad terrain. Given a more abstract problem than "Go through these loops a billion times", the solution in Java wouldn't even resemble the equivilant solution in C++. You can't approach the same problem identically in both languages, if you do, you're not writing Java code, you're writing C++ code in Java.

      There's a lot of utility code that would be necessary in a C++ program that's not necessary to perform the equivilant task in Java. Each language isn't just different syntax, you need an entirely different way of thinking. Trying to port a solution line for line into a different language is senseless.

    4. Re:Hello World by Anonymous Coward · · Score: 2, Insightful



          I agree with most of what you're saying but I do think that rallying
          around a standard also has it's advantages. That's why C became such
          a reference point for scientific and engineering software. It works
          and it's ubiquitous (available everywhere). Java is similar. It has
          many problems too (like every language) but if Computer Scientists
          and programmers rally around Java as a language of choice it will
          continue to improve and allow us even more freedom in where and how
          it is used.

          BTW I ran your little test in Java and C. I was incredibly close to
          your number in Java (1 min 20 sec) but nearly identical code in C:

      #include

      int main ()
      {
              long double t = 0, lp, ilp;

              for (lp = 0; lp = 0; ilp --)
                      {
                              t ++;
                      }
              }
      }

      Compilied with gcc it took 2 minutes and 30 seconds to run!!
      Go figure.... If you change back to just a double (Vs long
      double) it finishes in 1 minute 10 seconds. So I think you
      have to admit that just saying Java is slow is a tremendous
      over simplification.

    5. Re:Hello World by Jekler · · Score: 3, Insightful

      I apologize, what I said could be wrong. The test may not be more suited to C++ than Java. Truthfully, a short test like that could favor either language or neither. It's too small of a test to be a significant benchmark of a language. If you could test the performance capabilities of an entire language with half a dozen lines of code, no one would ever create an entirely new language until they found a way to execute 4 lines of code faster.

      The test given doesn't bring into a single feature that's unique to any language. It tests the execution speed of a loop and the increment/decrement of primitive types which is likely to be equally fast/slow in any language as it just comes down to the processor speed. To test Java as a language, a good start would be testing the creation of objects, allocating and deallocating arbitrary amounts of memory, and calling random methods on randomly sized objects.

      Objects and memory management is where Java shines. Many tests that compare Java's speed to C++ speed tend to focus on areas where C++ shines and Java performs poorly, like resizing containers.

      One reason Java really shines with objects is that Java doesn't run into the performance overhead incurred by copy constructors. There are a lot of situations in which Java will perform more slowly than C++. There are also situations where Java performs better. The end result is that Java's performance and C++'s performance can't be compared based on a single test. Many people craft a single test and based on the results of one test they brazely declare that Java is always slower. If, one day, it was 100 degrees in NYC, and 90 degrees in Las Vegas, one wouldn't say it's always hotter in NYC. By the same token, you can't compare language performances with a single test. The only real way to compare the performance of two languages is to actually spec a real-world program and have two teams go about building it in different languages.

  2. Sony Ericsson phones by wertarbyte · · Score: 5, Informative
    --
    Life is just nature's way of keeping meat fresh.
  3. 3D Handsets by seanellis · · Score: 5, Interesting

    Quite a few handsets already support M3G, among them the Siemens S65, Motorola E680, E1000, V980, SonyEricsson V800 and K750i, and the Nokia 6630 and 6680.

    M3G is a lot lighter weight than Java3D, has high and low level APIs, and has its own compact file format for efficient packaging of assets.

    I've been developing M3G technology, both engines and games, since day 1 (I was our company's representative on the expert group), and I am happy that Slashdot has at last highlighted it.

    If you think retreads of "Mr. Do" and "Snake" are going to cut it in the Java space from now on, think again. You might like to look at Superscape's site for a taste of the kind of 3D games that are already out there.

    Developers might also want to visit Benhui.net's 3D Developer Forum.

    1. Re:3D Handsets by Agret · · Score: 2, Informative

      There is just no comparison between the PSP and a mobile phone (using your links and the psp comparision in the original summrary)

      http://www.superscape.com/games/title.php?SB_3D,sc reens Phone basket ball game with "amazing 3D"
      http://www.1up.com/do/media?cId=3142148 PSP Basketball game

      --
      Have you metaroderated recently?
    2. Re:3D Handsets by seanellis · · Score: 3, Insightful

      The comparison with the PSP was in the original link, not my post. These are very different games on very different platforms.

      On the one hand, we have the PSP - an ultra-slick, hardware-accelerated, single-purpose device which is excellent at playing action games.

      On the other, we have almost-ubiquitous Java handsets (here in Europe, anyway), with enough processing power to run simplified versions of the console games. That is a niche begging to be filled.

      The hardcore g4merz will have a PSP. And probably a GBA, a GBM and an Atari Lynx just in case. Everyone else will have a cellphone. They are very different markets and will have very different expectations and different needs.

    3. Re:3D Handsets by mwvdlee · · Score: 4, Interesting

      Yes, I know most gamers have mobile phones.

      Did you also realize that practically the rest of the civilized world also has mobile phones?

      Gamers are but a small percentage of the mobile phone users.

      Especially when using "gamer" in the popular interpretation as one who primarily plays games in the popular (racing, FPS and sports) genres.

      I consider a fanatical phone user, a person who will frequently use SMS, MMS, WAP, built-in cam, built-in MP3 and in general know more than the manual does about the phone. By definition, these are people who are more "on-the-road" than a typical gamer and thus less likely to be a gamer. Apparently conventional popular game genres did not attract them enough to shift from being a hardcore phone user to becomming gamers. Logically, this means that such games would not attract them on their mobile phones either.

      Perhaps you should refrain from smoking anything for a while, might help you to actually understand what you're reading. ;)

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
  4. Just reminds me by olddotter · · Score: 4, Insightful

    I have a freind who used to work at a major cell phone company. I remember him telling me people would NEVER use java or linux in embedded products because the memory foot print was just too big.

    Ah, Moore's Law, what isn't practical today will be in 18 months (or 36 months, etc.).

    He is a smart guy, he just doesn't have the vision to look out that far into the future.

    1. Re:Just reminds me by IamTheRealMike · · Score: 2, Interesting
      To be fair to your friend, many phones (Symbian, BREW) don't use Java but provide their own C++ API. Many people who have used Java on mobile phones have found that performance and memory management are extremely poor and not really competitive next to C++ (though this is the technology I'm talking about rather than the footprint).

      Motorola now use the "JUIX" operating system which is a combination of Linux and Java so while he was definitely wrong, his mistake was simple enough - assuming that technological superiority would win out over mass-market/buzzword appeal.

    2. Re:Just reminds me by LarsWestergren · · Score: 3, Insightful

      Motorola now use the "JUIX" operating system which is a combination of Linux and Java so while he was definitely wrong, his mistake was simple enough - assuming that technological superiority would win out over mass-market/buzzword appeal.

      Ease of development, maintainability and porting are also forms of technological superiority, and in this case perhaps more important than pure performance?

      --

      Being bitter is drinking poison and hoping someone else will die

    3. Re:Just reminds me by Bogtha · · Score: 3, Insightful

      I remember him telling me people would NEVER use java or linux in embedded products because the memory foot print was just too big.

      Java was designed for embedded products.

      He is a smart guy, he just doesn't have the vision to look out that far into the future.

      Or the past, apparently.

      --
      Bogtha Bogtha Bogtha
  5. 3D programming and multiple screens on my sony by jurt1235 · · Score: 2, Interesting

    So will I see the frontside of the object on one screen, and when I turn the phone around to watch the other screen, the back side of the object? That would be pretty cool!

    --

    My wife's sketchblog Blob[p]: Gastrono-me
  6. Bad Idea! by Agret · · Score: 3, Insightful

    3D Java Games? Anyone re-call the N-Gage?

    This seems like a bad idea to me. Instead of trying to make a phone compete with a gaming console they should be looking for more innovate things that they can make phones do.

    --
    Have you metaroderated recently?
  7. How much would a phone.. by CyricZ · · Score: 4, Insightful

    How much would it cost these days for a phone that did not have any unnecessities like 3D graphics, address books, calendars, clocks, and so forth? I'm talking about a cell phone equivalent feature-wise to your typical 1960s telephone. How terribly cheap could something like that be produced for? I'd almost be inclined to think that you could find them in vending machines.

    --
    Cyric Zndovzny at your service.
    1. Re:How much would a phone.. by eneville · · Score: 3, Insightful

      ebay for the nokia 8310! It's still one of the smallest and useful phones.

    2. Re:How much would a phone.. by Tryfen · · Score: 2, Informative

      Nokia 1100.

      Does nothing but voice and SMS.

      Costs ~£20 on PAYT. That's ~USD$40.

      --
      If a square is really a rhombus, why aren't all triangles purple?
  8. And queue the Java-being-slow comments... by MaestroSartori · · Score: 3, Insightful

    ...even though back in 2000 I wrote a 3D software engine in Java that was more than acceptably fast enough to run Wolfenstein-quality gfx on a P75. And I knew fairly little about optimisation in Java, so that could probably have been faster. Throw in hardware acceleration, and you can bet these'll be fast enough for at least ok game-level graphics. Beyond games, I don't know what use this would have...

    1. Re:And queue the Java-being-slow comments... by IamTheRealMike · · Score: 2, Interesting
      Most phones use the "KVM" micro virtual machine which does not do JIT compilation (imho a very stupid thing to do on a phone anyway), instead relying on a pure interpreter approach. It does practically no optimisation and has a very simplistic garbage collector. It is by no definition of the word fast. Sun now provide a JIT micro VM that implements HotSpot but even then, as we saw in an earlier Slashdot story basic optimisations like stack allocation are beyond it and most phones don't seem to use it anyway.

      Unfortunately the javac compiler doesn't do any optimisation either. So you're left running unoptimised code exactly where you need it most. One of the things I want to experiment with next time I have some spare hours is using GCJ instead of JavaC to produce class files for phones. I suspect there would be an improvement.

      It would have been smarter IMHO to embed a static compiler into phones (like GCC) and then use that to produce native ARM/whatever binaries at install time using the full range of optimisations possible. It would take longer to install apps, but this is a one time cost, and you could mostly eliminate the startup overhead of the VM and the speed penalty of bytecode interpreting.

    2. Re:And queue the Java-being-slow comments... by vidnet · · Score: 3, Interesting

      For a taste of what java can do, try Jake2. It's a Quake2 engine written entirely in java (easily started via webstart, on both linux and windows, and automatically downloads the Quake2 demo files if you want).

      You would never be able to tell that it's java.

  9. Explain this to me by RootsLINUX · · Score: 3, Insightful

    Why would I want (or even care) to have 3D graphics on my mobile phone/device? The screen is already tiny. I'm sure 3D graphics are more computationally expensive and power-consuming than traditional 2D graphics. And in the end, I'm still just looking at a 2D projection of a 3D image. Its not like I want to be playing Half-life or another FPS on my cellphone. I'm sorry but this just seems stupid to me and I get the feeling that the only people who will want this "feature" will be the hard-core tech gadget geeks out there. Does a 3D API bring *anything* useful to the mobile table???

    --
    Hero of Allacrost, a FOSS RPG for *NIX/*BSD/OS X/Win
    1. Re:Explain this to me by CyricZ · · Score: 2, Informative

      Do you or I need it? Of course not. We'd get a phone to increase our productivity. But that's just because we're into getting work done.

      They've reached a point where basically everyone has a cell phone that does everything they _need_ it to do. Now they need to start throwing in gimmicks like this to get people to upgrade. This is especially true for the "teenyboppers" or "hardcore gamerz" who are easily amused by gadgetry such as this. Chances are there'll be many 13-year-old boys and girls begging their parents for a phone with 3D graphics support, even though it has very little practical benefit.

      --
      Cyric Zndovzny at your service.
  10. Gaming on the Phone !? by betasam · · Score: 2, Informative

    One of the early companies focusing on Mobile Phones was Fathammer. Initially they started out with a ports of Doom engine based classics; now seem to have a nice collection. I believe the stronger driver of applications on phone platforms is the phone hardware. Java 3D API is one more trial at luring in more applications by providing easy-to-use API. But even if Handspring and Palm were to provide 3D programming API for their Treo series (or anyone else does likewise), it still depends on the hardware. Things one would be bothered about would be battery times and audio which actually adds on to gaming experience (and already no one wants to hear loud ringtones everywhere!)

    Nokia airs an ad in India which almost drives in a message saying "phones are for talking" while showing a model with a vidcam and video playback. I wonder how many people find time to use the "other" applications on the phone apart from a PIM (Phonebook/Calendar). Further, with 3D games what about an added issue of people getting something akin to Doom Induced Motion Sickness(DIMS)? I have found controls for a 3D game (on my Treo) pretty difficult to use for a 3D racer game, which kind of kills the experience. I wonder how many people play 3D games on their phones comfortably, and where they get them from!

    --
    No Greater Friend, No Greater Enemy! (Lucius Cornelius Sulla)
  11. Neat article by LarsWestergren · · Score: 3, Interesting

    I have some friends who are working with developing Java games. So far the big money is not in developing titles for phone companies portals (or even worse trying to sell them to the end user yourself) but to develop ad games for companies who make them available for free downloads, usually as a part of a competition.

    From what I understand, the best part of the job is that since graphics on mobile phones and other limited devices are so cruddy development focus tends to be on addictive gameplay rather than eyecandy. It is also still possible to be a small independent game studio, no need for a big art studio to render hours of CGI, etc.

    Worst part is that just about all phone developers are very sloppy when it comes to implementing the J2ME standards and all models tend to have their own quirks. Sony Ericsson and Nokia are probably the best, but that is not saying much. So in this case, it really is "write once, debug everywhere" type java.

    Mobile gaming is really taking off, I read on GameDev for instance that mobile game developers Gameloft increased their workforce from 432 to 1375 employees.

    --

    Being bitter is drinking poison and hoping someone else will die

  12. Re:A very definite direction by @madeus · · Score: 2, Insightful

    A new way to make EVEN SLOWER crummy Java games indeed! Because playing Rayman at really low res @ 5-10 FPS on the N-Gage was just so much fun, everyone should be able to re-create the experience!

    Java is in no way driving 3D games development - on mobile platforms or otherwise, this is just a bizarre article. It comes as no surprise to me the IBM/SUN employee who submitted this article wishes to remain 'anonymous'.

    There are currently zero mobile Java games available that compare even remotely favourably to a decent GBA title, let alone with any titles available on the DS or PSP.

    Typically, the frame rates are awful, the interfaces are not responsive, the sound is often out of sync and of poor quality (as are the often tiny sprites). Even something like a Java based chess game with a slow and unresponsive interface can be frustrating to use.

    Mobile devices are constrained by battery life, which in turn means they tend to be fairly modest devices. They simply don't have time to waste on a JRE and titles need to be heavily optimised on a per-platform basis, even for very simple games (because games software in particular has to be responsive, or users will very quickly become frustrated).

    Of course if your writing reasonable code in the first place, it shouldn't be all that difficult to keep it portable (something that most game developers manage without too much trouble anyway).

  13. Java! That's the answer! by MBCook · · Score: 2, Insightful
    There! That's it! Java is the solution!

    There are so many people (me included) who would love to be able to program for the PSP, but they won't open it up for various reasons (fear of piracy, mostly).

    So why not give people a Java sandbox (J2ME would be fine) to play in? That way they can make games and other fun things, but they won't be able to use it to boot pirated games off memory sticks and such (unless they REALLY mess up the JVM). Seems like a perfect solution.

    They sold the Net Yahorzee, why not give us this? Download a copy today (tied to the PSP's serial number to prevent copying?) for only $20! They'd make a fortune.

    --
    Comment forecast: Bits of genius surrounded by a sea of mediocrity.
  14. Re:A very definite direction by LarsWestergren · · Score: 3, Insightful

    Java is in no way driving 3D games development - on mobile platforms or otherwise, this is just a bizarre article.

    They don't have to "drive" 3D games development, they just have to be fun enough that people with mobile phones want to play them.

    There are currently zero mobile Java games available that compare even remotely favourably to a decent GBA title, let alone with any titles available on the DS or PSP.

    Oh, I agree DS or PSP games are more fun, it would be strange otherwise since they are dedicated gaming machines. Thing is, there are many millions more mobile phones sold. Not all people are hardcore gamers who are willing to pay for one of those devices. Some just want a few minutes of diversion while on the bus. A Sudoku puzzle or similar. And this article shows that these games are getting better and better.

    Typically, the frame rates are awful, the interfaces are not responsive, the sound is often out of sync and of poor quality (as are the often tiny sprites).

    That is just FUD. I have played plenty of fun and responsive Java games. Still, it must be said that more developers should focus on making addictive puzzle games or similar rather than action games. As you point out, the processor, the screen and the input possibilities are by necessity rather limited.

    --

    Being bitter is drinking poison and hoping someone else will die

  15. John Carmack by vasqzr · · Score: 2, Informative

    He made a comment a while back:

    "The biggest problem is that Java is really slow. On a pure cpu / memory / display / communications level, most modern cell phones should be considerably better gaming platforms than a Game Boy Advanced. With Java, on most phones you are left with about the CPU power of an original 4.77 mhz IBM PC, and lousy control over everything."

  16. Opensource 3D on every phone ? possible (*caugh* ) by rzr · · Score: 2, Interesting

    Just to let you know, that 3D is possible on most java phones
    with my embryonic diet3d library :
    http://rzr.online.fr.nyud.net:8090/java.htm

    OK lot of work to be done to be M3G compliant... (btw, i am open to contribs)

    But what is bugging me : is J2ME the only alternative to WinCE or symbian ?
    since most Linux handset doesnt not provide other API (beside QTopia and his friends)

    --
    -- http://rzr.online.fr/
  17. 3d user interfaces by Goodbyte · · Score: 2, Informative

    I have just had my final lecture in a course on Mobile Computer Graphics and there is a lot more to mobile 3d graphics than producing nice games. Especially there was one lecturer from TAT that makes user interfaces for mobile devices, and the possibilities for creating more userfriendly interfaces are endless with 3d graphics. I am not just speaking of eye candy, but useful animations that help the user navigate the menu tree.

  18. Re:Only for JIT VMs by Hal_Porter · · Score: 2, Informative

    Sort of. Most of the ARM9 cores in mobile phones have a very clever hack that lets them execute 80-90% of byte codes in a single cycle by mapping them to a Arm instruction with an extra stage on the front of the normal Arm pipeline. The rest trap to ARM code that emulates them.

    http://www.arm.com/pdfs/JazelleWhitePaper.pdf

    The real ARM instruction set is nothing like Java BTW, it's a slick Risc chip where all instructions are conditional, and you get shifts for free, whereas the Java VM is stack based.

    http://en.wikipedia.org/wiki/Acorn_RISC_Machine

    --
    echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;