Hi again,
I think I found a workaround. The issue is, that the DX9 SDK is compiled with a much older version of visual studio and static libraries are not fully compatible to each other. Unfortunately M$ does not support this old SDK for new compilers, so the only way is to recompile the dxerr library by yourself. Of course you cannot access the original code from M$, but there is a very interesting wrapper available, that make the original dxerr.h functions available by using inside the new FormatMessage function instead of vprintf.
This is the link to the blog and files:
http://blogs.msdn.com/b/chuckw/archive/ ... r-lib.aspx
(you find the files as ZIP at the end of this blog entry, copy them to a folder named "src" and use cmake with the following cmake file to compile a dxerr.lib out of it)
cmake-file:
Code: Select all
# -*- cmake -*-
cmake_minimum_required(VERSION 3.3)
PROJECT(dxerr)
## section: include directory
#INCLUDE_DIRECTORIES(
# includes
# src
# )
## section: source files
# Add your source files here (one file per line), please SORT in alphabetical order for future maintenance
SET (DXERR_SOURCE_FILES
src/dxerr.cpp
)
## section: header files
# Add your header files here(one file per line), please SORT in alphabetical order for future maintenance!
SET(DXERR_HEADER_FILES
src/dxerr.h
)
SET_SOURCE_FILES_PROPERTIES(DXERR_HEADER_FILES
PROPERTIES HEADER_FILE_ONLY TRUE)
LIST(APPEND DXERR_SOURCE_FILES ${DXERR_HEADER_FILES})
## section: add definitions
# add prefix -D. example> -DSHP
# - DO NOT add the following definitions(already defined in ${OSP_DEFINITIONS}:
# -DSHP, -DWIN32, -D_WINDOWS, -D_DEBUG, -D_USRDLL, -D_CRT_SECURE_NO_DEPRECATE
ADD_DEFINITIONS(
-D_LIB;-D_STLP_DEBUG;
)
## section: add target
ADD_LIBRARY (dxerr ${DXERR_SOURCE_FILES} )
## section: add dependency
# dependency determines overall build order.
#ADD_DEPENDENCIES(${this_target} dxguid dinput8 xinput)
INSTALL(TARGETS dxerr
ARCHIVE DESTINATION "lib" CONFIGURATIONS Debug Release MinSizeRel RelWithDebInfo
LIBRARY DESTINATION "lib" CONFIGURATIONS Debug Release MinSizeRel RelWithDebInfo
RUNTIME DESTINATION "bin" CONFIGURATIONS Debug Release MinSizeRel RelWithDebInfo
)
INSTALL(FILES ${DXERR_HEADER_FILES} DESTINATION "includes")
Unfortunately DXGetErrorDescription function prototype is different here and Ogre3D is using the non Unicode-Function, that is not supported by this dxerr-wrapper.
However I was able to adapt the wrapper code in a way that it fits to the original prototype and I also added a non Unicode version.
Due to license reasons I cannot offer the full code to you, but as a fast solution you can simply use a static WCHAR[32000] array inside the function and return the pointer to that array. This is not a nice approach but the easiest one.
For adapting to non-Unicode, you can use this code (is also using a static array):
Code: Select all
const char* WINAPI DXGetErrorDescriptionA(__in HRESULT hr)
{
WCHAR const * pUnicodeStr = DXGetErrorDescriptionW(hr);
static char ASCIIStr[32000];
wcstombs(ASCIIStr, pUnicodeStr, 31999);
return ASCIIStr;
}
I think for a first approach this is ok. Later I should have another look here to implement it in a more clean way.
BTW: Remember to add the ifdef/else/endif for the #define DXGetErrorDescription to the wrapper header like it was in the original DX9 dxerr.h