d57ca44902
This commit also reintroduces nvcore Library.h and Library.cpp files
required by nvtt/cuda/CudaUtils.cpp
Ref:
https://github.com/castano/nvidia-texture-tools/issues/230
81336cc3e9
Signed-off-by: Elvis Dowson <elvis.dowson@gmail.com>
51 lines
953 B
C++
51 lines
953 B
C++
// This code is in the public domain -- castano@gmail.com
|
|
|
|
#pragma once
|
|
#ifndef NV_CORE_LIBRARY_H
|
|
#define NV_CORE_LIBRARY_H
|
|
|
|
#include "nvcore.h"
|
|
|
|
#if NV_OS_WIN32
|
|
#define LIBRARY_NAME(name) #name ".dll"
|
|
#elif NV_OS_DARWIN
|
|
#define NV_LIBRARY_NAME(name) "lib" #name ".dylib"
|
|
#else
|
|
#define NV_LIBRARY_NAME(name) "lib" #name ".so"
|
|
#endif
|
|
|
|
NVCORE_API void * nvLoadLibrary(const char * name);
|
|
NVCORE_API void nvUnloadLibrary(void * lib);
|
|
NVCORE_API void * nvBindSymbol(void * lib, const char * symbol);
|
|
|
|
class NVCORE_CLASS Library
|
|
{
|
|
public:
|
|
Library(const char * name)
|
|
{
|
|
handle = nvLoadLibrary(name);
|
|
}
|
|
~Library()
|
|
{
|
|
if (isValid())
|
|
{
|
|
nvUnloadLibrary(handle);
|
|
}
|
|
}
|
|
|
|
bool isValid() const
|
|
{
|
|
return handle != NULL;
|
|
}
|
|
|
|
void * bindSymbol(const char * symbol)
|
|
{
|
|
return nvBindSymbol(handle, symbol);
|
|
}
|
|
|
|
private:
|
|
void * handle;
|
|
};
|
|
|
|
|
|
#endif // NV_CORE_LIBRARY_H
|