本文整理汇总了C++中WIN_StringToUTF8函数的典型用法代码示例。如果您正苦于以下问题:C++ WIN_StringToUTF8函数的具体用法?C++ WIN_StringToUTF8怎么用?C++ WIN_StringToUTF8使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WIN_StringToUTF8函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WIN_AddDisplay
static SDL_bool
WIN_AddDisplay(_THIS, LPTSTR DeviceName)
{
SDL_VideoDisplay display;
SDL_DisplayData *displaydata;
SDL_DisplayMode mode;
DISPLAY_DEVICE device;
#ifdef DEBUG_MODES
printf("Display: %s\n", WIN_StringToUTF8(DeviceName));
#endif
if (!WIN_GetDisplayMode(_this, DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
return SDL_FALSE;
}
displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
if (!displaydata) {
return SDL_FALSE;
}
SDL_memcpy(displaydata->DeviceName, DeviceName,
sizeof(displaydata->DeviceName));
SDL_zero(display);
device.cb = sizeof(device);
if (EnumDisplayDevices(DeviceName, 0, &device, 0)) {
display.name = WIN_StringToUTF8(device.DeviceString);
}
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
SDL_AddVideoDisplay(&display);
SDL_free(display.name);
return SDL_TRUE;
}
示例2: SDL_DXGIGetOutputInfo
void
SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex )
{
void *pDXGIDLL;
IDXGIFactory *pDXGIFactory;
*adapterIndex = -1;
*outputIndex = -1;
if (!DXGI_LoadDLL(&pDXGIDLL, &pDXGIFactory)) {
SDL_SetError("Unable to create DXGI interface");
} else {
SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex);
if (!pData) {
SDL_SetError("Invalid display index");
} else {
char *displayName = WIN_StringToUTF8(pData->DeviceName);
int nAdapter = 0, nOutput = 0;
IDXGIAdapter* pDXGIAdapter;
while ( *adapterIndex == -1 && IDXGIFactory_EnumAdapters(pDXGIFactory, nAdapter, &pDXGIAdapter) != DXGI_ERROR_NOT_FOUND ) {
IDXGIOutput* pDXGIOutput;
while ( *adapterIndex == -1 && IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput) != DXGI_ERROR_NOT_FOUND ) {
DXGI_OUTPUT_DESC outputDesc;
if (SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) {
char *outputName = WIN_StringToUTF8(outputDesc.DeviceName);
if(!SDL_strcmp(outputName, displayName)) {
*adapterIndex = nAdapter;
*outputIndex = nOutput;
}
SDL_free( outputName );
}
IDXGIOutput_Release( pDXGIOutput );
nOutput++;
}
IDXGIAdapter_Release( pDXGIAdapter );
nAdapter++;
}
SDL_free(displayName);
}
/* free up the D3D stuff we inited */
IDXGIFactory_AddRef( pDXGIFactory );
SDL_UnloadObject(pDXGIDLL);
}
}
示例3: D3D_FindAdapter
static UINT D3D_FindAdapter(IDirect3D9 * d3d, SDL_VideoDisplay * display)
{
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
UINT adapter, count;
count = IDirect3D9_GetAdapterCount(d3d);
for (adapter = 0; adapter < count; ++adapter) {
HRESULT result;
D3DADAPTER_IDENTIFIER9 info;
char *name;
result = IDirect3D9_GetAdapterIdentifier(d3d, adapter, 0, &info);
if (FAILED(result)) {
continue;
}
name = WIN_StringToUTF8(displaydata->DeviceName);
if (SDL_strcmp(name, info.DeviceName) == 0) {
SDL_free(name);
return adapter;
}
SDL_free(name);
}
/* This should never happen, but just in case... */
return D3DADAPTER_DEFAULT;
}
示例4: WIN_CreateWindowFrom
int
WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
HWND hwnd = (HWND) data;
LPTSTR title;
int titleLen;
/* Query the title from the existing window */
titleLen = GetWindowTextLength(hwnd);
title = SDL_stack_alloc(TCHAR, titleLen + 1);
if (title) {
titleLen = GetWindowText(hwnd, title, titleLen);
} else {
titleLen = 0;
}
if (titleLen > 0) {
window->title = WIN_StringToUTF8(title);
}
if (title) {
SDL_stack_free(title);
}
if (SetupWindowData(_this, window, hwnd, SDL_FALSE) < 0) {
return -1;
}
return 0;
}
示例5: WIN_GetClipboardText
char *
WIN_GetClipboardText(_THIS)
{
char *text;
text = NULL;
if (IsClipboardFormatAvailable(TEXT_FORMAT) &&
OpenClipboard(GetWindowHandle(_this))) {
HANDLE hMem;
LPTSTR tstr;
hMem = GetClipboardData(TEXT_FORMAT);
if (hMem) {
tstr = (LPTSTR)GlobalLock(hMem);
text = WIN_StringToUTF8(tstr);
GlobalUnlock(hMem);
} else {
WIN_SetError("Couldn't get clipboard data");
}
CloseClipboard();
}
if (!text) {
text = SDL_strdup("");
}
return text;
}
示例6: XAUDIO2_DetectDevices
static void
XAUDIO2_DetectDevices(void)
{
IXAudio2 *ixa2 = NULL;
UINT32 devcount = 0;
UINT32 i = 0;
if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
SDL_SetError("XAudio2: XAudio2Create() failed at detection.");
return;
} else if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
SDL_SetError("XAudio2: IXAudio2::GetDeviceCount() failed.");
IXAudio2_Release(ixa2);
return;
}
for (i = 0; i < devcount; i++) {
XAUDIO2_DEVICE_DETAILS details;
if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
char *str = WIN_StringToUTF8(details.DisplayName);
if (str != NULL) {
SDL_AddAudioDevice(SDL_FALSE, str, (void *) ((size_t) i+1));
SDL_free(str); /* SDL_AddAudioDevice made a copy of the string. */
}
}
}
IXAudio2_Release(ixa2);
}
示例7: WIN_AddDisplay
static SDL_bool
WIN_AddDisplay(LPTSTR DeviceName)
{
SDL_VideoDisplay display;
SDL_DisplayData *displaydata;
SDL_DisplayMode mode;
#ifdef DEBUG_MODES
printf("Display: %s\n", WIN_StringToUTF8(DeviceName));
#endif
if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
return SDL_FALSE;
}
displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
if (!displaydata) {
return SDL_FALSE;
}
SDL_memcpy(displaydata->DeviceName, DeviceName,
sizeof(displaydata->DeviceName));
SDL_zero(display);
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
SDL_AddVideoDisplay(&display);
return SDL_TRUE;
}
示例8: WIN_CreateWindowFrom
int
WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
HWND hwnd = (HWND) data;
LPTSTR title;
int titleLen;
/* Query the title from the existing window */
titleLen = GetWindowTextLength(hwnd);
title = SDL_stack_alloc(TCHAR, titleLen + 1);
if (title) {
titleLen = GetWindowText(hwnd, title, titleLen);
} else {
titleLen = 0;
}
if (titleLen > 0) {
window->title = WIN_StringToUTF8(title);
}
if (title) {
SDL_stack_free(title);
}
if (SetupWindowData(_this, window, hwnd, SDL_FALSE) < 0) {
return -1;
}
// Urho3D: if window will be used for OpenGL, choose pixel format
if (window->flags & SDL_WINDOW_OPENGL) {
if (WIN_GL_SetupWindow(_this, window) < 0) {
return -1;
}
}
return 0;
}
示例9: XAUDIO2_DetectDevices
static void
XAUDIO2_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
{
IXAudio2 *ixa2 = NULL;
UINT32 devcount = 0;
UINT32 i = 0;
if (iscapture) {
SDL_SetError("XAudio2: capture devices unsupported.");
return;
} else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
SDL_SetError("XAudio2: XAudio2Create() failed at detection.");
return;
} else if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
SDL_SetError("XAudio2: IXAudio2::GetDeviceCount() failed.");
IXAudio2_Release(ixa2);
return;
}
for (i = 0; i < devcount; i++) {
XAUDIO2_DEVICE_DETAILS details;
if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
char *str = WIN_StringToUTF8(details.DisplayName);
if (str != NULL) {
addfn(str);
SDL_free(str); /* addfn() made a copy of the string. */
}
}
}
IXAudio2_Release(ixa2);
}
示例10: WIN_CreateWindowFrom
int
WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
HWND hwnd = (HWND) data;
LPTSTR title;
int titleLen;
/* Query the title from the existing window */
titleLen = GetWindowTextLength(hwnd);
title = SDL_stack_alloc(TCHAR, titleLen + 1);
if (title) {
titleLen = GetWindowText(hwnd, title, titleLen);
} else {
titleLen = 0;
}
if (titleLen > 0) {
window->title = WIN_StringToUTF8(title);
}
if (title) {
SDL_stack_free(title);
}
if (SetupWindowData(_this, window, hwnd, SDL_FALSE) < 0) {
return -1;
}
// Urho3D: if window will be used for OpenGL, choose pixel format
if (window->flags & SDL_WINDOW_OPENGL) {
if (WIN_GL_SetupWindow(_this, window) < 0) {
return -1;
}
}
#if SDL_VIDEO_OPENGL_WGL
{
const char *hint = SDL_GetHint(SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT);
if (hint) {
// This hint is a pointer (in string form) of the address of
// the window to share a pixel format with
SDL_Window *otherWindow = NULL;
SDL_sscanf(hint, "%p", (void**)&otherWindow);
// Do some error checking on the pointer
if (otherWindow != NULL && otherWindow->magic == &_this->window_magic)
{
// If the otherWindow has SDL_WINDOW_OPENGL set, set it for the new window as well
if (otherWindow->flags & SDL_WINDOW_OPENGL)
{
window->flags |= SDL_WINDOW_OPENGL;
if(!WIN_GL_SetPixelFormatFrom(_this, otherWindow, window)) {
return -1;
}
}
}
}
}
#endif
return 0;
}
示例11: SDL_DINPUT_MaybeAddDevice
int
SDL_DINPUT_MaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance)
{
HRESULT ret;
LPDIRECTINPUTDEVICE8 device;
const DWORD needflags = DIDC_ATTACHED | DIDC_FORCEFEEDBACK;
DIDEVCAPS capabilities;
SDL_hapticlist_item *item = NULL;
if (dinput == NULL) {
return -1; /* not initialized. We'll pick these up on enumeration if we init later. */
}
/* Make sure we don't already have it */
for (item = SDL_hapticlist; item; item = item->next) {
if ((!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof(*pdidInstance)) == 0)) {
return -1; /* Already added */
}
}
/* Open the device */
ret = IDirectInput8_CreateDevice(dinput, &pdidInstance->guidInstance, &device, NULL);
if (FAILED(ret)) {
/* DI_SetError("Creating DirectInput device",ret); */
return -1;
}
/* Get capabilities. */
SDL_zero(capabilities);
capabilities.dwSize = sizeof(DIDEVCAPS);
ret = IDirectInputDevice8_GetCapabilities(device, &capabilities);
IDirectInputDevice8_Release(device);
if (FAILED(ret)) {
/* DI_SetError("Getting device capabilities",ret); */
return -1;
}
if ((capabilities.dwFlags & needflags) != needflags) {
return -1; /* not a device we can use. */
}
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
return SDL_OutOfMemory();
}
item->name = WIN_StringToUTF8(pdidInstance->tszProductName);
if (!item->name) {
SDL_free(item);
return -1;
}
/* Copy the instance over, useful for creating devices. */
SDL_memcpy(&item->instance, pdidInstance, sizeof(DIDEVICEINSTANCE));
SDL_memcpy(&item->capabilities, &capabilities, sizeof(capabilities));
return SDL_SYS_AddHapticDevice(item);
}
示例12: EnumJoysticksCallback
/* helper function for direct input, gets called for each connected joystick */
static BOOL CALLBACK
EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
{
JoyStick_DeviceData *pNewJoystick;
JoyStick_DeviceData *pPrevJoystick = NULL;
const DWORD devtype = (pdidInstance->dwDevType & 0xFF);
if (devtype == DI8DEVTYPE_SUPPLEMENTAL) {
return DIENUM_CONTINUE; /* Ignore touchpads, etc. */
}
if (SDL_IsXInputDevice(&pdidInstance->guidProduct)) {
return DIENUM_CONTINUE; /* ignore XInput devices here, keep going. */
}
pNewJoystick = *(JoyStick_DeviceData **)pContext;
while (pNewJoystick) {
if (!SDL_memcmp(&pNewJoystick->dxdevice.guidInstance, &pdidInstance->guidInstance, sizeof(pNewJoystick->dxdevice.guidInstance))) {
/* if we are replacing the front of the list then update it */
if (pNewJoystick == *(JoyStick_DeviceData **)pContext) {
*(JoyStick_DeviceData **)pContext = pNewJoystick->pNext;
} else if (pPrevJoystick) {
pPrevJoystick->pNext = pNewJoystick->pNext;
}
pNewJoystick->pNext = SYS_Joystick;
SYS_Joystick = pNewJoystick;
return DIENUM_CONTINUE; /* already have this joystick loaded, just keep going */
}
pPrevJoystick = pNewJoystick;
pNewJoystick = pNewJoystick->pNext;
}
pNewJoystick = (JoyStick_DeviceData *)SDL_malloc(sizeof(JoyStick_DeviceData));
if (!pNewJoystick) {
return DIENUM_CONTINUE; /* better luck next time? */
}
SDL_zerop(pNewJoystick);
pNewJoystick->joystickname = WIN_StringToUTF8(pdidInstance->tszProductName);
if (!pNewJoystick->joystickname) {
SDL_free(pNewJoystick);
return DIENUM_CONTINUE; /* better luck next time? */
}
SDL_memcpy(&(pNewJoystick->dxdevice), pdidInstance,
sizeof(DIDEVICEINSTANCE));
SDL_memcpy(&pNewJoystick->guid, &pdidInstance->guidProduct, sizeof(pNewJoystick->guid));
SDL_SYS_AddJoystickDevice(pNewJoystick);
return DIENUM_CONTINUE; /* get next device, please */
}
示例13: WIN_SetError
/* Sets an error message based on GetLastError() */
void
WIN_SetError(const char *prefix)
{
TCHAR buffer[1024];
char *message;
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
buffer, SDL_arraysize(buffer), NULL);
message = WIN_StringToUTF8(buffer);
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
SDL_free(message);
}
示例14: WIN_SetErrorFromHRESULT
/* Sets an error message based on GetLastError() */
int
WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
{
TCHAR buffer[1024];
char *message;
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0,
buffer, SDL_arraysize(buffer), NULL);
message = WIN_StringToUTF8(buffer);
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
SDL_free(message);
return -1;
}
示例15: EnumJoysticksCallback
static BOOL CALLBACK
EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
{
SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance,
sizeof(DIDEVICEINSTANCE));
SYS_JoystickNames[SYS_NumJoysticks] = WIN_StringToUTF8(pdidInstance->tszProductName);
SYS_NumJoysticks++;
if (SYS_NumJoysticks >= MAX_JOYSTICKS)
return DIENUM_STOP;
return DIENUM_CONTINUE;
}