public static ShaderProgram GetPickingShaderProgram() { var vertexShaderSource = GetShaderSource(ShaderTypes.VertexShader); string fragmentShaderSource = GetShaderSource(ShaderTypes.FragmentShader); var shaderProgram = new ShaderProgram(); shaderProgram.Create(vertexShaderSource, fragmentShaderSource, null); shaderProgram.AssertValid(); return shaderProgram; }
//static readonly object synObj = new object(); public static ShaderProgram GetPickingShaderProgram() { var vertexShaderSource = ManifestResourceLoader.LoadTextFile(@"ColorCodedPicking.PickingShader.vert"); string fragmentShaderSource = ManifestResourceLoader.LoadTextFile(@"ColorCodedPicking.PickingShader.frag"); var shaderProgram = new ShaderProgram(); shaderProgram.Create(vertexShaderSource, fragmentShaderSource, null); shaderProgram.AssertValid(); return shaderProgram; }
protected ShaderProgram InitializeShader() { var vertexShaderSource = ManifestResourceLoader.LoadTextFile(@"DemoMapBuffer.vert"); var fragmentShaderSource = ManifestResourceLoader.LoadTextFile(@"DemoMapBuffer.frag"); var shaderProgram = new ShaderProgram(); shaderProgram.Create(vertexShaderSource, fragmentShaderSource, null); shaderProgram.AssertValid(); return shaderProgram; }
protected override void DoInitialize() { // Now create a simple program to visualize the result basicShaderProgram = new ShaderProgram(); basicShaderProgram.Create(basicVertexShader, basicFragmentShader, null); basicShaderProgram.AssertValid(); base_model_matrix_pos = GL.GetUniformLocation(basicShaderProgram.ShaderProgramObject, "model_matrix"); base_projection_matrix_pos = GL.GetUniformLocation(basicShaderProgram.ShaderProgramObject, "projection_matrix"); fur_prog = GL.CreateProgram(); ShaderHelper.vglAttachShaderSource(fur_prog, ShaderType.VertexShader, furVertexShader); ShaderHelper.vglAttachShaderSource(fur_prog, ShaderType.GeometryShader, furGeometryShader); ShaderHelper.vglAttachShaderSource(fur_prog, ShaderType.FragmentShader, furFragmentShader); GL.LinkProgram(fur_prog); GL.UseProgram(fur_prog); fur_model_matrix_pos = GL.GetUniformLocation(fur_prog, "model_matrix"); fur_projection_matrix_pos = GL.GetUniformLocation(fur_prog, "projection_matrix"); GL.GenTextures(1, fur_texture); UnmanagedArray<byte> tex = new UnmanagedArray<byte>(1024 * 1024 * 4); Random random = new Random(); for (int n = 0; n < 256; n++) { for (int m = 0; m < 1270; m++) { int x = random.Next() & 0x3FF; int y = random.Next() & 0x3FF; tex[(y * 1024 + x) * 4 + 0] = (byte)((random.Next() & 0x3F) + 0xC0); tex[(y * 1024 + x) * 4 + 1] = (byte)((random.Next() & 0x3F) + 0xC0); tex[(y * 1024 + x) * 4 + 2] = (byte)((random.Next() & 0x3F) + 0xC0); tex[(y * 1024 + x) * 4 + 3] = (byte)(n); //tex[(y * 1024 + x) * 4 + 0] = (byte)(random.Next()); //tex[(y * 1024 + x) * 4 + 1] = (byte)(random.Next()); //tex[(y * 1024 + x) * 4 + 2] = (byte)(random.Next()); //tex[(y * 1024 + x) * 4 + 3] = (byte)(random.Next()); } } GL.BindTexture(GL.GL_TEXTURE_2D, fur_texture[0]); GL.TexImage2D(TexImage2DTargets.Texture2D, 0, TexImage2DFormats.RGBA, 1024, 1024, 0, TexImage2DFormats.RGBA, TexImage2DTypes.UnsignedByte, tex.Header); GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, (int)GL.GL_LINEAR); GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, (int)GL.GL_LINEAR); tex.Dispose(); vboObject.LoadFromVBM(@"media\ninja.vbm", 0, 1, 2); base.BeforeRendering += LightingExample_BeforeRendering; base.AfterRendering += LightingExample_AfterRendering; }
private void InitShaderProgram() { var vertexShaderSource = ManifestResourceLoader.LoadTextFile(@"SceneElements.FontElement.vert"); var fragmentShaderSource = ManifestResourceLoader.LoadTextFile(@"SceneElements.FontElement.frag"); var shaderProgram = new ShaderProgram(); shaderProgram.Create(vertexShaderSource, fragmentShaderSource, null); shaderProgram.AssertValid(); this.shaderProgram = shaderProgram; }
protected override void DoInitialize() { // Now create a simple program to visualize the result shaderProgram = new ShaderProgram(); shaderProgram.Create(render_vs, render_fs, null); shaderProgram.AssertValid(); //mv_mat_loc = GL.GetUniformLocation(shaderProgram.ShaderProgramObject, "model_matrix"); //prj_mat_loc = GL.GetUniformLocation(shaderProgram.ShaderProgramObject, "proj_matrix"); //col_amb_loc = GL.GetUniformLocation(shaderProgram.ShaderProgramObject, "color_ambient"); //col_diff_loc = GL.GetUniformLocation(shaderProgram.ShaderProgramObject, "color_diffuse"); //col_spec_loc = GL.GetUniformLocation(shaderProgram.ShaderProgramObject, "color_specular"); vboObject.LoadFromVBM(@"media\unit_torus.vbm", 0, 1, 2); base.BeforeRendering += LightingExample_BeforeRendering; base.AfterRendering += LightingExample_AfterRendering; }
protected void InitializeShader(out ShaderProgram shaderProgram) { var vertexShaderSource = ManifestResourceLoader.LoadTextFile(@"SceneElements.CylinderElement.vert"); var fragmentShaderSource = ManifestResourceLoader.LoadTextFile(@"SceneElements.CylinderElement.frag"); shaderProgram = new ShaderProgram(); shaderProgram.Create(vertexShaderSource, fragmentShaderSource, null); shaderProgram.AssertValid(); }
private void InitShaderProgram() { // Create the shader program. var vertexShaderSource = ManifestResourceLoader.LoadTextFile(@"SceneElements.PointSpriteStringElement.vert"); var fragmentShaderSource = ManifestResourceLoader.LoadTextFile(@"SceneElements.PointSpriteStringElement.frag"); var shaderProgram = new ShaderProgram(); shaderProgram.Create(vertexShaderSource, fragmentShaderSource, null); this.attributeIndexPosition = shaderProgram.GetAttributeLocation("in_Position"); shaderProgram.AssertValid(); this.shaderProgram = shaderProgram; }
private void InitProgram() { { var vertexShaderSource = ManifestResourceLoader.LoadTextFile(@"TransformFeedback.transform.vert"); transformProgram = new TransformShaderProgram(); transformProgram.Create(vertexShaderSource); transformProgram.AssertValid(); } { var vertexShaderSource = ManifestResourceLoader.LoadTextFile(@"TransformFeedback.feedback.vert"); var fragmentShaderSource = ManifestResourceLoader.LoadTextFile(@"TransformFeedback.feedback.frag"); feedbackProgram = new ShaderProgram(); feedbackProgram.Create(vertexShaderSource, fragmentShaderSource, null); feedbackProgram.AssertValid(); } { var index = GL.GetUniformBlockIndex(transformProgram.ShaderProgramObject, "transform"); GL.UniformBlockBinding(transformProgram.ShaderProgramObject, index, (uint)UniformType.TRANSFORM0); } }
protected ShaderProgram InitializeShader() { var vertexShaderSource = ManifestResourceLoader.LoadTextFile(@"UIs.SimpleUIColorIndicatorBar.vert"); var fragmentShaderSource = ManifestResourceLoader.LoadTextFile(@"UIs.SimpleUIColorIndicatorBar.frag"); shaderProgram = new ShaderProgram(); shaderProgram.Create(vertexShaderSource, fragmentShaderSource, null); in_PositionLocation = shaderProgram.GetAttributeLocation(strin_Position); in_ColorLocation = shaderProgram.GetAttributeLocation(strin_Color); shaderProgram.AssertValid(); return shaderProgram; }
protected void InitializeShader(out ShaderProgram shaderProgram) { var vertexShaderSource = ManifestResourceLoader.LoadTextFile(@"DemoSimplePointSpriteElement.vert"); string fragmentShaderSource = string.Empty; switch (this.fragShaderType) { case FragShaderType.Simple: fragmentShaderSource = ManifestResourceLoader.LoadTextFile( @"DemoSimplePointSpriteElement_Simple.frag"); break; case FragShaderType.Analytic: fragmentShaderSource = ManifestResourceLoader.LoadTextFile( @"DemoSimplePointSpriteElement_Analytic.frag"); break; default: throw new NotImplementedException(); } shaderProgram = new ShaderProgram(); shaderProgram.Create(vertexShaderSource, fragmentShaderSource, null); shaderProgram.AssertValid(); }
protected void InitializeShader(out ShaderProgram shaderProgram) { var vertexShaderSource = ManifestResourceLoader.LoadTextFile(@"DemoTexImage2D.vert"); var fragmentShaderSource = ManifestResourceLoader.LoadTextFile(@"DemoTexImage2D.frag"); shaderProgram = new ShaderProgram(); shaderProgram.Create(vertexShaderSource, fragmentShaderSource, null); shaderProgram.AssertValid(); }