Ejemplo n.º 1
0
    public ShapeRenderer3d(RenderingDevice device)
    {
        _device = device;

        _lineMaterial         = CreateLineMaterial(false).Ref();
        _quadMaterial         = CreateQuadMaterial().Ref();
        _lineOccludedMaterial = CreateLineMaterial(true).Ref();
        _discBufferBinding    = _device.CreateMdfBufferBinding().Ref();
        _lineBinding          = new BufferBinding(_device, _lineMaterial.Resource.VertexShader).Ref();
        _circleBinding        = new BufferBinding(_device, _lineMaterial.Resource.VertexShader).Ref();

        _discVerticesTpl[0].pos  = new Vector4(-1.0f, 0.0f, -1.0f, 1);
        _discVerticesTpl[1].pos  = new Vector4(0.0f, 0.0f, -1.0f, 1);
        _discVerticesTpl[2].pos  = new Vector4(0.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[3].pos  = new Vector4(-1.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[4].pos  = new Vector4(0.0f, 0.0f, -1.0f, 1);
        _discVerticesTpl[5].pos  = new Vector4(1.0f, 0.0f, -1.0f, 1);
        _discVerticesTpl[6].pos  = new Vector4(1.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[7].pos  = new Vector4(0.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[8].pos  = new Vector4(0.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[9].pos  = new Vector4(1.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[10].pos = new Vector4(1.0f, 0.0f, 1.0f, 1);
        _discVerticesTpl[11].pos = new Vector4(0.0f, 0.0f, 1.0f, 1);
        _discVerticesTpl[12].pos = new Vector4(-1.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[13].pos = new Vector4(0.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[14].pos = new Vector4(0.0f, 0.0f, 1.0f, 1);
        _discVerticesTpl[15].pos = new Vector4(-1.0f, 0.0f, 1.0f, 1);

        for (var i = 0; i < _discVerticesTpl.Length; i++)
        {
            _discVerticesTpl[i].normal = new Vector4(0, 1, 0, 0);
        }

        _discVerticesTpl[0].uv  = new Vector2(0, 0);
        _discVerticesTpl[1].uv  = new Vector2(1, 0);
        _discVerticesTpl[2].uv  = new Vector2(1, 1);
        _discVerticesTpl[3].uv  = new Vector2(0, 1);
        _discVerticesTpl[4].uv  = new Vector2(0, 1);
        _discVerticesTpl[5].uv  = new Vector2(0, 0);
        _discVerticesTpl[6].uv  = new Vector2(1, 0);
        _discVerticesTpl[7].uv  = new Vector2(1, 1);
        _discVerticesTpl[8].uv  = new Vector2(1, 1);
        _discVerticesTpl[9].uv  = new Vector2(0, 1);
        _discVerticesTpl[10].uv = new Vector2(0, 0);
        _discVerticesTpl[11].uv = new Vector2(1, 0);
        _discVerticesTpl[12].uv = new Vector2(1, 0);
        _discVerticesTpl[13].uv = new Vector2(1, 1);
        _discVerticesTpl[14].uv = new Vector2(0, 1);
        _discVerticesTpl[15].uv = new Vector2(0, 0);

        _resourceListener = new ResourceLifecycleCallbacks(_device, CreateResources, FreeResources);
    }
Ejemplo n.º 2
0
    public FontRenderer(RenderingDevice device)
    {
        _device   = device;
        _material = CreateMaterial(device).Ref();
        _sampler  = device.CreateSamplerState(new SamplerSpec()
        {
            addressU  = TextureAddress.Clamp,
            addressV  = TextureAddress.Clamp,
            magFilter = TextureFilterType.Linear,
            minFilter = TextureFilterType.Linear
        });
        _callbacks = new ResourceLifecycleCallbacks(device, CreateResources, FreeResources);

        for (var i = 0; i < _fileState.Length; i++)
        {
            _fileState[i] = new GlyphFileState();
        }
    }