本文整理汇总了C#中ShaderProgram.Use方法的典型用法代码示例。如果您正苦于以下问题:C# ShaderProgram.Use方法的具体用法?C# ShaderProgram.Use怎么用?C# ShaderProgram.Use使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram.Use方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loadContent
void loadContent()
{
scenes = new List<Scene>();
setProjectionMatrix();
Dictionary<Enums.Textures, Texture> textures = new Dictionary<Enums.Textures, Texture>();
Dictionary<Enums.MeshVBOs, MeshVBOs> meshVBOs = new Dictionary<Enums.MeshVBOs, MeshVBOs>();
Dictionary<Enums.Shaders, ShaderProgram> shaders = new Dictionary<Enums.Shaders, ShaderProgram>();
ShaderProgram defaultShader = new ShaderProgram(File.ReadAllText("content/shaders/defaultShader.vert"), File.ReadAllText("content/shaders/defaultShader.frag"), "defaultShader");
//defaultShader.writeAllInfoLogs();
Console.WriteLine(defaultShader.ProgramInfoLog);
Console.WriteLine(defaultShader.ShaderInfoLog);
defaultShader.Use();
defaultShader.setUniform("lightPos", new Vector3(1,1,1));
defaultShader.setUniform("ambientCoefficient", .1f);
defaultShader.setUniform("lightIntensities", Vector3.One);
ShaderProgram earthShader = new ShaderProgram(File.ReadAllText("content/shaders/earthShader.vert"), File.ReadAllText("content/shaders/earthShader.frag"), "earthShader");
//earthShader.writeAllInfoLogs();
Console.WriteLine(earthShader.ProgramInfoLog);
earthShader.Use();
earthShader.setUniform("lightPos", Vector3.Zero);
earthShader.setUniform("lightIntensities", Vector3.One);
ShaderProgram sunShader = new ShaderProgram(File.ReadAllText("content/shaders/defaultShader.vert"), File.ReadAllText("content/shaders/sunShader.frag"), "sunShader");
Console.WriteLine(sunShader.ProgramInfoLog);
//sunShader.writeAllInfoLogs();
ShaderProgram lineShader = new ShaderProgram(File.ReadAllText("content/shaders/lineShader.vert"), File.ReadAllText("content/shaders/lineShader.frag"), "lineShader");
Console.WriteLine(lineShader.ProgramInfoLog);
//lineShader.writeAllInfoLogs();
shaders.Add(Enums.Shaders.default_, defaultShader);
shaders.Add(Enums.Shaders.earth, earthShader);
shaders.Add(Enums.Shaders.sun, sunShader);
shaders.Add(Enums.Shaders.line, lineShader);
Console.Write("Loaded Shaders...");
PlanetParameters planetParams = PlanetParameters.readFromFile("content/planetInfo.txt");
ObjLoader loader = new ObjLoader();
meshVBOs.Add(Enums.MeshVBOs.planet, loader.loadVBOS("content/models/sphere.obj"));
meshVBOs.Add(Enums.MeshVBOs.saturnRings, loader.loadVBOS("content/models/saturnRings.obj"));
meshVBOs.Add(Enums.MeshVBOs.uranusRings, loader.loadVBOS("content/models/uranusRings.obj"));
Console.Write("Loading Textures...");
textures.Add(Enums.Textures.starsT, new Texture("content/textures/stars.jpg"));
textures.Add(Enums.Textures.sunT, new Texture("content/textures/sun4096g.jpg"));
textures.Add(Enums.Textures.mercury, new Texture("content/textures/mercury4096.jpg"));
textures.Add(Enums.Textures.venusT, new Texture("content/textures/venus4096.jpg"));
textures.Add(Enums.Textures.earthT, new Texture("content/textures/earth4096.jpg"));
textures.Add(Enums.Textures.earth_SpecT, new Texture("content/textures/earth_Spec4096.png"));
textures.Add(Enums.Textures.earth_NightT, new Texture("content/textures/earth_Night4096.jpg"));
textures.Add(Enums.Textures.earth_NormalT, new Texture("content/textures/earth_Normal4096.jpg"));
textures.Add(Enums.Textures.earty_CloudsT, new Texture("content/textures/earth_Clouds4096.jpg"));
textures.Add(Enums.Textures.moonT, new Texture("content/textures/moon4096.jpg"));
textures.Add(Enums.Textures.marsT, new Texture("content/textures/mars4096.jpg"));
textures.Add(Enums.Textures.jupiterT, new Texture("content/textures/jupiter4096.jpg"));
textures.Add(Enums.Textures.saturnT, new Texture("content/textures/saturn2048.jpg"));
textures.Add(Enums.Textures.uranusT, new Texture("content/textures/uranus2048.png"));
textures.Add(Enums.Textures.neptuneT, new Texture("content/textures/neptune1024.png"));
textures.Add(Enums.Textures.plutoT, new Texture("content/textures/pluto1024.jpg"));
textures.Add(Enums.Textures.saturn_RingsT, new Texture("content/textures/saturnRings.png"));
textures.Add(Enums.Textures.uranus_RingsT, new Texture("content/textures/uranusRings.png"));
Console.Write(" done!\n");
solarSystemScene = new SolarSystemScene(planetParams, meshVBOs, textures, shaders, hoursPerSecond, ZAxisLine, this.glPannel);
scenes.Add(solarSystemScene);
//planetSizeScene = new PlanetSizeScene(meshVBOs, textures, shaders);
//scenes.Add(planetSizeScene);
activeScene = scenes[0];
Console.WriteLine("Created Scenes");
}
示例2: TextureInfo
public TextureInfo( ShaderProgram shader, String identifier,
TextureUnit textureUnit = TextureUnit.Texture0)
{
Shader = shader;
Identifier = identifier;
UniformLocation = GL.GetUniformLocation( Shader.Program, Identifier );
TextureUnit = textureUnit;
Shader.Use();
int val = int.Parse( TextureUnit.ToString().Substring( "Texture".Length ) );
GL.Uniform1( UniformLocation, val );
CurrentTexture = null;
}
示例3: Draw
public void Draw(ShaderProgram shaderProg)
{
shaderProg.Use (shader => {
this.ViewportTarget.DrawRaw (shader, Matrix);
});
}