예제 #1
0
파일: vis.cpp 프로젝트: Doormatty/MilkDrop2
// initialization. Registers our window class, creates our window, etc. Again, this one works for
// both modules, but you could make init1() and init2()...
// returns 0 on success, 1 on failure.
int init(struct winampVisModule *this_mod)
{
    DWORD version = GetWinampVersion(mod1.hwndParent);

	if (!warand)
    {
		warand = (int (*)(void))SendMessage(this_mod->hwndParent, WM_WA_IPC, 0, IPC_GET_RANDFUNC);
        if ((size_t)warand <= 1)
        {
            warand = fallback_rand_fn;
        }
    }
    
    if (!WaitUntilPluginFinished(this_mod->hwndParent))
    {
        return 1;        
    }

    if (GetWinampVersion(mod1.hwndParent) < 0x4000)
    {
        // query winamp for its playback state
        LRESULT ret = SendMessage(this_mod->hwndParent, WM_USER, 0, 104); 
        // ret=1: playing, ret=3: paused, other: stopped

        if (ret != 1)
        {
			wchar_t title[64];
            MessageBoxW(this_mod->hwndParent, WASABI_API_LNGSTRINGW(IDS_THIS_PLUGIN_NEEDS_MUSIC_TO_RUN),
					   WASABI_API_LNGSTRINGW_BUF(IDS_NO_MUSIC_PLAYING, title, 64),
					   MB_OK|MB_SETFOREGROUND|MB_TOPMOST|MB_TASKMODAL );
            return 1;  // failure
        }
    }

    g_bFullyExited = false;

    if (!g_plugin.PluginPreInitialize(this_mod->hwndParent, this_mod->hDllInstance))
    {
        g_plugin.PluginQuit();
        g_bFullyExited = true;
        return 1;
    }

    if (!g_plugin.PluginInitialize())
    {
        g_plugin.PluginQuit();
        g_bFullyExited = true;
        return 1;
    }

    return 0;    // success
}
예제 #2
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	_CrtSetBreakAlloc(60);

	// Register the windows class
	WNDCLASS wndClass;
	wndClass.style = CS_DBLCLKS;
	wndClass.lpfnWndProc = StaticWndProc;
	wndClass.cbClsExtra = 0;
	wndClass.cbWndExtra = 0;
	wndClass.hInstance = hInstance;
	wndClass.hIcon = NULL;
	wndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
	wndClass.hbrBackground = ( HBRUSH )GetStockObject( BLACK_BRUSH );
	wndClass.lpszMenuName = NULL;
	wndClass.lpszClassName = "Direct3DWindowClass";

	if( !RegisterClass( &wndClass ) )
	{
		DWORD dwError = GetLastError();
		if( dwError != ERROR_CLASS_ALREADY_EXISTS )
			return -1;
	}

	// Find the window's initial size, but it might be changed later
	int nDefaultWidth = 1280;
	int nDefaultHeight = 720;

	RECT rc;
	SetRect( &rc, 0, 0, nDefaultWidth, nDefaultHeight );
	AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, false );

	// Create the render window
	HWND hWnd = CreateWindow( "Direct3DWindowClass", "Vortex", WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, CW_USEDEFAULT, ( rc.right - rc.left ), ( rc.bottom - rc.top ), 0,
		NULL, hInstance, 0 );
	if( hWnd == NULL )
	{
		DWORD dwError = GetLastError();
		return -1;
	}
	gHWND = hWnd;

	ShowWindow( hWnd, SW_SHOW );

	CreateDevice( nDefaultWidth, nDefaultHeight );

	g_plugin.PluginPreInitialize(0,0);
	g_plugin.PluginInitialize( pD3DDevice, 0, 0, nDefaultWidth, nDefaultHeight, nDefaultHeight / (float)nDefaultWidth);
	
	MainLoop();

	g_plugin.PluginQuit();

	pD3DDevice->Release();
	pD3D9->Release();

	return 0;
}
extern "C" void ADDON_Stop()
{
	if( IsInitialized )
	{
		g_plugin.PluginQuit();
	
		for( int i = 0;  i < GNumPresets; i++ )
		{
			delete[] GAllPresetStrings[ i ];
		}

		delete[] GAllPresetStrings;
		GAllPresetStrings = NULL;

		IsInitialized = false;
	}
}
예제 #4
0
파일: vis.cpp 프로젝트: Doormatty/MilkDrop2
// cleanup (opposite of init()). Should destroy the window, unregister the window class, etc.
void quit(struct winampVisModule *this_mod)
{
	g_plugin.PluginQuit();
	g_bFullyExited = true;
}