File: EffectPass.cs

package info (click to toggle)
monogame 2.5.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,060 kB
  • ctags: 10,325
  • sloc: cs: 65,996; xml: 591; makefile: 22; ansic: 8
file content (81 lines) | stat: -rw-r--r-- 2,551 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenTK.Graphics.ES20;
using OpenTK.Graphics.ES11;
using GL11 = OpenTK.Graphics.ES11.GL;
using GL20 = OpenTK.Graphics.ES20.GL;
using All11 = OpenTK.Graphics.ES11.All;
using All20 = OpenTK.Graphics.ES20.All;

namespace Microsoft.Xna.Framework.Graphics
{
    public class EffectPass
    {
        EffectTechnique _technique = null;
		internal int shaderProgram;

        public void Apply()
        {
			// Tell the GL Context to use the program
			//GL20.UseProgram (shaderProgram);
			
            _technique._effect.Apply();
        }

        public EffectPass(EffectTechnique technique)
        {
            _technique = technique;
        }
		
		internal void ApplyPass ()
		{
			
			// Create a Program object
			shaderProgram = GL20.CreateProgram ();

			// Attach our compiled shaders
			if ( VertexIndex < _technique._effect.vertexShaders.Count)
				GL20.AttachShader (shaderProgram, _technique._effect.vertexShaders[VertexIndex]);
			if ( FragmentIndex < _technique._effect.fragmentShaders.Count)			
				GL20.AttachShader (shaderProgram, _technique._effect.fragmentShaders[FragmentIndex]);

			// Set the parameters
			// TODO GL20.ProgramParameter (shaderProgram, AssemblyProgramParameterArb.GeometryInputType, (int)All.Lines);	
			// TODO GL20.ProgramParameter (shaderProgram, AssemblyProgramParameterArb.GeometryOutputType, (int)All.Line);
			
			// Set the max vertices
			int maxVertices;
			// TODO GL20.GetInteger (GetPName.MaxGeometryOutputVertices, out maxVertices);
			// TODO GL20.ProgramParameter (shaderProgram, AssemblyProgramParameterArb.GeometryVerticesOut, maxVertices);

			// Link the program
			GL20.LinkProgram (shaderProgram);
			string name = String.Format("Technique {0} - Pass {1}: ",_technique.Name, Name);
			ShaderLog(name,shaderProgram);				
			
		}
		
		public string Name { get; set; }	
		
		// internal for now until I figure out what I can do with this mess
		internal int VertexIndex { get; set; }
		internal int FragmentIndex { get; set; }
		
		// Output the log of an object
		private void ShaderLog (string whichObj, int obj)
		{
			int infoLogLen = 0;
			var infoLog = "Is good to go.";

			// TODO GL.GetProgram (obj, ProgramParameter.InfoLogLength, out infoLogLen);

			/* TODO if (infoLogLen > 0)
				infoLog = GL.GetProgramInfoLog (obj); */
#if DEBUG
			Console.WriteLine ("{0} {1}", whichObj, infoLog);
#endif
		}	
    }
}