N900 and Qt support

All code submission.
Djardin
Posts: 129
Joined: Sat Sep 04, 2010 11:40 am

N900 and Qt support

Post by Djardin »

Hello guys,

As I wanted to play Wagic on my N900 phone, I've modified locally the wagic source to include the following stuff:
- QtCreator project support, I used it on both linux and windows to be able to create binaries for windows, linux and my N900 phone
- Qt wagic main class, it works for linux, windows and n900 but of course introduces a Qt dependancy to wagic
- OpenGl 2.0/OpenGl ES 2.0 support. This was required as my phone didn't like OpenGl 1.1. It's my first shader coding, so it's probably not optimized at all, but it works on Linux, Windows and N900. It mostly impacts the jGFX.cpp. This code does not depend on Qt so it could probably be reused for other platform supporting OpenGl ES 2.0 without Qt (iPhone, Android, ...)

As, it's getting close to being shareable (still some weird artifacts in some of the menues ...), I would like some guidelines or advices about the proper way to share my stuff with you.

Thanks for your answers,

Yann.
wololo
Site Admin
Posts: 3728
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: N900 and Qt support

Post by wololo »

Awesome!
I replied to your PM as well, but I'll say it here to: don't hesitate to post your files here directly, we will then try to integrate them to the SVN.
Djardin
Posts: 129
Joined: Sat Sep 04, 2010 11:40 am

Re: N900 and Qt support

Post by Djardin »

The stuff I'm working on is in the attached wagic-n900.zip:
- diff is on the current SVN
- Qtmain.cpp needs to be placed in JGE/src
- wagic.pro needs to be placed in projects/mtg

- The fullscreen support seemed broken in JGE, so I handled it directly from Qt
- I added a Phonon support for the sound, it works fine on my phone, even if I don't really understand how to set the volume, would be nice to use the phone dedicated button for that. On my Linux PC, it worked fine for a while until my KDE complained, I didn't try it on Windows but it should work also...
- I used Q,A, J, K, Space, Enter and Backspace as default binding, I didn't try to overwrite it.
- the current .pro allows to download directly on the phone, but the real installation package for non-developer would need more configuration. In particular, it doesn't handle the resources installation.

2 bugs I didn't fix in the current code:
- with the new OpenGL 2.0 code, the border around the menu is broken. As far as I can tell, it's the only stuff that is broken, but I really don't understand why. I happens on every platform, so it's really the OpenGL 2.0 code.
- on my phone, sometime, I've got OpenGL error popping and after that, either card texture are just poorly display (text is no more readable), or I got once the overlay text disappearing (it's really annoying, no way to know how many life I've got left =)). I need to handle OpenGL error a bit more carefully I guess.

Feel free to comment :)

Yann.
Attachments

[The extension zip has been deactivated and can no longer be displayed.]

[The extension png has been deactivated and can no longer be displayed.]

Zethfox
Posts: 3029
Joined: Thu Jun 10, 2010 11:28 pm

Re: N900 and Qt support

Post by Zethfox »

nice! how does it preform on the phone? decent? so so?
Djardin
Posts: 129
Joined: Sat Sep 04, 2010 11:40 am

Re: N900 and Qt support

Post by Djardin »

Performance is very decent I would say. It of course depends of what the phone is doing in the background. I noticed the audio playback is consuming a lot (around 15% CPU to play a MP3, it looks weird). But without the sound, the application is usually running at 35% CPU without slowdown. On some particular action, you can notice massive slowdown, but it's no big deal. For example in the deck editor when you go from colour to colour, the animation is particularly slow...
Anyway, as far as I'm concerned, the game is VERY playable on the phone ;)
wololo
Site Admin
Posts: 3728
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: N900 and Qt support

Post by wololo »

I'm looking at the diffs right now...
I think there are lots of changes in GFX.cpp, maybe we could consider splitting it and have a N900 dedicated version ?
Or keep the common stuff in a file, and additionally have a file for PC VS N900 ?

Regarding sound, we are considering a migration to Phonon instead of FMOD :)

also, this might be a stupid question...but how does the makefile work for you? Do you simply type make USE_PHONON = 1 ... or ... ? I mean, I don't see the file QTMain used anywhere... (Edit: ok, I assume that's what the .pro file does...)

finally, why did the "slots" variable become "slotss" in MTGPack ?

I'm itching to compile it, test it on an emulator, and blog about it :)
Djardin
Posts: 129
Joined: Sat Sep 04, 2010 11:40 am

Re: N900 and Qt support

Post by Djardin »

- About the seperate GFX.cpp, I guess it would make sense. I actually didn't plan to modify so many things from the start. I initially thought that I could use OpenGL ES 1.1 (which is realy close from OpenGl 1.0) with Qt and the phone but it's not possible. So, I ended doing everything with OpenGl ES 2.0 which is really not backward compatible with the good old OpenGl 1.0. So, a dedicated file containing OpenGl (ES) 2.0 implementation would make the stuff cleaner.
- About phonon, then I guess you could use this code. A small comment tho, I used Qt signal/slot mechanism to implement the "repeat" feature needed for the music. But anyway, Phonon introduces a Qt dependency to your binary.
- The makefile is the .pro file. It's directly transformed into VisualC++ projects or unix makefile by qmake which is part of Qt. I'm actually directly using QtCreator which is available on both Linux and Windows and totally abstract the makefile mechanism. The good stuff in this .pro format is that you can directly embed into {} customization for some platforms. If you look at it, I activated phonon only for the maemo5 target because my linux desktop audio system is totaly broken ;).
- I probably was a bit lazy on this one. "slots" and "signals" are language keywords when you're using Qt. Qt actually pre-processes the C++ files to create aditional classes automatically. "slots" and "signals" are realy cool addition to the C++ language, you can find the details about it here http://doc.trolltech.com/4.6/signalsandslots.html. So, about for MTGPack, I didn't look at it, but there are probably some way to tell the Qt pre-processor to not process some particular classes.

I think we need to discuss the packaging of the app. In particular I would need to add a lot of files to create a clean debian package downloadable by any N900 user. I could do that either in your SVN or create a seperate repository in https://garage.maemo.org/.
wololo
Site Admin
Posts: 3728
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: N900 and Qt support

Post by wololo »

As we discussed by PM, I gave you SVN access :)
Regarding the details of the packaging, I have no idea what is the "best" for maemo users, so if you don't mind I'll let you take the decision.

One request from me: I believe quite a good amount of people would be interested in knowing there's an ongoing port on the N900 (see this thread for example: http://talk.maemo.org/showthread.php?t=50278 ), and I'd like to mention your current work in my blog. Hopefully this might get us a few extra devs.

Would it be possible for you to take a video of Wagic running on the actual device, and upload it maybe on youtube, or send it directly to me? That'd be great, no big deal if you can't though ;)
Djardin
Posts: 129
Joined: Sat Sep 04, 2010 11:40 am

Re: N900 and Qt support

Post by Djardin »

I would like to have a clean maemo package and push that to the the extra-devel catalogue. So, I need to finish the packaging and in particular, I need to decide :
- where to put the executable. For this one, it will probably be /usr/bin
- where to put the Res directory. I could put everything as subdirectory of /usr/bin but it's not very clean. The best method would be to use either /usr/share/wagic/Res or even a directory in the user partition like /home/user/MyDocs/.Wagic/Res for example so that the user can easily modify the Res ... This is close from what I'm currently using to develop
- what icon we use for the app. I think I need a 48x48 and 64x64 png icon or maybe some xpm something. The one in the SVN hasn't got the right format I think. Do you have something like that ? I'm currently running the program from a xterm so it's not very cool for end users

I still got 2 annoying bugs, but I guess it's ok for a first package because the game is still playable:
- opengl texture problem happening sometimes, it blurs textures making the card image not readable anymore
- SimpleMenu display problem. I found out my opengl 2.0 code has some problem with the SimpleMenu when it's combining translation, positive rotation and scaling. On this one, my code scales the menu vertical borders to the wrong direction. I coded a quick fix which repairs the menu but also introduces nice card reversing problems during the game. :(
I'm gonna try capturing a small video. You'll see my imba decks !!! =)
wololo
Site Admin
Posts: 3728
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: N900 and Qt support

Post by wololo »

Djardin wrote: - opengl texture problem happening sometimes, it blurs textures making the card image not readable anymore
This might also be a bug in our caching system. When wagic can't open a given card image (for any reason, including cache bugs), it tries to open the corresponding thumbnail, and displays it with an insane scale close to 500%
Locked