/* $Id: switcher.h $ */

/** @file
 * VBox D3D8/9 dll switcher
 */

/*
 * Copyright (C) 2009 Sun Microsystems, Inc.
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 * Clara, CA 95054 USA or visit http://www.sun.com if you need
 * additional information or have any questions.
 */

#ifndef ___CROPENGL_SWITCHER_H_
#define ___CROPENGL_SWITCHER_H_

typedef BOOL (APIENTRY *DrvValidateVersionProc)(DWORD version);

#define SW_FILLPROC(dispatch, hdll, name) \
    dispatch.p##name = (name##Proc) GetProcAddress(hdll, #name);

#define SW_DISPINIT(dispatch)                                   \
    {                                                           \
        if (!dispatch.initialized)                              \
        {                                                       \
            InitD3DExports(dispatch.vboxName, dispatch.msName); \
            dispatch.initialized = 1;                           \
        }                                                       \
    }

#define SW_CHECKRET(dispatch, func, failret)   \
    {                                          \
        SW_DISPINIT(dispatch)                  \
        if (!dispatch.p##func)                 \
            return failret;                    \
    }

#define SW_CHECKCALL(dispatch, func)    \
    {                                   \
        SW_DISPINIT(dispatch)           \
        if (!dispatch.p##func) return;  \
    }

extern BOOL IsVBox3DEnabled(void);
extern BOOL CheckOptions(void);
extern void FillD3DExports(HANDLE hDLL);
extern void InitD3DExports(const char *vboxName, const char *msName);

#endif /* #ifndef ___CROPENGL_SWITCHER_H_ */