Пример #1
0
        private void DrawInitVertices()
        {
            //Console.WriteLine(WGL.wglGetCurrentContext());
            _verticesPositionBuffer  = GLBuffer.Create();
            _verticesNormalBuffer    = GLBuffer.Create();
            _verticesTexcoordsBuffer = GLBuffer.Create();
            _verticesColorsBuffer    = GLBuffer.Create();
            _verticesWeightsBuffer   = GLBuffer.Create();
            _shader = new GLShader(
                typeof(OpenglGpuImpl).Assembly.GetManifestResourceStream("CSPspEmu.Core.Gpu.Impl.Opengl.shader.vert")
                .ReadAllContentsAsString(),
                typeof(OpenglGpuImpl).Assembly.GetManifestResourceStream("CSPspEmu.Core.Gpu.Impl.Opengl.shader.frag")
                .ReadAllContentsAsString()
                );
            Console.WriteLine("###################################");
            foreach (var uniform in _shader.Uniforms)
            {
                Console.WriteLine(uniform);
            }
            foreach (var attribute in _shader.Attributes)
            {
                Console.WriteLine(attribute);
            }
            Console.WriteLine("###################################");

            _shader.BindUniformsAndAttributes(ShaderInfo);
        }
        private void Initialize()
        {
            Smaa = new Smaa();

            var prefix = @"
				#ifndef GL_ES
				#version 330
				#endif
			"            ;

            Shader = new GLShader(
                prefix +
                "attribute vec4 position; attribute vec4 texCoords; varying vec2 v_texCoord; void main() { gl_Position = position; v_texCoord = texCoords.xy; }",
                prefix +
                "uniform sampler2D texture; varying vec2 v_texCoord; void main() { gl_FragColor = texture2D(texture, v_texCoord); }"
                );

            VertexBuffer = GLBuffer.Create()
                           .SetData(CSharpPlatform.RectangleF.FromCoords(-1, -1, +1, +1).GetFloat2TriangleStripCoords());

            Shader.BindUniformsAndAttributes(ShaderInfo);

            // TestTexture = GLTexture.Create().SetFormat(TextureFormat.RGBA).SetSize(2, 2).SetData(new uint[] { 0xFF0000FF, 0xFF00FFFF, 0xFFFF00FF, 0xFFFFFFFF });
        }