Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

wxhtml MyApp::OnInit()

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 FGFS   Members   

345
Like
0Likes
Like

Posted 20 November 2013 - 08:36 AM

Hi

 this is for execution at application start. Now how should I rewrite it to call it as function?

 

 

// Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp
{
public:
    // override base class virtuals
    // ----------------------------

    // this one is called on application startup and is a good place for the app
    // initialization (doing it here and not in the ctor allows to have an error
    // return: if OnInit() returns false, the application terminates)
    virtual bool OnInit();

...

...

 

 

// `Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{

...

 

I want to call OnInit from a function and not at app start. If I simply try that I get:

 cannot call member function ‘virtual bool MyApp::OnInit()’ without object

 

Many thanks

 

 



#2 TheComet   Members   

3860
Like
1Likes
Like

Posted 20 November 2013 - 08:58 AM

You need to instantiate a "MyApp" object in order to call method functions:

int main()
{
    MyApp theApp;
    theApp.OnInit(); // <-- like this

    return 0;
}

But since you're deriving your app from WxApp, I'm going to assume the function OnInit is called automatically for you, so it's a bad idea to call it yourself. That's the whole idea of deriving from a base App class, so the library you're using has control over when to execute what in your program.

 

What are you trying to do?


"I would try to find halo source code by bungie best fps engine ever created, u see why call of duty loses speed due to its detail." -- GettingNifty

#3 FGFS   Members   

345
Like
0Likes
Like

Posted 21 November 2013 - 01:45 AM

Hmm seems I cannot open a window. Would you have an idea on how to integrate in my existing c++/opengl app without a new window the attached?

Attached File  zip.cpp.zip   2.01KB   32 downloads






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.