Jump to content
  • Advertisement
Sign in to follow this  
lance3D

Can I draw to screen in symbian's exe mode?

This topic is 4960 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I found most games on symbian are using app(dll). But as app can not use global variables, it is very hard to port current programs. I wonder if we can write games in exe format? Can we draw to screen and respond to message in exe mode?

Share this post


Link to post
Share on other sites
Advertisement
I don't know who told you that you cannot use globals in Symbian but he was right.

HOWEVER!
There is a pretty easy way around this that actually enables you to use global variables nontheless.
What you would want to do is to create a class that should serve as your global class as a member of another class (any would do). The parent class of the global class should probably create the global class on initialiazation as it would any other member class (complex member class that is).
Now here is the magic :
In order for you to access that class from anywhere, thus making it global, you use a mechanism called Tls (thread local storage).
See, every dll has 4 bytes of memory that are globally accessible and can be used for any purpose, like holding a pointer to a global class.
Nothing like an example to illustrate usage :

Assume you declare your global class as CGameProperties, and in this class you declare all sorts of variables that you use.
Further assume that you have an initalization function called InitL() in the class that owns the instance of CGameProperties
This is how you set the Tls to the address of that class :

CSomeClass::InitL()
{
//Create the global class as a local instance of the current class
iGameProperties = CGameProperties::NewL();
//Set the address to the Tls using the static function SetTls
Dll::SetTls(iGameProperties);
}





Now whenever and wherever you want to retrieve this, you would have to do a cast in the lines of :

CGameProperties* GameProperties = static_cast<CGameProperties*>(Dll::Tls());





Let me know if you need more clarifications.
Cheers,
Adi.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!