コード例 #1
0
        public RenderTextureCubeCommand(Vector3 min, Vector3 max, Texture t, float alpha = 1.0f)
            : base()
        {
            myVerts = new V3T2B4[24];
            V3T2[] verts = new V3T2[24];
            UInt32 col   = new Color4(1.0f, 1.0f, 1.0f, alpha).toUInt();

            //front face
            myVerts[0].Position = new Vector3(max.X, min.Y, min.Z); myVerts[0].TexCoord = new Vector2(0, 0);        myVerts[0].Color = col;
            myVerts[1].Position = new Vector3(min.X, min.Y, min.Z); myVerts[1].TexCoord = new Vector2(1, 0);        myVerts[1].Color = col;
            myVerts[2].Position = new Vector3(min.X, max.Y, min.Z); myVerts[2].TexCoord = new Vector2(1, 1);        myVerts[2].Color = col;
            myVerts[3].Position = new Vector3(max.X, max.Y, min.Z); myVerts[3].TexCoord = new Vector2(0, 1);        myVerts[3].Color = col;

            //left
            myVerts[4].Position = new Vector3(min.X, min.Y, min.Z); myVerts[4].TexCoord = new Vector2(0, 0);        myVerts[4].Color = col;
            myVerts[5].Position = new Vector3(min.X, min.Y, max.Z); myVerts[5].TexCoord = new Vector2(1, 0);        myVerts[5].Color = col;
            myVerts[6].Position = new Vector3(min.X, max.Y, max.Z); myVerts[6].TexCoord = new Vector2(1, 1);        myVerts[6].Color = col;
            myVerts[7].Position = new Vector3(min.X, max.Y, min.Z); myVerts[7].TexCoord = new Vector2(0, 1);        myVerts[7].Color = col;

            //right
            myVerts[8].Position  = new Vector3(max.X, min.Y, max.Z);  myVerts[8].TexCoord = new Vector2(0, 0);  myVerts[8].Color = col;
            myVerts[9].Position  = new Vector3(max.X, min.Y, min.Z);  myVerts[9].TexCoord = new Vector2(1, 0);  myVerts[9].Color = col;
            myVerts[10].Position = new Vector3(max.X, max.Y, min.Z);  myVerts[10].TexCoord = new Vector2(1, 1); myVerts[10].Color = col;
            myVerts[11].Position = new Vector3(max.X, max.Y, max.Z);  myVerts[11].TexCoord = new Vector2(0, 1); myVerts[11].Color = col;

            //top
            myVerts[12].Position = new Vector3(min.X, max.Y, max.Z);  myVerts[12].TexCoord = new Vector2(0, 0); myVerts[12].Color = col;
            myVerts[13].Position = new Vector3(max.X, max.Y, max.Z);  myVerts[13].TexCoord = new Vector2(1, 0); myVerts[13].Color = col;
            myVerts[14].Position = new Vector3(max.X, max.Y, min.Z);  myVerts[14].TexCoord = new Vector2(1, 1); myVerts[14].Color = col;
            myVerts[15].Position = new Vector3(min.X, max.Y, min.Z);  myVerts[15].TexCoord = new Vector2(0, 1); myVerts[15].Color = col;

            //bottom
            myVerts[16].Position = new Vector3(min.X, min.Y, min.Z);  myVerts[16].TexCoord = new Vector2(0, 0); myVerts[16].Color = col;
            myVerts[17].Position = new Vector3(max.X, min.Y, min.Z);  myVerts[17].TexCoord = new Vector2(1, 0); myVerts[17].Color = col;
            myVerts[18].Position = new Vector3(max.X, min.Y, max.Z);  myVerts[18].TexCoord = new Vector2(1, 1); myVerts[18].Color = col;
            myVerts[19].Position = new Vector3(min.X, min.Y, max.Z);  myVerts[19].TexCoord = new Vector2(0, 1); myVerts[19].Color = col;

            //back
            myVerts[20].Position = new Vector3(min.X, min.Y, max.Z);  myVerts[20].TexCoord = new Vector2(0, 0); myVerts[20].Color = col;
            myVerts[21].Position = new Vector3(max.X, min.Y, max.Z);  myVerts[21].TexCoord = new Vector2(1, 0); myVerts[21].Color = col;
            myVerts[22].Position = new Vector3(max.X, max.Y, max.Z);  myVerts[22].TexCoord = new Vector2(1, 1); myVerts[22].Color = col;
            myVerts[23].Position = new Vector3(min.X, max.Y, max.Z);  myVerts[23].TexCoord = new Vector2(0, 1); myVerts[23].Color = col;

            renderState.setTexture(t.id(), 0, t.target);
            renderState.setIndexBuffer(theIBO.id);
            renderState.setVertexBuffer(theVBO.id, 0, 0, V3T2B4.stride);
            renderState.setUniform(new UniformData(0, Uniform.UniformType.Bool, true));
            renderState.setUniform(new UniformData(20, Uniform.UniformType.Int, 0));
            renderState.setUniform(new UniformData(23, Uniform.UniformType.Int, 0));
            renderState.setUniform(new UniformData(25, Uniform.UniformType.Bool, false));

            pipelineState = new PipelineState();
            pipelineState.shaderState.shaderProgram = theShader;
            pipelineState.vaoState.vao      = theVAO;
            pipelineState.depthTest.enabled = false;
            pipelineState.blending.enabled  = t.hasAlpha || alpha < 1.0f;
            pipelineState.generateId();
        }
コード例 #2
0
        public TextureFont(String name, Texture t, int charTextureSize, int size, int offset = 0)
            : base(name, size)
        {
            myCharTextureSize = charTextureSize;
            myLetteroffset    = offset;
            texture           = t;
            buildFont();

            //set shader
            List <ShaderDescriptor> desc = new List <ShaderDescriptor>();

            desc.Add(new ShaderDescriptor(ShaderType.VertexShader, "..\\src\\Graphics\\shaders\\font-vs.glsl", ShaderDescriptor.Source.File));
            desc.Add(new ShaderDescriptor(ShaderType.FragmentShader, "..\\src\\Graphics\\shaders\\font-ps.glsl", ShaderDescriptor.Source.File));
            ShaderProgramDescriptor shDesc = new ShaderProgramDescriptor(desc);

            myShader = Renderer.resourceManager.getResource(shDesc) as ShaderProgram;
            myVao.bindVertexFormat(myShader, V3T2.bindings());
        }
コード例 #3
0
        public TTFFont(String name, String filename, int size)
            : base(name, size)
        {
            for (int i = 0; i < 128; i++)
            {
                myGlyphs.Add(new Glyph());
            }

            myFilename = filename;
            buildFont();

            //set shader
            List <ShaderDescriptor> desc = new List <ShaderDescriptor>();

            desc.Add(new ShaderDescriptor(ShaderType.VertexShader, "..\\src\\Graphics\\shaders\\font-vs.glsl", ShaderDescriptor.Source.File));
            desc.Add(new ShaderDescriptor(ShaderType.FragmentShader, "..\\src\\Graphics\\shaders\\font-ps.glsl", ShaderDescriptor.Source.File));
            ShaderProgramDescriptor shDesc = new ShaderProgramDescriptor(desc);

            myShader = Renderer.resourceManager.getResource(shDesc) as ShaderProgram;
            myVao.bindVertexFormat(myShader, V3T2.bindings());
        }