[SailfishDevel] Problems porting our game to Sailfish - welcome any advice

Duncan Waugh duncan_waugh at hotmail.co.uk
Thu Oct 24 14:20:21 UTC 2013


Hello everyone,

I've started work porting our Qt-based game from Symbian over to Sailfish and I'm hitting a pretty major roadblock at the moment. It looks like I haven't set something up in the graphics system properly and would be very grateful for any help that anyone can provide.

A brief outline:
* The application uses the QGraphicsView framework. We set up the QGraphicsView object once at the start of the game and then replace the QGraphicsScene object at various points as the user moves through the application.
* We have overriden the drawForeground() method within the QGraphicsScene objects and manually pass the QPainter object that we receive to the various elements of the UI, which use it to draw to the screen.
* The QGraphicsView object is set not to update itself.  We have a timer in a manager class, which fires 60 times a second, from where we manually call repaint() on the QGraphicsView object.

Current state:
* All code has been tidied up to build under Qt5 and non-Sailfish components, such as Phonon, are currently #ifdeffed out.
* On execution the game runs and moves through a couple of QGraphicsScenes, but only ever displays a white screen.  The calls to QGraphicsView::repaint() are ignored and the QDisplayScenes only have their drawForeground() methods called once, directly after instantiation.  Why we only get a white screen I'm also not sure.  This is all on the latest emulator.

An excerpt from the log is shown below with basic class hierarchy:
DisplayScene ->- QGraphicsScene
BootupScene ->- DisplayScene
TitleMenuScene ->- DisplayScene

0:    Using Wayland-EGL 
1:    libpng warning: Malformed iTXt chunk
2: 
3:    calling QGraphicsView::SetScene() 
4:    DisplayScene::drawForeground  QRectF(1,1 538x958) 
5:    BootupScene::UpdateNotification  52 
6:    >>GameManager::FrameTimerTick - repaint 
7:    <<GameManager::FrameTimerTick - repaint 
8:    BootupScene::UpdateNotification  52 
9:    >>GameManager::FrameTimerTick - repaint 
10:   <<GameManager::FrameTimerTick - repaint 
11: 
12:   ...
13: 
14:   >>GameManager::FrameTimerTick - repaint 
15:   <<GameManager::FrameTimerTick - repaint 
16:   BootupScene::UpdateNotification  51 
17;   SWITCH 
18:   >>GameManager::FrameTimerTick - repaint 
19:   <<GameManager::FrameTimerTick - repaint 
20: 
21:   calling QGraphicsView::SetScene() 
22:   >>GameManager::FrameTimerTick - repaint 
23:   TitleMenuScene::drawForeground 
24:   DisplayScene::drawForeground  QRectF(1,1 538x958) 
25:   <<GameManager::FrameTimerTick - repaint 
26:   >>GameManager::FrameTimerTick - repaint 
27:   <<GameManager::FrameTimerTick - repaint 
28: 
29:   ...
30:   
31:   >>GameManager::FrameTimerTick - repaint 
32:   User requested stop. Shutting down...
33    <<GameManager::FrameTimerTick - repaint 

As you can see when the GameManager calls QGraphicsView repaint() we don't get any calls to the Scenes' drawForeground().

The setup code for the QGraphicsView is:

0:    setScene(iScene);
1:    setOptimizationFlags(QGraphicsView::IndirectPainting);
2:    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
3:    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
4:    setRenderHint(QPainter::Antialiasing); 
5:    setCacheMode(QGraphicsView::CacheBackground);
6:    setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
7:    resize(iScreenWidth, iScreenHeight);
8:    viewport()->setAttribute(Qt::WA_AcceptTouchEvents);

I'm assuming the issue is either here or that I have incorrectly set up the configuration files for Sailfish.  Here's our main.cpp file:
MyApplication ->- QApplication

0:    int main(int argc, char *argv[])
1:    {
2:        MyApplication a(argc, argv);
3:
4:        QWidget* screen = QApplication::desktop()->screen();
5:        GameManager w(screen->width(), screen->height(), a);
6:        return a.exec();
7:    }

I based the Sailfish installation files off of the sample application, it's possible I made an error here.
Yaml:

0:    Name: PuzzleStones
1:    Summary: My SailfishOS Application
2:    Version: 0.1
3:    Release: 1
4:    Group: Qt/Qt
5:    License: LICENSE
6:    Sources:
7:    - '%{name}-%{version}.tar.bz2'
8:    Description: |
9:      Short description of my SailfishOS Application
10:   Configure: none
11:   Builder: qtc5
12:   PkgConfigBR:
13:   - sailfishapp
14:   - Qt5Quick
15:   - Qt5Qml
16:   - Qt5Core
17:   Requires:
18:   - sailfishsilica-qt5
19:   Files:
20:   - '%{_bindir}'
21:   - '%{_datadir}/%{name}/qml'
22:   - '%{_datadir}/applications/%{name}.desktop'
23:   - '%{_datadir}/icons/hicolor/90x90/apps/%{name}.png'
24:   - /usr/bin
25:   - /usr/share/PuzzleStones
26:   - /usr/share/applications
27:   - /usr/share/icons/hicolor/90x90/apps

Spec:

0:    # 
1:    # Do NOT Edit the Auto-generated Part!
2:    # Generated by: spectacle version 0.27
3:    # 
4:
5:    Name:       PuzzleStones
6:
7:    # >> macros
8:    # << macros
9:
10:   %{!?qtc_qmake:%define qtc_qmake %qmake}
11:   %{!?qtc_qmake5:%define qtc_qmake5 %qmake5}
12:   %{!?qtc_make:%define qtc_make make}
13:   %{?qtc_builddir:%define _builddir %qtc_builddir}
14:   Summary:    My SailfishOS Application
15:   Version:    0.1
16:   Release:    1
17:   Group:      Qt/Qt
18:   License:    LICENSE
19:   Source0:    %{name}-%{version}.tar.bz2
20:   Source100:  PuzzleStones.yaml
21:   Requires:   sailfishsilica-qt5
22:   BuildRequires:  pkgconfig(sailfishapp)
23:   BuildRequires:  pkgconfig(Qt5Quick)
24:   BuildRequires:  pkgconfig(Qt5Qml)
25:   BuildRequires:  pkgconfig(Qt5Core)
26:   BuildRequires:  desktop-file-utils
27:
28:   %description
29:   Short description of my SailfishOS Application
30:
31:
32:   %prep
33:   %setup -q -n %{name}-%{version}
34:
35:   # >> setup
36:   # << setup
37:
38:   %build
39:   # >> build pre
40:   # << build pre
41:
42:   %qtc_qmake5 
43:
44:   %qtc_make %{?_smp_mflags}
45: 
46:   # >> build post
47:   # << build post
48:
49:   %install
50:   rm -rf %{buildroot}
51:   # >> install pre
52:   # << install pre
53:   %qmake5_install
54:
55:   # >> install post
56:   # << install post
57:
58:   desktop-file-install --delete-original       \
59:     --dir %{buildroot}%{_datadir}/applications             \
60:      %{buildroot}%{_datadir}/applications/*.desktop
61:
62:   %files
63:   %defattr(-,root,root,-)
64:   %{_bindir}
65:   %{_datadir}/%{name}/qml
66:   %{_datadir}/applications/%{name}.desktop
67:   %{_datadir}/icons/hicolor/90x90/apps/%{name}.png
68:   /usr/bin
69:   /usr/share/PuzzleStones
70:   /usr/share/applications
71:   /usr/share/icons/hicolor/90x90/apps
72:   # >> files
73:   # << files


Thank you for reading and I hope someone can help point us in the right direction.

Best regards,
Duncan
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20131024/d877efb7/attachment.html>


More information about the Devel mailing list