PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

GapiDraw with Symbian 60 EXE files

Has anybody had any luck (or even tried) getting gapi to work for symbian 60 exe?

I tried tonight making the changes to the Minimal demo to have to work as an EXE but the program keeps quiting out before it even starts. I have programs I have gotten to work in exe form on symbian 60 but I can't get the gapidraw Minimal demo to work.

Anybody from the gapi team have a test demo of gapi working in an exe insted of an app?

I need to use EXE due to a pc program I have ported to symbian 60 (which has heavy use of global varibles).
It is possible to use the dll from an exe, and yes, we have tried it. The imageloader doesn't work from en exe, though. You also need to provide your own framework, since GapiApplication is designed for apps.

If global variables is your only reason for wanting to use an exe instead of an app I suggest that you check out the Dll::Tls approach discussed in
this paper.

/Jonas
I have read that "Dll::Tls" slows down access to the data.

The program I am porting is an emulator which has critical sections in global varibles (Rom, Bios, Ram, Vram, Z80 Mem, ...). I am also trying to keep the original core with little to no modifications (so if someone else were to update a faster version of the core, I can update with out hassel).

Can you please list what Librarys & classes are crutial to GapiDraw for it to function? Did you guys modify the included class for gapidraw to function for exe or did you have to write another method to use the gapidraw lib with out using the included class used in the examples.
Yes, it's true that Dll::Tls slows down data access somewhat. There's a 20 instructions overhead doing so.

Here is a very basic example of an exe. It opens the display and draws the text from minimal to the screen. When it exits it just exits. The screen won't be repainted by the system, so it will look as if the program is still running until some part of the screen will need to be repainted, i. e. if you start navigating in menus. This is just to give you an idea of how you can start.

Also note that you need to take care of things like incoming phonecalls and other system events, since this is handled by CGapiApplication, not by the dll.

Code:

#include "gapidraw.h"
#include <e32base.h>
#include <w32std.h>

TInt E32Main() {

RWsSession aWsSession;
aWsSession.Connect();

CGapiDraw* m_gapidraw;
m_gapidraw = new CGapiDraw();

CGapiDisplay* m_pDisplay;
CGapiSurface* backbuffer;
m_pDisplay = new CGapiDisplay();
m_pDisplay->OpenDisplay(aWsSession, GDDISPLAY_FULLSCREEN|GDDISPMODE_NORMAL);
backbuffer=m_pDisplay->GetBackBuffer();

backbuffer->FillRect(NULL,RGB(128,128,128),0,NULL);

DWORD dwXCenter = (backbuffer->GetWidth()>>1);
DWORD dwYCenter = (backbuffer->GetHeight()>>1);

// Draw some text
TCHAR str1[] = TEXT("This is a minimal GapiDraw Application");
TCHAR str2[] = TEXT("-Press any key to exit-");
CGapiBitmapFont* pSystemFont = m_pDisplay->GetSystemFontBorder();
backbuffer->DrawText(dwXCenter, (dwYCenter-10), str1, pSystemFont, GDDRAWTEXT_CENTER, NULL, 0, NULL);
backbuffer->DrawText(dwXCenter, (dwYCenter+2), str2, pSystemFont, GDDRAWTEXT_CENTER, NULL, 0, NULL);

m_pDisplay->Flip();
User::After(500000);
aWsSession.Close();
delete m_pDisplay;
delete m_gapidraw;
return true;
}


Your mmp file could look something like this:

Code:

TARGET myexe.exe
TARGETTYPE exe
TARGETPATH \system\apps\myexe
UID 0

SOURCEPATH .
SOURCE myexe.cpp

USERINCLUDE ..\..\..\include\Symbian

SYSTEMINCLUDE \epoc32\include

LIBRARY euser.lib
LIBRARY gd300.lib
LIBRARY ws32.lib
Jonasb,

I just tried your example out but it does not work. It seems to crash in "m_gapidraw = new CGapiDraw();"

This is for Sybman 60 (6.1 C++ SDK). Anything missing that would cause the crash?
Jonasb,

I am sorry. I am an idiot. I did not copy over the gapi dll with the program. :( So now everything works fine with drawing. :)

I have a new problem though. Is Gapi taking controll over my input request in my TRequestStatus object? Because now my program is not recieving any input and when I press key buttons I see the display fight with fexplorer (i used to launch my program). So is there something different I have to do for my input or something I need to set with gapi to fix my input problem?
The sample that Jonas posted was indeed a minimal one and a lot of things are not there to make it fully work. We have basically just tested that it works in an exe and then nothing more, but I think you should try the following: Create a full screen window (even though GapiDraw operates directly on the framebuffer it's probably a good idea to "tell" the system that we are drawing on the whole screen). Then you should be able to call CGapiInput::OpenInput(RWindowGroup& windowGroup) to lock all hardware keys.

Great that you got it started.

//Erik
Thanks guys for all the help. I put back in all my old drawing init code (creating an RWindow session) and everything is fine.

I have only one problem remaing that I need help with. When I exit out of my exe the screen does not refresh so the screen stays with the last image drawn by gapi. If I move around on the dpad then parts of the menu will redraw to the screen (a few icons).

Any clue what I might be doing wrong?