Beispiel #1
0
void pMain(int argc, char* argv[])
{
    PASSERT(PActivity::s_activity != P_NULL);

    if (PActivity::s_activity != P_NULL)
    {
        PContextProperties contextProperties;
        contextProperties.m_contextName = PString("loadscene");
        contextProperties.m_archiveName = PString("loadscene.par");
#if defined P_WIN32
        contextProperties.m_windowWidth = 480;
        contextProperties.m_windowHeight = 800;
        contextProperties.m_multisamples = 2;
#elif defined P_ANDROID
		 contextProperties.m_windowWidth = 0xffffffff;
        contextProperties.m_windowHeight = 0xffffffff;
#endif

        PContext* context = PNEW(MyContext(contextProperties));
		context->addModule(PNEW(PResourceManager(context)));
		context->addModule(PNEW(PSceneManager(context)));
		// TODO: initialize more modules here.

        PActivity::s_activity->addContext(context);
    }
    else
    {
        PLOG_ERROR("No running activity");
    }
}
Beispiel #2
0
void pMain(int argc, char* argv[])
{
    PASSERT(PActivity::s_activity != P_NULL);

    if (PActivity::s_activity != P_NULL)
    {
        PContextProperties contextProperties;
        contextProperties.m_contextName = PString("background");
        contextProperties.m_archiveName = PString("background.par");
        contextProperties.m_windowWidth = 640;
        contextProperties.m_windowHeight = 480;
#if defined P_WIN32
        contextProperties.m_multisamples = 2;
#endif

        PContext* context = PNEW(MyContext(contextProperties));
		context->addModule(PNEW(PResourceManager(context)));
		context->addModule(PNEW(PSceneManager(context)));
		// More modules
        PActivity::s_activity->addContext(context);
    }
    else
    {
        PLOG_ERROR("No running activity");
    }
}
PEvent *PAnimationInstance::createEvent(PEventTypeEnum event)
{
    PContext *context = m_manager->getContext();
    // TODO: replace the tailing P_NULL with this after PAnimationInstance
    // is refactored to a subclass of PObject.
    return context->eventManager()->createEvent(event, P_NULL);
}
Beispiel #4
0
int pwin32main(int argc, char* argv[])
{
    // Enable memory leak checks and heap validation. 
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);
    _CrtSetBreakAlloc(-1);

    int exitCode = EXIT_SUCCESS;

    // Create the memory debugger.
    PMemoryDebugger::create();

    PActivity* activity = PNEW(PActivity(argc, argv));
    if (!activity->initialize())
    {
        PDELETE(activity);
        return EXIT_FAILURE;
    }
    
    pMain(argc, argv);

    // Set console title.
    SetConsoleTitle(L"Console");
    
    // Disable the close button of the console window.
    HWND hConsoleWindow = GetConsoleWindow();
    if (hConsoleWindow != NULL)
    {
        HMENU hMenu = GetSystemMenu(hConsoleWindow, 0);
        if (hMenu != NULL)
        {
            DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
            DrawMenuBar(hConsoleWindow);
        }
    }

    PContext* context = activity->findContext(puint32(0));
    PASSERT(context != P_NULL);
    if (context == P_NULL)
    {
        exitCode = EXIT_FAILURE;
        PDELETE(activity);
        return exitCode;
    }

    PWin32Window window(context);

    if (!window.create())
    {
        exitCode = EXIT_FAILURE;
        PDELETE(activity);
        return exitCode;
    }
    
    // Initialize the context. 
    context->setState(P_CONTEXT_STATE_UNINITIALIZED);
    if (!context->initialize(context->properties()->m_windowWidth, context->properties()->m_windowHeight))
    {
        exitCode = EXIT_FAILURE;
    }
    else
    {
        if (!context->onInitialized())
        {
            context->setState(P_CONTEXT_STATE_ERROR);
        }
        else
        {
            PLOG_DEBUG("Starting program main loop");
            context->setState(P_CONTEXT_STATE_RUNNING);
        }

        if (context->state() == P_CONTEXT_STATE_ERROR)
        {
            exitCode = EXIT_FAILURE;
        }

        // The mainloop of window.
        window.run();

        // Right before destroy the context, user might have
        // something to do.
        context->onDestroy();
    }

    context->destroy();
    
    // Destroy native window.
    window.destroy();

    // Destroy the activity
    activity->uninitialize();
    PDELETE(activity);

    // Destroy the memory debugger.
    PMemoryDebugger::destroy();

    // If debugger is present, a pause is required to keep the console output
    // visible. Otherwise the pause is automatic. 
    if (IsDebuggerPresent())
    {
        system("pause");
    }

    return exitCode;
}
Beispiel #5
0
int main(int argc, char* argv[])
{
    int exitCode = EXIT_SUCCESS;

    PActivity* activity = pNew(PActivity(argc, argv));
    
    // Enable memory leak checks and heap validation. 
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);
    _CrtSetBreakAlloc(-1);
    
    pMain(argc, argv);

    // Set console title.
    SetConsoleTitle(L"protoss debug console");
    
    // Disable the close button of the console window.
    HWND hConsoleWindow = GetConsoleWindow();
    if (hConsoleWindow != NULL)
    {
        HMENU hMenu = GetSystemMenu(hConsoleWindow, 0);
        if (hMenu != NULL)
        {
            DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
            DrawMenuBar(hConsoleWindow);
        }
    }

    PContext* context = activity->findContext(pUint32(0));
    pAssert(context != P_NULL);
    if (context == P_NULL)
    {
        exitCode = EXIT_FAILURE;
        pDelete(activity);
        return exitCode;
    }

    PWin32Window window(context);

    if (!window.create())
    {
        exitCode = EXIT_FAILURE;
        pDelete(activity);
        return exitCode;
    }
    
    // Initialize the context. 
    // kzaPlatformSetInstanceHandle(context, GetModuleHandle(NULL));
    context->setState(P_CONTEXT_STATE_UNINITIALIZED);
    if (!context->initialize())
    {
        exitCode = EXIT_FAILURE;
    }

    if (!context->onInitialized())
    {
        context->setState(P_CONTEXT_STATE_ERROR);
    }
    else
    {
        pLogDebug("Starting program main loop");
        context->setState(P_CONTEXT_STATE_RUNNING);
    }

    if (context->getState() == P_CONTEXT_STATE_ERROR)
    {
        exitCode = EXIT_FAILURE;
    }

    // The mainloop of window.
    window.run();

    // Right before destroy the context, user might have
    // something to do.
    context->onDestroy();

    context->destroy();
    
    // Destroy native window.
    window.destroy();

    // Destroy the activity
    pDelete(activity);

    // If debugger is present, a pause is required to keep the console output
    // visible. Otherwise the pause is automatic. 
    if (IsDebuggerPresent())
    {
        system("pause");
    }

    return exitCode;
}
Beispiel #6
0
PEvent* PTimer::createEvent(PEventTypeEnum eventType)
{
    // TODO: manage the memory allocation effectively.
    PContext *context = m_manager->context();
    return context->eventManager()->createEvent(eventType, P_NULL);
}