Пример #1
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;
}
Пример #2
0
// 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
}
extern "C" ADDON_STATUS ADDON_Create(void* hdl, void* props)
{
	if (!props)
		return ADDON_STATUS_UNKNOWN;

	VIS_PROPS* visprops = (VIS_PROPS*)props;

	swprintf(g_plugin.m_szPluginsDirPath, L"%hs\\resources\\", visprops->presets);

  if (FALSE == g_plugin.PluginPreInitialize(0, 0))
    return ADDON_STATUS_UNKNOWN;

  if (FALSE == g_plugin.PluginInitialize((ID3D11DeviceContext*)visprops->device, visprops->x, visprops->y, visprops->width, visprops->height, visprops->pixelRatio))
    return ADDON_STATUS_UNKNOWN;

  IsInitialized = true;
	return ADDON_STATUS_NEED_SETTINGS;
//  return ADDON_STATUS_NEED_SAVEDSETTINGS; // We need some settings to be saved later before we quit this plugin
}