本文整理汇总了C++中Extension::GetRenderProc方法的典型用法代码示例。如果您正苦于以下问题:C++ Extension::GetRenderProc方法的具体用法?C++ Extension::GetRenderProc怎么用?C++ Extension::GetRenderProc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Extension
的用法示例。
在下文中一共展示了Extension::GetRenderProc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: require
HRESULT STDMETHODCALLTYPE GLScript_Engine::require (BSTR bstr_path, VARIANT var_options,
IDispatch **ppDispatchExtLib)
{
// default loading options to use for the 'require' call for loading extensions
const long DEF_LOAD_OPTIONS = GLS_EXTENSION_LIBRARY;
// supported loading options
const long SUPPORTED_LOAD_OPTIONS = (GLS_EXTENSION_RENDERER |
GLS_EXTENSION_LIBRARY);
// check for invalud arguments
if (bstr_path == NULL || ppDispatchExtLib == NULL) {
return E_POINTER;
}
*ppDispatchExtLib = NULL;
// parse the variant options argument for the loading options. The loading options
// can be specified as a string encoded options or as a long interger bitmask. the
// loading options is optional, in which case default loading options is used.
long load_options;
if (var_options.vt == VT_ERROR) {
// use default loading options variant's internal type is VT_ERROR, which means
// no value was supplied for this parameter.
load_options = DEF_LOAD_OPTIONS;
} else if (var_options.vt == VT_BSTR) {
// parse load options from string encoded options
if (!ParseExtensionLoadOptions (var_options.bstrVal, load_options)) {
return E_INVALIDARG;
}
} else {
// assume load options as a long type and fetch the value from the variant
if (!gls_comvariant_get_long_value (&var_options, &load_options)) {
return E_INVALIDARG;
}
}
// check for any option that is not supported in the current environment
if ( (load_options & SUPPORTED_LOAD_OPTIONS) != load_options ) {
return E_INVALIDARG;
}
GLScriptHost_Win32 *pHost = reinterpret_cast<GLScriptHost_Win32 *>(GetParent());
// extension load options has been successfully parsed so next task is to build the
// extension path to load it
UINT path_length = ::SysStringLen(bstr_path);
char *ascii_path_buff = new char [path_length + 1];
::wcstombs (ascii_path_buff, bstr_path, path_length);
ascii_path_buff [path_length] = '\0';
// load the extension using the extension host object
Extension *pExtension = pHost->m_ext_host.LoadExtension (ascii_path_buff, load_options);
delete ascii_path_buff;
// check if extension failed to load
if (pExtension == NULL) {
// failed to load the extension. notify the host about the error.
if (pHost->m_pEventListener != NULL) {
tstring str_error (_T("Failed to load the extension '"));
#ifdef UNICODE
str_error+= bstr_path;
#else
str_error+= WS2MBS(bstr_path);
#endif
str_error+= _T("'.");
pHost->RaiseHostError (str_error.c_str());
}
// #TODO: return error only if strict mode is set
return E_FAIL;
}
// hook render proc if "renderer" option is specified
if (load_options & GLS_EXTENSION_RENDERER) {
pHost->m_ext_host.HookRenderProc (pExtension->GetRenderProc(), pExtension);
}
// Return the lib interface if required
if (load_options & GLS_EXTENSION_LIBRARY) {
// return the IDispatch interface
*ppDispatchExtLib = reinterpret_cast<IDispatch *>(pExtension->GetLibInterface());
(*ppDispatchExtLib)->AddRef ();
}
return NOERROR;
}