コード例 #1
0
 public static extern nk_font *nk_font_atlas_add_compressed(
     nk_font_atlas *atlas,
     IntPtr memory,
     IntPtr size,
     float height,
     nk_font_config *fconfig
     );
コード例 #2
0
ファイル: NuklearAPI.cs プロジェクト: Nurkz/NuklearDotNet
        //public  NuklearAPI(NuklearDevice Device) {
        public static void Init(NuklearDevice Device)
        {
            if (Initialized)
            {
                throw new InvalidOperationException("NuklearAPI.Init is called twice");
            }

            Initialized = true;

            Dev           = Device;
            FrameBuffered = Device as IFrameBuffered;

            // TODO: Free these later
            Ctx         = (nk_context *)ManagedAlloc(sizeof(nk_context));
            Allocator   = (nk_allocator *)ManagedAlloc(sizeof(nk_allocator));
            FontAtlas   = (nk_font_atlas *)ManagedAlloc(sizeof(nk_font_atlas));
            NullTexture = (nk_draw_null_texture *)ManagedAlloc(sizeof(nk_draw_null_texture));
            ConvertCfg  = (nk_convert_config *)ManagedAlloc(sizeof(nk_convert_config));
            Commands    = (nk_buffer *)ManagedAlloc(sizeof(nk_buffer));
            Vertices    = (nk_buffer *)ManagedAlloc(sizeof(nk_buffer));
            Indices     = (nk_buffer *)ManagedAlloc(sizeof(nk_buffer));

            VertexLayout    = (nk_draw_vertex_layout_element *)ManagedAlloc(sizeof(nk_draw_vertex_layout_element) * 4);
            VertexLayout[0] = new nk_draw_vertex_layout_element(nk_draw_vertex_layout_attribute.NK_VERTEX_POSITION, nk_draw_vertex_layout_format.NK_FORMAT_FLOAT,
                                                                Marshal.OffsetOf(typeof(NkVertex), nameof(NkVertex.Position)));
            VertexLayout[1] = new nk_draw_vertex_layout_element(nk_draw_vertex_layout_attribute.NK_VERTEX_TEXCOORD, nk_draw_vertex_layout_format.NK_FORMAT_FLOAT,
                                                                Marshal.OffsetOf(typeof(NkVertex), nameof(NkVertex.UV)));
            VertexLayout[2] = new nk_draw_vertex_layout_element(nk_draw_vertex_layout_attribute.NK_VERTEX_COLOR, nk_draw_vertex_layout_format.NK_FORMAT_R8G8B8A8,
                                                                Marshal.OffsetOf(typeof(NkVertex), nameof(NkVertex.Color)));
            VertexLayout[3] = nk_draw_vertex_layout_element.NK_VERTEX_LAYOUT_END;

            Alloc = (Handle, Old, Size) => ManagedAlloc(Size);
            Free  = (Handle, Old) => ManagedFree(Old);

            //GCHandle.Alloc(Alloc);
            //GCHandle.Alloc(Free);

            Allocator->alloc_nkpluginalloct = Marshal.GetFunctionPointerForDelegate(Alloc);
            Allocator->free_nkpluginfreet   = Marshal.GetFunctionPointerForDelegate(Free);

            Nuklear.nk_init(Ctx, Allocator, null);

            Dev.Init();
            FontStash(Dev.FontStash);

            ConvertCfg->shape_AA             = nk_anti_aliasing.NK_ANTI_ALIASING_ON;
            ConvertCfg->line_AA              = nk_anti_aliasing.NK_ANTI_ALIASING_ON;
            ConvertCfg->vertex_layout        = VertexLayout;
            ConvertCfg->vertex_size          = new IntPtr(sizeof(NkVertex));
            ConvertCfg->vertex_alignment     = new IntPtr(1);
            ConvertCfg->circle_segment_count = 22;
            ConvertCfg->curve_segment_count  = 22;
            ConvertCfg->arc_segment_count    = 22;
            ConvertCfg->global_alpha         = 1.0f;
            ConvertCfg->null_tex             = *NullTexture;

            Nuklear.nk_buffer_init(Commands, Allocator, new IntPtr(4 * 1024));
            Nuklear.nk_buffer_init(Vertices, Allocator, new IntPtr(4 * 1024));
            Nuklear.nk_buffer_init(Indices, Allocator, new IntPtr(4 * 1024));
        }
コード例 #3
0
        public NuklearRenderer(NuklearDevice device)
        {
            Device         = device;
            _frameBuffered = Device as IFrameBuffered;

            _nuklearContext = (nk_context *)ManagedAlloc(sizeof(nk_context));
            _allocator      = (nk_allocator *)ManagedAlloc(sizeof(nk_allocator));
            _fontAtlas      = (nk_font_atlas *)ManagedAlloc(sizeof(nk_font_atlas));
            _nullTexture    = (nk_draw_null_texture *)ManagedAlloc(sizeof(nk_draw_null_texture));
            _convertConfig  = (nk_convert_config *)ManagedAlloc(sizeof(nk_convert_config));
            _commands       = (nk_buffer *)ManagedAlloc(sizeof(nk_buffer));
            _vertices       = (nk_buffer *)ManagedAlloc(sizeof(nk_buffer));
            _indices        = (nk_buffer *)ManagedAlloc(sizeof(nk_buffer));

            _vertexLayout    = (nk_draw_vertex_layout_element *)ManagedAlloc(sizeof(nk_draw_vertex_layout_element) * 4);
            _vertexLayout[0] = new nk_draw_vertex_layout_element(nk_draw_vertex_layout_attribute.NK_VERTEX_POSITION,
                                                                 nk_draw_vertex_layout_format.NK_FORMAT_FLOAT,
                                                                 Marshal.OffsetOf(typeof(nk_vertex), nameof(nk_vertex.position)));
            _vertexLayout[1] = new nk_draw_vertex_layout_element(nk_draw_vertex_layout_attribute.NK_VERTEX_TEXCOORD,
                                                                 nk_draw_vertex_layout_format.NK_FORMAT_FLOAT,
                                                                 Marshal.OffsetOf(typeof(nk_vertex), nameof(nk_vertex.uv)));
            _vertexLayout[2] = new nk_draw_vertex_layout_element(nk_draw_vertex_layout_attribute.NK_VERTEX_COLOR,
                                                                 nk_draw_vertex_layout_format.NK_FORMAT_R8G8B8A8,
                                                                 Marshal.OffsetOf(typeof(nk_vertex), nameof(nk_vertex.color)));
            _vertexLayout[3] = nk_draw_vertex_layout_element.NK_VERTEX_LAYOUT_END;

            _alloc = (_, _, size) => ManagedAlloc(size);
            _free  = (_, old) => ManagedFree(old);

            _allocator->alloc_nkpluginalloct = Marshal.GetFunctionPointerForDelegate(_alloc);
            _allocator->free_nkpluginfreet   = Marshal.GetFunctionPointerForDelegate(_free);

            Nuklear.nk_init(_nuklearContext, _allocator, null);

            Device.Init();
            FontStash(Device.FontStash);

            _convertConfig->shape_AA             = nk_anti_aliasing.NK_ANTI_ALIASING_ON;
            _convertConfig->line_AA              = nk_anti_aliasing.NK_ANTI_ALIASING_ON;
            _convertConfig->vertex_layout        = _vertexLayout;
            _convertConfig->vertex_size          = new IntPtr(sizeof(nk_vertex));
            _convertConfig->vertex_alignment     = new IntPtr(1);
            _convertConfig->circle_segment_count = 22;
            _convertConfig->curve_segment_count  = 22;
            _convertConfig->arc_segment_count    = 22;
            _convertConfig->global_alpha         = 1.0f;
            _convertConfig->null_tex             = *_nullTexture;

            Nuklear.nk_buffer_init(_commands, _allocator, new IntPtr(4 * 1024));
            Nuklear.nk_buffer_init(_vertices, _allocator, new IntPtr(4 * 1024));
            Nuklear.nk_buffer_init(_indices, _allocator, new IntPtr(4 * 1024));

            NuklearUI.InitializeContext(_nuklearContext);
        }
コード例 #4
0
ファイル: Font.cs プロジェクト: leafi/NuklearDotNet
 public static extern nk_font *nk_font_atlas_add(nk_font_atlas *atlas, nk_font_config *fconfig);
コード例 #5
0
ファイル: Font.cs プロジェクト: leafi/NuklearDotNet
 public static extern nk_font *nk_font_atlas_add_default(nk_font_atlas *atlas, float height, nk_font_config *fconfig);
コード例 #6
0
ファイル: Font.cs プロジェクト: leafi/NuklearDotNet
 public static extern void nk_font_atlas_init_custom(nk_font_atlas *atlas, nk_allocator *persistent, nk_allocator *transient);
コード例 #7
0
ファイル: Font.cs プロジェクト: leafi/NuklearDotNet
 public static extern void nk_font_atlas_begin(nk_font_atlas *atlas);
コード例 #8
0
 public static void nk_font_atlas_begin(nk_font_atlas *atlas) => _nk_font_atlas_begin(atlas);
コード例 #9
0
ファイル: Font.cs プロジェクト: leafi/NuklearDotNet
 public static extern void nk_font_atlas_init(nk_font_atlas *atlas, nk_allocator *alloc);
コード例 #10
0
ファイル: Font.cs プロジェクト: leafi/NuklearDotNet
 public static extern void nk_font_atlas_end(nk_font_atlas *atlas, nk_handle tex, nk_draw_null_texture *drawnulltex);
コード例 #11
0
 public static nk_font *nk_font_atlas_add_default(nk_font_atlas *atlas, float height, nk_font_config *fconfig) => _nk_font_atlas_add_default(atlas, height, fconfig);
コード例 #12
0
 public static void nk_font_atlas_end(nk_font_atlas *atlas, nk_handle tex, nk_draw_null_texture *drawnulltex) => _nk_font_atlas_end(atlas, tex, drawnulltex);
コード例 #13
0
 public static void nk_font_atlas_clear(nk_font_atlas *atlas) => _nk_font_atlas_clear(atlas);
コード例 #14
0
 public static IntPtr nk_font_atlas_bake(nk_font_atlas *atlas, int *width, int *height, nk_font_atlas_format afmt) => _nk_font_atlas_bake(atlas, width, height, afmt);
コード例 #15
0
 public static nk_font *nk_font_atlas_add_compressed_base85(nk_font_atlas *atlas, byte *data, float height, nk_font_config *fconfig) => _nk_font_atlas_add_compressed_base85(atlas, data, height, fconfig);
コード例 #16
0
 public static nk_font *nk_font_atlas_add_compressed(nk_font_atlas *atlas, IntPtr memory, IntPtr size, float height, nk_font_config *fconfig) => _nk_font_atlas_add_compressed(atlas, memory, size, height, fconfig);
コード例 #17
0
ファイル: Font.cs プロジェクト: leafi/NuklearDotNet
 public static extern nk_font *nk_font_atlas_add_compressed_base85(nk_font_atlas *atlas, byte *data, float height, nk_font_config *fconfig);
コード例 #18
0
 public static void nk_font_atlas_init_custom(nk_font_atlas *atlas, nk_allocator *persistent, nk_allocator *transient) => _nk_font_atlas_init_custom(atlas, persistent, transient);
コード例 #19
0
ファイル: Font.cs プロジェクト: leafi/NuklearDotNet
 public static extern IntPtr nk_font_atlas_bake(nk_font_atlas *atlas, int *width, int *height, nk_font_atlas_format afmt);
コード例 #20
0
 public static nk_font *nk_font_atlas_add(nk_font_atlas *atlas, nk_font_config *fconfig) => _nk_font_atlas_add(atlas, fconfig);
コード例 #21
0
ファイル: Font.cs プロジェクト: leafi/NuklearDotNet
 public static extern void nk_font_atlas_clear(nk_font_atlas *atlas);
コード例 #22
0
 public static void nk_font_atlas_init(nk_font_atlas *atlas, nk_allocator *alloc) => _nk_font_atlas_init(atlas, alloc);