Created demo using Direct3D 11 for rendering. Uses VS2015 for compiler.

Also fixes wrong location of GlobalUnlock in GDI rendering demo.
This commit is contained in:
Martins Mozeiko 2016-04-22 08:41:40 -07:00
parent 412f65fa65
commit 062032e933
9 changed files with 1430 additions and 3 deletions

4
.gitignore vendored
View File

@ -1,2 +1,2 @@
demo/gdi/*.exe
demo/gdi/*.obj
demo/*/*.exe
demo/*/*.obj

9
demo/d3d11/build.bat Normal file
View File

@ -0,0 +1,9 @@
@echo off
rem This will use VS2015 for compiler
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
fxc.exe /nologo /T vs_4_0_level_9_0 /E vs /O3 /WX /Zpc /Ges /Fh nuklear_d3d11_vertex_shader.h /Vn nk_d3d11_vertex_shader /Qstrip_reflect /Qstrip_debug /Qstrip_priv nuklear_d3d11.hlsl
fxc.exe /nologo /T ps_4_0_level_9_0 /E ps /O3 /WX /Zpc /Ges /Fh nuklear_d3d11_pixel_shader.h /Vn nk_d3d11_pixel_shader /Qstrip_reflect /Qstrip_debug /Qstrip_priv nuklear_d3d11.hlsl
cl /D_CRT_SECURE_NO_DEPRECATE /nologo /W3 /WX /O2 /fp:fast /Gm- /Fedemo.exe main.c user32.lib dxguid.lib d3d11.lib /link /incremental:no

248
demo/d3d11/main.c Normal file
View File

@ -0,0 +1,248 @@
/* nuklear - v1.00 - public domain */
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d11.h>
#include <stdio.h>
#include <string.h>
#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 600
#define MAX_VERTEX_BUFFER 512 * 1024
#define MAX_INDEX_BUFFER 128 * 1024
/* these defines are both needed for the header
* and source file. So if you split them remember
* to copy them as well. */
#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_STANDARD_IO
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_DEFAULT_FONT
#include "nuklear_d3d11.h"
#include "nuklear_d3d11.c"
static IDXGISwapChain *swap_chain;
static ID3D11Device *device;
static ID3D11DeviceContext *context;
static ID3D11RenderTargetView* rt_view;
static void
set_swap_chain_size(int width, int height)
{
ID3D11Texture2D *back_buffer;
D3D11_RENDER_TARGET_VIEW_DESC desc;
HRESULT hr;
if (rt_view)
ID3D11RenderTargetView_Release(rt_view);
ID3D11DeviceContext_OMSetRenderTargets(context, 0, NULL, NULL);
hr = IDXGISwapChain_ResizeBuffers(swap_chain, 0, width, height, DXGI_FORMAT_UNKNOWN, 0);
if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET || hr == DXGI_ERROR_DRIVER_INTERNAL_ERROR)
{
/* to recover from this, you'll need to recreate device and all the resources */
MessageBoxW(NULL, L"DXGI device is removed or reset!", L"Error", 0);
exit(0);
}
assert(SUCCEEDED(hr));
memset(&desc, 0, sizeof(desc));
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
hr = IDXGISwapChain_GetBuffer(swap_chain, 0, &IID_ID3D11Texture2D, &back_buffer);
assert(SUCCEEDED(hr));
hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)back_buffer, &desc, &rt_view);
assert(SUCCEEDED(hr));
ID3D11Texture2D_Release(back_buffer);
}
static LRESULT CALLBACK
WindowProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_SIZE:
if (swap_chain)
{
int width = LOWORD(lparam);
int height = HIWORD(lparam);
set_swap_chain_size(width, height);
nk_d3d11_resize(context, width, height);
}
break;
}
if (nk_d3d11_handle_event(wnd, msg, wparam, lparam))
return 0;
return DefWindowProcW(wnd, msg, wparam, lparam);
}
int main(void)
{
struct nk_context *ctx;
struct nk_color background;
WNDCLASSW wc;
RECT rect = { 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT };
DWORD style = WS_OVERLAPPEDWINDOW;
DWORD exstyle = WS_EX_APPWINDOW;
HWND wnd;
int running = 1;
HRESULT hr;
D3D_FEATURE_LEVEL feature_level;
DXGI_SWAP_CHAIN_DESC swap_chain_desc;
/* Win32 */
memset(&wc, 0, sizeof(wc));
wc.lpfnWndProc = WindowProc;
wc.hInstance = GetModuleHandleW(0);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszClassName = L"NuklearWindowClass";
RegisterClassW(&wc);
AdjustWindowRectEx(&rect, style, FALSE, exstyle);
wnd = CreateWindowExW(exstyle, wc.lpszClassName, L"Nuklear Demo",
style | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT,
rect.right - rect.left, rect.bottom - rect.top,
NULL, NULL, wc.hInstance, NULL);
/* D3D11 setup */
memset(&swap_chain_desc, 0, sizeof(swap_chain_desc));
swap_chain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swap_chain_desc.BufferDesc.RefreshRate.Numerator = 60;
swap_chain_desc.BufferDesc.RefreshRate.Denominator = 1;
swap_chain_desc.SampleDesc.Count = 1;
swap_chain_desc.SampleDesc.Quality = 0;
swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swap_chain_desc.BufferCount = 1;
swap_chain_desc.OutputWindow = wnd;
swap_chain_desc.Windowed = TRUE;
swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swap_chain_desc.Flags = 0;
if (FAILED(D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE,
NULL, 0, NULL, 0, D3D11_SDK_VERSION, &swap_chain_desc,
&swap_chain, &device, &feature_level, &context)))
{
/* if hardware device fails, then try WARP high-performance
software rasterizer, this is useful for RDP sessions */
hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_WARP,
NULL, 0, NULL, 0, D3D11_SDK_VERSION, &swap_chain_desc,
&swap_chain, &device, &feature_level, &context);
assert(SUCCEEDED(hr));
}
set_swap_chain_size(WINDOW_WIDTH, WINDOW_HEIGHT);
/* GUI */
ctx = nk_d3d11_init(device, WINDOW_WIDTH, WINDOW_HEIGHT, MAX_VERTEX_BUFFER, MAX_INDEX_BUFFER);
/* Load Fonts: if none of these are loaded a default font will be used */
{struct nk_font_atlas *atlas;
nk_d3d11_font_stash_begin(&atlas);
/*struct nk_font *droid = nk_font_atlas_add_from_file(atlas, "../../../extra_font/DroidSans.ttf", 14, 0);*/
/*struct nk_font *robot = nk_font_atlas_add_from_file(atlas, "../../../extra_font/Robot-Regular.ttf", 14, 0);*/
/*struct nk_font *future = nk_font_atlas_add_from_file(atlas, "../../../extra_font/kenvector_future_thin.ttf", 13, 0);*/
/*struct nk_font *clean = nk_font_atlas_add_from_file(atlas, "../../../extra_font/ProggyClean.ttf", 12, 0);*/
/*struct nk_font *tiny = nk_font_atlas_add_from_file(atlas, "../../../extra_font/ProggyTiny.ttf", 10, 0);*/
/*struct nk_font *cousine = nk_font_atlas_add_from_file(atlas, "../../../extra_font/Cousine-Regular.ttf", 13, 0);*/
nk_d3d11_font_stash_end();
/*nk_style_set_font(ctx, &droid->handle)*/;}
background = nk_rgb(28,48,62);
while (running)
{
MSG msg;
/* Input */
nk_input_begin(ctx);
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
running = 0;
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
nk_input_end(ctx);
/* GUI */
{struct nk_panel layout;
if (nk_begin(ctx, &layout, "Demo", nk_rect(50, 50, 230, 250),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
{
enum {EASY, HARD};
static int op = EASY;
static int property = 20;
nk_layout_row_static(ctx, 30, 80, 1);
if (nk_button_label(ctx, "button", NK_BUTTON_DEFAULT))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 22, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
{struct nk_panel combo;
nk_layout_row_dynamic(ctx, 20, 1);
nk_label(ctx, "background:", NK_TEXT_LEFT);
nk_layout_row_dynamic(ctx, 25, 1);
if (nk_combo_begin_color(ctx, &combo, background, 400)) {
nk_layout_row_dynamic(ctx, 120, 1);
background = nk_color_picker(ctx, background, NK_RGBA);
nk_layout_row_dynamic(ctx, 25, 1);
background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1);
background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1);
background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1);
background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1);
nk_combo_end(ctx);
}}
}
nk_end(ctx);}
if (nk_window_is_closed(ctx, "Demo")) break;
/* Draw */
{
float bg[4];
nk_color_fv(bg, background);
ID3D11DeviceContext_ClearRenderTargetView(context, rt_view, bg);
ID3D11DeviceContext_OMSetRenderTargets(context, 1, &rt_view, NULL);
nk_d3d11_render(context, NK_ANTI_ALIASING_ON);
hr = IDXGISwapChain_Present(swap_chain, 1, 0);
if (hr == DXGI_ERROR_DEVICE_RESET || hr == DXGI_ERROR_DEVICE_REMOVED)
{
/* to recover from this, you'll need to recreate device and all the resources */
MessageBoxW(NULL, L"D3D11 device is lost or removed!", L"Error", 0);
break;
}
else if (hr == DXGI_STATUS_OCCLUDED)
{
/* window is not visible, so vsync won't work. Let's sleep a bit to reduce CPU usage */
Sleep(10);
}
assert(SUCCEEDED(hr));
}
}
ID3D11DeviceContext_ClearState(context);
nk_d3d11_shutdown();
ID3D11ShaderResourceView_Release(rt_view);
ID3D11DeviceContext_Release(context);
ID3D11Device_Release(device);
IDXGISwapChain_Release(swap_chain);
UnregisterClassW(wc.lpszClassName, wc.hInstance);
return 0;
}

587
demo/d3d11/nuklear_d3d11.c Normal file
View File

@ -0,0 +1,587 @@
#define WIN32_LEAN_AND_MEAN
#define COBJMACROS
#include <d3d11.h>
#include <stddef.h>
#include <string.h>
#include <float.h>
#include <assert.h>
#define NK_IMPLEMENTATION
#include "nuklear_d3d11.h"
#include "../../nuklear.h"
#include "nuklear_d3d11_vertex_shader.h"
#include "nuklear_d3d11_pixel_shader.h"
static struct
{
struct nk_context ctx;
struct nk_font_atlas atlas;
struct nk_buffer cmds;
struct nk_draw_null_texture null;
unsigned int max_vertex_buffer;
unsigned int max_index_buffer;
D3D11_VIEWPORT viewport;
ID3D11Device *device;
ID3D11RasterizerState *rasterizer_state;
ID3D11VertexShader *vertex_shader;
ID3D11InputLayout *input_layout;
ID3D11Buffer *const_buffer;
ID3D11PixelShader *pixel_shader;
ID3D11BlendState *blend_state;
ID3D11Buffer *index_buffer;
ID3D11Buffer *vertex_buffer;
ID3D11ShaderResourceView *font_texture_view;
ID3D11SamplerState *sampler_state;
} d3d11;
NK_API void
nk_d3d11_render(ID3D11DeviceContext *context, enum nk_anti_aliasing AA)
{
const float blend_factor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
const UINT stride = sizeof(struct nk_draw_vertex);
const UINT offset = 0;
ID3D11DeviceContext_IASetInputLayout(context, d3d11.input_layout);
ID3D11DeviceContext_IASetVertexBuffers(context, 0, 1, &d3d11.vertex_buffer, &stride, &offset);
ID3D11DeviceContext_IASetIndexBuffer(context, d3d11.index_buffer, DXGI_FORMAT_R16_UINT, 0);
ID3D11DeviceContext_IASetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ID3D11DeviceContext_VSSetShader(context, d3d11.vertex_shader, NULL, 0);
ID3D11DeviceContext_VSSetConstantBuffers(context, 0, 1, &d3d11.const_buffer);
ID3D11DeviceContext_PSSetShader(context, d3d11.pixel_shader, NULL, 0);
ID3D11DeviceContext_PSSetSamplers(context, 0, 1, &d3d11.sampler_state);
ID3D11DeviceContext_OMSetBlendState(context, d3d11.blend_state, blend_factor, 0xffffffff);
ID3D11DeviceContext_RSSetState(context, d3d11.rasterizer_state);
ID3D11DeviceContext_RSSetViewports(context, 1, &d3d11.viewport);
/* convert from command queue into draw list and draw to screen */
{
/* load draw vertices & elements directly into vertex + element buffer */
D3D11_MAPPED_SUBRESOURCE vertices;
D3D11_MAPPED_SUBRESOURCE indices;
const struct nk_draw_command *cmd;
UINT offset = 0;
HRESULT hr;
hr = ID3D11DeviceContext_Map(context, (ID3D11Resource *)d3d11.vertex_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &vertices);
assert(SUCCEEDED(hr));
hr = ID3D11DeviceContext_Map(context, (ID3D11Resource *)d3d11.index_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &indices);
assert(SUCCEEDED(hr));
{
/* fill converting configuration */
struct nk_convert_config config;
memset(&config, 0, sizeof(config));
config.global_alpha = 1.0f;
config.shape_AA = AA;
config.line_AA = AA;
config.circle_segment_count = 22;
config.curve_segment_count = 22;
config.arc_segment_count = 22;
config.null = d3d11.null;
/* setup buffers to load vertices and elements */
{
struct nk_buffer vbuf, ibuf;
nk_buffer_init_fixed(&vbuf, vertices.pData, (size_t)d3d11.max_vertex_buffer);
nk_buffer_init_fixed(&ibuf, indices.pData, (size_t)d3d11.max_index_buffer);
nk_convert(&d3d11.ctx, &d3d11.cmds, &vbuf, &ibuf, &config);
}
}
ID3D11DeviceContext_Unmap(context, (ID3D11Resource *)d3d11.vertex_buffer, 0);
ID3D11DeviceContext_Unmap(context, (ID3D11Resource *)d3d11.index_buffer, 0);
/* iterate over and execute each draw command */
nk_draw_foreach(cmd, &d3d11.ctx, &d3d11.cmds)
{
ID3D11ShaderResourceView *texture_view = (ID3D11ShaderResourceView *)cmd->texture.ptr;
D3D11_RECT scissor;
if (!cmd->elem_count) continue;
scissor.left = (LONG)cmd->clip_rect.x;
scissor.right = (LONG)(cmd->clip_rect.x + cmd->clip_rect.w);
scissor.top = (LONG)cmd->clip_rect.y;
scissor.bottom = (LONG)(cmd->clip_rect.y + cmd->clip_rect.h);
ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &texture_view);
ID3D11DeviceContext_RSSetScissorRects(context, 1, &scissor);
ID3D11DeviceContext_DrawIndexed(context, (UINT)cmd->elem_count, offset, 0);
offset += cmd->elem_count;
}
nk_clear(&d3d11.ctx);
}
}
static void
nk_d3d11_get_projection_matrix(int width, int height, float *result)
{
const float L = 0.0f;
const float R = (float)width;
const float T = 0.0f;
const float B = (float)height;
float matrix[4][4] =
{
{ 2.0f / (R - L), 0.0f, 0.0f, 0.0f },
{ 0.0f, 2.0f / (T - B), 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.5f, 0.0f },
{ (R + L) / (L - R), (T + B) / (B - T), 0.5f, 1.0f },
};
memcpy(result, matrix, sizeof(matrix));
}
NK_API void
nk_d3d11_resize(ID3D11DeviceContext *context, int width, int height)
{
D3D11_MAPPED_SUBRESOURCE mapped;
if (SUCCEEDED(ID3D11DeviceContext_Map(context, (ID3D11Resource *)d3d11.const_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped)))
{
nk_d3d11_get_projection_matrix(width, height, (float *)mapped.pData);
ID3D11DeviceContext_Unmap(context, (ID3D11Resource *)d3d11.const_buffer, 0);
d3d11.viewport.Width = (float)width;
d3d11.viewport.Height = (float)height;
}
}
NK_API int
nk_d3d11_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_KEYDOWN:
case WM_KEYUP:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
{
int down = (lparam >> 31) & 1;
int ctrl = GetKeyState(VK_CONTROL) & (1 << 15);
switch (wparam)
{
case VK_SHIFT:
case VK_LSHIFT:
case VK_RSHIFT:
nk_input_key(&d3d11.ctx, NK_KEY_SHIFT, down);
return 1;
case VK_DELETE:
nk_input_key(&d3d11.ctx, NK_KEY_DEL, down);
return 1;
case VK_RETURN:
nk_input_key(&d3d11.ctx, NK_KEY_ENTER, down);
return 1;
case VK_TAB:
nk_input_key(&d3d11.ctx, NK_KEY_TAB, down);
return 1;
case VK_LEFT:
if (ctrl)
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_WORD_LEFT, down);
else
nk_input_key(&d3d11.ctx, NK_KEY_LEFT, down);
return 1;
case VK_RIGHT:
if (ctrl)
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_WORD_RIGHT, down);
else
nk_input_key(&d3d11.ctx, NK_KEY_RIGHT, down);
return 1;
case VK_BACK:
nk_input_key(&d3d11.ctx, NK_KEY_BACKSPACE, down);
return 1;
case VK_HOME:
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_START, down);
return 1;
case VK_END:
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_END, down);
return 1;
case 'C':
if (ctrl) {
nk_input_key(&d3d11.ctx, NK_KEY_COPY, down);
return 1;
}
break;
case 'V':
if (ctrl) {
nk_input_key(&d3d11.ctx, NK_KEY_PASTE, down);
return 1;
}
break;
case 'X':
if (ctrl) {
nk_input_key(&d3d11.ctx, NK_KEY_CUT, down);
return 1;
}
break;
case 'Z':
if (ctrl) {
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_UNDO, down);
return 1;
}
break;
case 'R':
if (ctrl) {
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_REDO, down);
return 1;
}
break;
}
return 0;
}
case WM_CHAR:
if (wparam >= 32)
{
nk_input_unicode(&d3d11.ctx, (nk_rune)wparam);
return 1;
}
break;
case WM_LBUTTONDOWN:
nk_input_button(&d3d11.ctx, NK_BUTTON_LEFT, (short)LOWORD(lparam), (short)HIWORD(lparam), 1);
SetCapture(wnd);
return 1;
case WM_LBUTTONUP:
nk_input_button(&d3d11.ctx, NK_BUTTON_LEFT, (short)LOWORD(lparam), (short)HIWORD(lparam), 0);
ReleaseCapture();
return 1;
case WM_RBUTTONDOWN:
nk_input_button(&d3d11.ctx, NK_BUTTON_RIGHT, (short)LOWORD(lparam), (short)HIWORD(lparam), 1);
SetCapture(wnd);
return 1;
case WM_RBUTTONUP:
nk_input_button(&d3d11.ctx, NK_BUTTON_RIGHT, (short)LOWORD(lparam), (short)HIWORD(lparam), 0);
ReleaseCapture();
return 1;
case WM_MBUTTONDOWN:
nk_input_button(&d3d11.ctx, NK_BUTTON_MIDDLE, (short)LOWORD(lparam), (short)HIWORD(lparam), 1);
SetCapture(wnd);
return 1;
case WM_MBUTTONUP:
nk_input_button(&d3d11.ctx, NK_BUTTON_MIDDLE, (short)LOWORD(lparam), (short)HIWORD(lparam), 0);
ReleaseCapture();
return 1;
case WM_MOUSEWHEEL:
nk_input_scroll(&d3d11.ctx, (float)(short)HIWORD(wparam) / WHEEL_DELTA);
return 1;
case WM_MOUSEMOVE:
nk_input_motion(&d3d11.ctx, (short)LOWORD(lparam), (short)HIWORD(lparam));
return 1;
}
return 0;
}
static void
nk_d3d11_clipbard_paste(nk_handle usr, struct nk_text_edit *edit)
{
(void)usr;
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL))
{
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
if (mem)
{
SIZE_T size = GlobalSize(mem) - 1;
if (size)
{
LPCWSTR wstr = (LPCWSTR)GlobalLock(mem);
if (wstr)
{
int utf8size = WideCharToMultiByte(CP_UTF8, 0, wstr, size / sizeof(wchar_t), NULL, 0, NULL, NULL);
if (utf8size)
{
char* utf8 = malloc(utf8size);
if (utf8)
{
WideCharToMultiByte(CP_UTF8, 0, wstr, size / sizeof(wchar_t), utf8, utf8size, NULL, NULL);
nk_textedit_paste(edit, utf8, utf8size);
free(utf8);
}
}
GlobalUnlock(mem);
}
}
}
CloseClipboard();
}
}
static void
nk_d3d11_clipbard_copy(nk_handle usr, const char *text, int len)
{
(void)usr;
if (OpenClipboard(NULL))
{
int wsize = MultiByteToWideChar(CP_UTF8, 0, text, len, NULL, 0);
if (wsize)
{
HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (wsize + 1) * sizeof(wchar_t));
if (mem)
{
wchar_t* wstr = GlobalLock(mem);
if (wstr)
{
MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
wstr[wsize] = 0;
GlobalUnlock(mem);
SetClipboardData(CF_UNICODETEXT, mem);
}
}
}
CloseClipboard();
}
}
NK_API struct nk_context*
nk_d3d11_init(ID3D11Device *device, int width, int height, unsigned int max_vertex_buffer, unsigned int max_index_buffer)
{
HRESULT hr;
d3d11.max_vertex_buffer = max_vertex_buffer;
d3d11.max_index_buffer = max_index_buffer;
d3d11.device = device;
ID3D11Device_AddRef(device);
nk_init_default(&d3d11.ctx, 0);
d3d11.ctx.clip.copy = nk_d3d11_clipbard_copy;
d3d11.ctx.clip.paste = nk_d3d11_clipbard_paste;
d3d11.ctx.clip.userdata = nk_handle_ptr(0);
nk_buffer_init_default(&d3d11.cmds);
/* rasterizer state */
{
D3D11_RASTERIZER_DESC desc;
memset(&desc, 0, sizeof(desc));
desc.FillMode = D3D11_FILL_SOLID;
desc.CullMode = D3D11_CULL_NONE;
desc.FrontCounterClockwise = FALSE;
desc.DepthBias = 0;
desc.DepthBiasClamp = 0;
desc.SlopeScaledDepthBias = 0.0f;
desc.DepthClipEnable = TRUE;
desc.ScissorEnable = TRUE;
desc.MultisampleEnable = FALSE;
desc.AntialiasedLineEnable = FALSE;
hr = ID3D11Device_CreateRasterizerState(device,&desc, &d3d11.rasterizer_state);
assert(SUCCEEDED(hr));
}
/* vertex shader */
{
hr = ID3D11Device_CreateVertexShader(device,nk_d3d11_vertex_shader, sizeof(nk_d3d11_vertex_shader), NULL, &d3d11.vertex_shader);
assert(SUCCEEDED(hr));
}
/* input layout */
{
const D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(struct nk_draw_vertex, position), D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(struct nk_draw_vertex, uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, offsetof(struct nk_draw_vertex, col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
hr = ID3D11Device_CreateInputLayout(device,layout, ARRAYSIZE(layout), nk_d3d11_vertex_shader, sizeof(nk_d3d11_vertex_shader), &d3d11.input_layout);
assert(SUCCEEDED(hr));
}
/* constant buffer */
{
float matrix[4*4];
D3D11_BUFFER_DESC desc;
memset(&desc, 0, sizeof(desc));
desc.ByteWidth = sizeof(matrix);
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA data;
data.pSysMem = matrix;
data.SysMemPitch = 0;
data.SysMemSlicePitch = 0;
nk_d3d11_get_projection_matrix(width, height, matrix);
hr = ID3D11Device_CreateBuffer(device, &desc, &data, &d3d11.const_buffer);
assert(SUCCEEDED(hr));
}
/* pixel shader */
{
hr = ID3D11Device_CreatePixelShader(device, nk_d3d11_pixel_shader, sizeof(nk_d3d11_pixel_shader), NULL, &d3d11.pixel_shader);
assert(SUCCEEDED(hr));
}
/* blend state */
{
D3D11_BLEND_DESC desc;
memset(&desc, 0, sizeof(desc));
desc.AlphaToCoverageEnable = FALSE;
desc.RenderTarget[0].BlendEnable = TRUE;
desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
hr = ID3D11Device_CreateBlendState(device, &desc, &d3d11.blend_state);
assert(SUCCEEDED(hr));
}
/* vertex buffer */
{
D3D11_BUFFER_DESC desc;
memset(&desc, 0, sizeof(desc));
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.ByteWidth = max_vertex_buffer;
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0;
hr = ID3D11Device_CreateBuffer(device, &desc, NULL, &d3d11.vertex_buffer);
assert(SUCCEEDED(hr));
}
/* index buffer */
{
D3D11_BUFFER_DESC desc;
memset(&desc, 0, sizeof(desc));
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.ByteWidth = max_index_buffer;
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
hr = ID3D11Device_CreateBuffer(device, &desc, NULL, &d3d11.index_buffer);
assert(SUCCEEDED(hr));
}
/* sampler state */
{
D3D11_SAMPLER_DESC desc;
memset(&desc, 0, sizeof(desc));
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
desc.MipLODBias = 0.0f;
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
desc.MinLOD = 0.0f;
desc.MaxLOD = FLT_MAX;
hr = ID3D11Device_CreateSamplerState(device, &desc, &d3d11.sampler_state);
assert(SUCCEEDED(hr));
}
/* viewport */
{
d3d11.viewport.TopLeftX = 0.0f;
d3d11.viewport.TopLeftY = 0.0f;
d3d11.viewport.Width = (float)width;
d3d11.viewport.Height = (float)height;
d3d11.viewport.MinDepth = 0.0f;
d3d11.viewport.MaxDepth = 1.0f;
}
return &d3d11.ctx;
}
NK_API void
nk_d3d11_font_stash_begin(struct nk_font_atlas **atlas)
{
nk_font_atlas_init_default(&d3d11.atlas);
nk_font_atlas_begin(&d3d11.atlas);
*atlas = &d3d11.atlas;
}
NK_API void
nk_d3d11_font_stash_end(void)
{
const void *image; int w, h;
image = nk_font_atlas_bake(&d3d11.atlas, &w, &h, NK_FONT_ATLAS_RGBA32);
/* upload font to texture and create texture view */
{
ID3D11Texture2D *font_texture;
HRESULT hr;
D3D11_TEXTURE2D_DESC desc;
memset(&desc, 0, sizeof(desc));
desc.Width = (UINT)w;
desc.Height = (UINT)h;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0;
D3D11_SUBRESOURCE_DATA data;
data.pSysMem = image;
data.SysMemPitch = (UINT)(w * 4);
data.SysMemSlicePitch = 0;
hr = ID3D11Device_CreateTexture2D(d3d11.device, &desc, &data, &font_texture);
assert(SUCCEEDED(hr));
D3D11_SHADER_RESOURCE_VIEW_DESC srv;
memset(&srv, 0, sizeof(srv));
srv.Format = desc.Format;
srv.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
srv.Texture2D.MipLevels = 1;
srv.Texture2D.MostDetailedMip = 0;
hr = ID3D11Device_CreateShaderResourceView(d3d11.device, (ID3D11Resource *)font_texture, &srv, &d3d11.font_texture_view);
assert(SUCCEEDED(hr));
ID3D11Texture2D_Release(font_texture);
}
nk_font_atlas_end(&d3d11.atlas, nk_handle_ptr(d3d11.font_texture_view), &d3d11.null);
if (d3d11.atlas.default_font)
nk_style_set_font(&d3d11.ctx, &d3d11.atlas.default_font->handle);
}
NK_API
void nk_d3d11_shutdown(void)
{
nk_font_atlas_clear(&d3d11.atlas);
nk_buffer_free(&d3d11.cmds);
nk_free(&d3d11.ctx);
ID3D11SamplerState_Release(d3d11.sampler_state);
ID3D11ShaderResourceView_Release(d3d11.font_texture_view);
ID3D11Buffer_Release(d3d11.vertex_buffer);
ID3D11Buffer_Release(d3d11.index_buffer);
ID3D11BlendState_Release(d3d11.blend_state);
ID3D11PixelShader_Release(d3d11.pixel_shader);
ID3D11Buffer_Release(d3d11.const_buffer);
ID3D11VertexShader_Release(d3d11.vertex_shader);
ID3D11InputLayout_Release(d3d11.input_layout);
ID3D11RasterizerState_Release(d3d11.rasterizer_state);
ID3D11Device_Release(d3d11.device);
}

View File

@ -0,0 +1,18 @@
#ifndef NK_D3D11_H_
#define NK_D3D11_H_
#include "../../nuklear.h"
typedef struct ID3D11Device ID3D11Device;
typedef struct ID3D11DeviceContext ID3D11DeviceContext;
NK_API struct nk_context *nk_d3d11_init(ID3D11Device *device, int width, int height, unsigned int max_vertex_buffer, unsigned int max_index_buffer);
NK_API void nk_d3d11_font_stash_begin(struct nk_font_atlas **atlas);
NK_API void nk_d3d11_font_stash_end(void);
NK_API void nk_d3d11_render(ID3D11DeviceContext *context, enum nk_anti_aliasing);
NK_API void nk_d3d11_resize(ID3D11DeviceContext *context, int width, int height);
NK_API void nk_d3d11_shutdown(void);
NK_API int nk_d3d11_handle_event(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
#endif

View File

@ -0,0 +1,36 @@
//
cbuffer buffer0 : register(b0)
{
float4x4 ProjectionMatrix;
};
sampler sampler0 : register(s0);
Texture2D<float4> texture0 : register(t0);
struct VS_INPUT
{
float2 pos : POSITION;
float4 col : COLOR0;
float2 uv : TEXCOORD0;
};
struct PS_INPUT
{
float4 pos : SV_POSITION;
float4 col : COLOR0;
float2 uv : TEXCOORD0;
};
PS_INPUT vs(VS_INPUT input)
{
PS_INPUT output;
output.pos = mul(ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));
output.col = input.col;
output.uv = input.uv;
return output;
}
float4 ps(PS_INPUT input) : SV_Target
{
return input.col * texture0.Sample(sampler0, input.uv);
}

View File

@ -0,0 +1,179 @@
#if 0
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float
// COLOR 0 xyzw 1 NONE float xyzw
// TEXCOORD 0 xy 2 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
//
// Sampler/Resource to DX9 shader sampler mappings:
//
// Target Sampler Source Sampler Source Resource
// -------------- --------------- ----------------
// s0 s0 t0
//
//
// Level9 shader bytecode:
//
ps_2_0
dcl t0
dcl t1.xy
dcl_2d s0
texld r0, t1, s0
mul r0, r0, t0
mov oC0, r0
// approximately 3 instruction slots used (1 texture, 2 arithmetic)
//
// Sampler/Resource to DX9 shader sampler mappings:
//
// Target Sampler Source Sampler Source Resource
// -------------- --------------- ----------------
// s0 s0 t0
//
//
// XNA shader bytecode:
//
ps_2_0
dcl t0
dcl t1.xy
dcl_2d s0
texld r0, r2, s0
mul oC0, r0, r1
// approximately 2 instruction slots used (1 texture, 1 arithmetic)
ps_4_0
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xy
dcl_output o0.xyzw
dcl_temps 1
sample r0.xyzw, v2.xyxx, t0.xyzw, s0
mul o0.xyzw, r0.xyzw, v1.xyzw
ret
// Approximately 0 instruction slots used
#endif
const BYTE nk_d3d11_pixel_shader[] =
{
68, 88, 66, 67, 249, 46,
26, 75, 111, 182, 161, 241,
199, 179, 191, 89, 44, 229,
245, 103, 1, 0, 0, 0,
124, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
176, 0, 0, 0, 56, 1,
0, 0, 212, 1, 0, 0,
72, 2, 0, 0, 88, 78,
65, 83, 116, 0, 0, 0,
116, 0, 0, 0, 0, 2,
255, 255, 76, 0, 0, 0,
40, 0, 0, 0, 0, 0,
40, 0, 0, 0, 40, 0,
0, 0, 40, 0, 1, 0,
36, 0, 0, 0, 40, 0,
0, 0, 0, 0, 0, 2,
255, 255, 31, 0, 0, 2,
0, 0, 0, 128, 0, 0,
15, 176, 31, 0, 0, 2,
0, 0, 0, 128, 1, 0,
3, 176, 31, 0, 0, 2,
0, 0, 0, 144, 0, 8,
15, 160, 66, 0, 0, 3,
0, 0, 15, 128, 2, 0,
228, 128, 0, 8, 228, 160,
5, 0, 0, 3, 0, 8,
15, 128, 0, 0, 228, 128,
1, 0, 228, 128, 255, 255,
0, 0, 65, 111, 110, 57,
128, 0, 0, 0, 128, 0,
0, 0, 0, 2, 255, 255,
88, 0, 0, 0, 40, 0,
0, 0, 0, 0, 40, 0,
0, 0, 40, 0, 0, 0,
40, 0, 1, 0, 36, 0,
0, 0, 40, 0, 0, 0,
0, 0, 0, 2, 255, 255,
31, 0, 0, 2, 0, 0,
0, 128, 0, 0, 15, 176,
31, 0, 0, 2, 0, 0,
0, 128, 1, 0, 3, 176,
31, 0, 0, 2, 0, 0,
0, 144, 0, 8, 15, 160,
66, 0, 0, 3, 0, 0,
15, 128, 1, 0, 228, 176,
0, 8, 228, 160, 5, 0,
0, 3, 0, 0, 15, 128,
0, 0, 228, 128, 0, 0,
228, 176, 1, 0, 0, 2,
0, 8, 15, 128, 0, 0,
228, 128, 255, 255, 0, 0,
83, 72, 68, 82, 148, 0,
0, 0, 64, 0, 0, 0,
37, 0, 0, 0, 90, 0,
0, 3, 0, 96, 16, 0,
0, 0, 0, 0, 88, 24,
0, 4, 0, 112, 16, 0,
0, 0, 0, 0, 85, 85,
0, 0, 98, 16, 0, 3,
242, 16, 16, 0, 1, 0,
0, 0, 98, 16, 0, 3,
50, 16, 16, 0, 2, 0,
0, 0, 101, 0, 0, 3,
242, 32, 16, 0, 0, 0,
0, 0, 104, 0, 0, 2,
1, 0, 0, 0, 69, 0,
0, 9, 242, 0, 16, 0,
0, 0, 0, 0, 70, 16,
16, 0, 2, 0, 0, 0,
70, 126, 16, 0, 0, 0,
0, 0, 0, 96, 16, 0,
0, 0, 0, 0, 56, 0,
0, 7, 242, 32, 16, 0,
0, 0, 0, 0, 70, 14,
16, 0, 0, 0, 0, 0,
70, 30, 16, 0, 1, 0,
0, 0, 62, 0, 0, 1,
73, 83, 71, 78, 108, 0,
0, 0, 3, 0, 0, 0,
8, 0, 0, 0, 80, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 92, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 3, 0,
0, 0, 1, 0, 0, 0,
15, 15, 0, 0, 98, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 3, 0,
0, 0, 2, 0, 0, 0,
3, 3, 0, 0, 83, 86,
95, 80, 79, 83, 73, 84,
73, 79, 78, 0, 67, 79,
76, 79, 82, 0, 84, 69,
88, 67, 79, 79, 82, 68,
0, 171, 79, 83, 71, 78,
44, 0, 0, 0, 1, 0,
0, 0, 8, 0, 0, 0,
32, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
83, 86, 95, 84, 97, 114,
103, 101, 116, 0, 171, 171
};

View File

@ -0,0 +1,350 @@
#if 0
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION 0 xy 0 NONE float xy
// COLOR 0 xyzw 1 NONE float xyzw
// TEXCOORD 0 xy 2 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float xyzw
// COLOR 0 xyzw 1 NONE float xyzw
// TEXCOORD 0 xy 2 NONE float xy
//
//
// Constant buffer to DX9 shader constant mappings:
//
// Target Reg Buffer Start Reg # of Regs Data Conversion
// ---------- ------- --------- --------- ----------------------
// c1 cb0 0 4 ( FLT, FLT, FLT, FLT)
//
//
// Runtime generated constant mappings:
//
// Target Reg Constant Description
// ---------- --------------------------------------------------
// c0 Vertex Shader position offset
//
//
// Level9 shader bytecode:
//
vs_2_0
def c5, 0, 1, 0, 0
dcl_texcoord v0
dcl_texcoord1 v1
dcl_texcoord2 v2
mul r0, v0.x, c1
mad r0, c2, v0.y, r0
mov r1.xy, c5
mad r0, c3, r1.x, r0
mad r0, c4, r1.y, r0
mul r1.xy, r0.w, c0
add oPos.xy, r0, r1
mov oPos.zw, r0
mov oT0, v1
mov oT1.xy, v2
// approximately 10 instruction slots used
//
// Constant buffer to DX9 shader constant mappings:
//
// Target Reg Buffer Start Reg # of Regs Data Conversion
// ---------- ------- --------- --------- ----------------------
// c0 cb0 0 4 ( FLT, FLT, FLT, FLT)
//
//
// XNA Prepass shader bytecode:
//
vs_2_0
def c4, 0, 1, 0, 0
dcl_texcoord v0
mul r1, r0.x, c0
mad r0, c1, r0.y, r1
mov r1.xy, c4
mad r0, c2, r1.x, r0
mad r0, c3, r1.y, r0
mov oPos, r0
// approximately 6 instruction slots used
//
// Constant buffer to DX9 shader constant mappings:
//
// Target Reg Buffer Start Reg # of Regs Data Conversion
// ---------- ------- --------- --------- ----------------------
// c0 cb0 0 4 ( FLT, FLT, FLT, FLT)
//
//
// XNA shader bytecode:
//
vs_2_0
def c4, 0, 1, 0, 0
dcl_texcoord v0
dcl_texcoord1 v1
dcl_texcoord2 v2
mov oT0, r1
mov oT1.xy, r2
mul r1, r0.x, c0
mad r0, c1, r0.y, r1
mov r1.xy, c4
mad r0, c2, r1.x, r0
mad r0, c3, r1.y, r0
mov oPos, r0
// approximately 8 instruction slots used
vs_4_0
dcl_constantbuffer cb0[4], immediateIndexed
dcl_input v0.xy
dcl_input v1.xyzw
dcl_input v2.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_temps 1
mul r0.xyzw, v0.xxxx, cb0[0].xyzw
mad r0.xyzw, cb0[1].xyzw, v0.yyyy, r0.xyzw
mad r0.xyzw, cb0[2].xyzw, l(0.000000, 0.000000, 0.000000, 0.000000), r0.xyzw
mad o0.xyzw, cb0[3].xyzw, l(1.000000, 1.000000, 1.000000, 1.000000), r0.xyzw
mov o1.xyzw, v1.xyzw
mov o2.xy, v2.xyxx
ret
// Approximately 0 instruction slots used
#endif
const BYTE nk_d3d11_vertex_shader[] =
{
68, 88, 66, 67, 215, 245,
86, 155, 188, 117, 37, 118,
193, 207, 209, 90, 160, 153,
246, 188, 1, 0, 0, 0,
72, 5, 0, 0, 6, 0,
0, 0, 56, 0, 0, 0,
48, 1, 0, 0, 248, 1,
0, 0, 20, 3, 0, 0,
100, 4, 0, 0, 212, 4,
0, 0, 88, 78, 65, 83,
240, 0, 0, 0, 240, 0,
0, 0, 0, 2, 254, 255,
192, 0, 0, 0, 48, 0,
0, 0, 1, 0, 36, 0,
0, 0, 48, 0, 0, 0,
48, 0, 0, 0, 36, 0,
0, 0, 48, 0, 0, 0,
0, 0, 4, 0, 0, 0,
0, 0, 0, 0, 0, 2,
254, 255, 81, 0, 0, 5,
4, 0, 15, 160, 0, 0,
0, 0, 0, 0, 128, 63,
0, 0, 0, 0, 0, 0,
0, 0, 31, 0, 0, 2,
5, 0, 0, 128, 0, 0,
15, 144, 31, 0, 0, 2,
5, 0, 1, 128, 1, 0,
15, 144, 31, 0, 0, 2,
5, 0, 2, 128, 2, 0,
15, 144, 1, 0, 0, 2,
0, 0, 15, 224, 1, 0,
228, 128, 1, 0, 0, 2,
1, 0, 3, 224, 2, 0,
228, 128, 5, 0, 0, 3,
1, 0, 15, 128, 0, 0,
0, 128, 0, 0, 228, 160,
4, 0, 0, 4, 0, 0,
15, 128, 1, 0, 228, 160,
0, 0, 85, 128, 1, 0,
228, 128, 1, 0, 0, 2,
1, 0, 3, 128, 4, 0,
228, 160, 4, 0, 0, 4,
0, 0, 15, 128, 2, 0,
228, 160, 1, 0, 0, 128,
0, 0, 228, 128, 4, 0,
0, 4, 0, 0, 15, 128,
3, 0, 228, 160, 1, 0,
85, 128, 0, 0, 228, 128,
1, 0, 0, 2, 0, 0,
15, 192, 0, 0, 228, 128,
255, 255, 0, 0, 88, 78,
65, 80, 192, 0, 0, 0,
192, 0, 0, 0, 0, 2,
254, 255, 144, 0, 0, 0,
48, 0, 0, 0, 1, 0,
36, 0, 0, 0, 48, 0,
0, 0, 48, 0, 0, 0,
36, 0, 0, 0, 48, 0,
0, 0, 0, 0, 4, 0,
0, 0, 0, 0, 0, 0,
0, 2, 254, 255, 81, 0,
0, 5, 4, 0, 15, 160,
0, 0, 0, 0, 0, 0,
128, 63, 0, 0, 0, 0,
0, 0, 0, 0, 31, 0,
0, 2, 5, 0, 0, 128,
0, 0, 15, 144, 5, 0,
0, 3, 1, 0, 15, 128,
0, 0, 0, 128, 0, 0,
228, 160, 4, 0, 0, 4,
0, 0, 15, 128, 1, 0,
228, 160, 0, 0, 85, 128,
1, 0, 228, 128, 1, 0,
0, 2, 1, 0, 3, 128,
4, 0, 228, 160, 4, 0,
0, 4, 0, 0, 15, 128,
2, 0, 228, 160, 1, 0,
0, 128, 0, 0, 228, 128,
4, 0, 0, 4, 0, 0,
15, 128, 3, 0, 228, 160,
1, 0, 85, 128, 0, 0,
228, 128, 1, 0, 0, 2,
0, 0, 15, 192, 0, 0,
228, 128, 255, 255, 0, 0,
65, 111, 110, 57, 20, 1,
0, 0, 20, 1, 0, 0,
0, 2, 254, 255, 224, 0,
0, 0, 52, 0, 0, 0,
1, 0, 36, 0, 0, 0,
48, 0, 0, 0, 48, 0,
0, 0, 36, 0, 1, 0,
48, 0, 0, 0, 0, 0,
4, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 2, 254, 255, 81, 0,
0, 5, 5, 0, 15, 160,
0, 0, 0, 0, 0, 0,
128, 63, 0, 0, 0, 0,
0, 0, 0, 0, 31, 0,
0, 2, 5, 0, 0, 128,
0, 0, 15, 144, 31, 0,
0, 2, 5, 0, 1, 128,
1, 0, 15, 144, 31, 0,
0, 2, 5, 0, 2, 128,
2, 0, 15, 144, 5, 0,
0, 3, 0, 0, 15, 128,
0, 0, 0, 144, 1, 0,
228, 160, 4, 0, 0, 4,
0, 0, 15, 128, 2, 0,
228, 160, 0, 0, 85, 144,
0, 0, 228, 128, 1, 0,
0, 2, 1, 0, 3, 128,
5, 0, 228, 160, 4, 0,
0, 4, 0, 0, 15, 128,
3, 0, 228, 160, 1, 0,
0, 128, 0, 0, 228, 128,
4, 0, 0, 4, 0, 0,
15, 128, 4, 0, 228, 160,
1, 0, 85, 128, 0, 0,
228, 128, 5, 0, 0, 3,
1, 0, 3, 128, 0, 0,
255, 128, 0, 0, 228, 160,
2, 0, 0, 3, 0, 0,
3, 192, 0, 0, 228, 128,
1, 0, 228, 128, 1, 0,
0, 2, 0, 0, 12, 192,
0, 0, 228, 128, 1, 0,
0, 2, 0, 0, 15, 224,
1, 0, 228, 144, 1, 0,
0, 2, 1, 0, 3, 224,
2, 0, 228, 144, 255, 255,
0, 0, 83, 72, 68, 82,
72, 1, 0, 0, 64, 0,
1, 0, 82, 0, 0, 0,
89, 0, 0, 4, 70, 142,
32, 0, 0, 0, 0, 0,
4, 0, 0, 0, 95, 0,
0, 3, 50, 16, 16, 0,
0, 0, 0, 0, 95, 0,
0, 3, 242, 16, 16, 0,
1, 0, 0, 0, 95, 0,
0, 3, 50, 16, 16, 0,
2, 0, 0, 0, 103, 0,
0, 4, 242, 32, 16, 0,
0, 0, 0, 0, 1, 0,
0, 0, 101, 0, 0, 3,
242, 32, 16, 0, 1, 0,
0, 0, 101, 0, 0, 3,
50, 32, 16, 0, 2, 0,
0, 0, 104, 0, 0, 2,
1, 0, 0, 0, 56, 0,
0, 8, 242, 0, 16, 0,
0, 0, 0, 0, 6, 16,
16, 0, 0, 0, 0, 0,
70, 142, 32, 0, 0, 0,
0, 0, 0, 0, 0, 0,
50, 0, 0, 10, 242, 0,
16, 0, 0, 0, 0, 0,
70, 142, 32, 0, 0, 0,
0, 0, 1, 0, 0, 0,
86, 21, 16, 0, 0, 0,
0, 0, 70, 14, 16, 0,
0, 0, 0, 0, 50, 0,
0, 13, 242, 0, 16, 0,
0, 0, 0, 0, 70, 142,
32, 0, 0, 0, 0, 0,
2, 0, 0, 0, 2, 64,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
70, 14, 16, 0, 0, 0,
0, 0, 50, 0, 0, 13,
242, 32, 16, 0, 0, 0,
0, 0, 70, 142, 32, 0,
0, 0, 0, 0, 3, 0,
0, 0, 2, 64, 0, 0,
0, 0, 128, 63, 0, 0,
128, 63, 0, 0, 128, 63,
0, 0, 128, 63, 70, 14,
16, 0, 0, 0, 0, 0,
54, 0, 0, 5, 242, 32,
16, 0, 1, 0, 0, 0,
70, 30, 16, 0, 1, 0,
0, 0, 54, 0, 0, 5,
50, 32, 16, 0, 2, 0,
0, 0, 70, 16, 16, 0,
2, 0, 0, 0, 62, 0,
0, 1, 73, 83, 71, 78,
104, 0, 0, 0, 3, 0,
0, 0, 8, 0, 0, 0,
80, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 3, 3, 0, 0,
89, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0,
0, 0, 15, 15, 0, 0,
95, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 2, 0,
0, 0, 3, 3, 0, 0,
80, 79, 83, 73, 84, 73,
79, 78, 0, 67, 79, 76,
79, 82, 0, 84, 69, 88,
67, 79, 79, 82, 68, 0,
79, 83, 71, 78, 108, 0,
0, 0, 3, 0, 0, 0,
8, 0, 0, 0, 80, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 92, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 3, 0,
0, 0, 1, 0, 0, 0,
15, 0, 0, 0, 98, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 3, 0,
0, 0, 2, 0, 0, 0,
3, 12, 0, 0, 83, 86,
95, 80, 79, 83, 73, 84,
73, 79, 78, 0, 67, 79,
76, 79, 82, 0, 84, 69,
88, 67, 79, 79, 82, 68,
0, 171
};

View File

@ -382,8 +382,8 @@ nk_gdi_clipbard_paste(nk_handle usr, struct nk_text_edit *edit)
nk_textedit_paste(edit, utf8, utf8size);
free(utf8);
}
GlobalUnlock(mem);
}
GlobalUnlock(mem);
}
}
}