Example #1
0
        private void Generate()
        {
            _shader = ShaderManager.GetOrCreateShader("slab_block", Shaders.slab_vertex, Shaders.slab_fragment);
            foreach (var face in BlockFaceMethods.All)
            {
                var vao = BlockFaceVertices.CreateVao(face, SlabHeight);
                vao.Bind();
                var vbo = new VertexBufferObject();
                vao.LinkBuffer(vbo);
                vbo.Bind(BufferTarget.ArrayBuffer);
                vbo.SetData(BufferTarget.ArrayBuffer, MaxFaces * InstanceFloatDataLength, BufferUsageHint.StreamDraw);
                var builder = new AttributePointerBuilder(vao, InstanceDataLength, 3);
                builder.AddPointer(3, true);
                builder.AddPointer(1, true);
                builder.AddPointer(1, true);
                builder.AddPointer(1, true);
                builder.AddPointer(1, true);
                builder.AddPointer(1, true);
                VertexBufferObject.Unbind(BufferTarget.ArrayBuffer);
                VertexArrayObject.Unbind();

                var i = (int)face;

                _vaos[i]        = vao;
                _dataBuffers[i] = vbo;
                var mapper = _mappers[i];
                mapper.Vao = vao;
                mapper.Vbo = vbo;
            }
        }
Example #2
0
        public WorldGui(World world)
        {
            _world            = world;
            _2dElements       = new Dictionary <string, Gui2dElement>();
            _2dElementsShader = ShaderManager.GetOrCreateShader("2d_elements",
                                                                Shaders.gui_2d_element_vertex, Shaders.gui_2d_element_fragment);
            _2dElementsShader.Use();
            _2dElementsShader.SetUInt("sampler", 0);
            _2dElementsVertexArrayObject = new VertexArrayObject(WorldGuiStaticElements.Vertices,
                                                                 WorldGuiStaticElements.Indices);

            _blockElements       = new Dictionary <string, GuiBlockElement>();
            _blockElementsShader =
                ShaderManager.GetOrCreateShader("block_elements", Shaders.gui_block_element_vertex,
                                                Shaders.gui_block_element_fragment);
            _blockElementVertexArrayObject = BlockFaceVertices.CreateCubeVao();
        }