예제 #1
0
        protected override unsafe void Initialize(bgfx.Init *ini)
        {
            init(ini);

            // Enable debug text.
            set_debug((uint)DebugFlags.Text);

            // Set view 0 clear state.
            set_view_clear(0, (ushort)ClearFlags.Color | (ushort)ClearFlags.Depth, 0x303030ff, 1.0f, 0);
        }
예제 #2
0
        protected override unsafe void Initialize(bgfx.Init *ini)
        {
            init(ini);

            // Enable debug text.
            set_debug((uint)DebugFlags.Text);

            // Set view 0 clear state.
            set_view_clear(0, (ushort)ClearFlags.Color | (ushort)ClearFlags.Depth, 0x303030ff, 1.0f, 0);

            // Set view 0 default viewport.
            set_view_rect(0, 0, 0, (ushort)width, (ushort)height);

            // Create vertex stream declaration.
            PosColorVertex.init();

            var size = Marshal.SizeOf <PosColorVertex>();

            // Create static vertex buffer.
            fixed(void *data = s_cubeVertices)
            {
                fixed(VertexLayout *layout = &PosColorVertex.ms_layout)
                {
                    var r = make_ref(data, (uint)((uint)size * s_cubeVertices.Length));

                    m_vbh = create_vertex_buffer(r, layout, (ushort)BufferFlags.None);
                }
            }

            m_ibh = new IndexBufferHandle[5];

            // Create static index buffer for triangle list rendering.
            fixed(void *data = s_cubeTriList)
            {
                // Static data can be passed with bgfx::makeRef
                m_ibh[0] = create_index_buffer(make_ref(data, (uint)(sizeof(ushort) * s_cubeTriList.Length)), (ushort)BufferFlags.None);
            }

            // Create static index buffer for line list rendering.
            fixed(void *data = s_cubeTriStrip)
            {
                // Static data can be passed with bgfx::makeRef
                m_ibh[1] = create_index_buffer(make_ref(data, (uint)(sizeof(ushort) * s_cubeTriStrip.Length)), (ushort)BufferFlags.None);
            }

            // Create static index buffer for line strip rendering.
            fixed(void *data = s_cubeLineList)
            {
                // Static data can be passed with bgfx::makeRef
                m_ibh[2] = create_index_buffer(make_ref(data, (uint)(sizeof(ushort) * s_cubeLineList.Length)), (ushort)BufferFlags.None);
            }

            // Create static index buffer for line strip rendering.
            fixed(void *data = s_cubeLineStrip)
            {
                // Static data can be passed with bgfx::makeRef
                m_ibh[3] = create_index_buffer(make_ref(data, (uint)(sizeof(ushort) * s_cubeLineStrip.Length)), (ushort)BufferFlags.None);
            }

            // Create static index buffer for point list rendering.
            fixed(void *data = s_cubePoints)
            {
                // Static data can be passed with bgfx::makeRef
                m_ibh[4] = create_index_buffer(make_ref(data, (uint)(sizeof(ushort) * s_cubePoints.Length)), (ushort)BufferFlags.None);
            }

            // Create program from shaders.
            program = load_program("vs_cubes", "fs_cubes");
        }