public override void Initialize(size videosize, long timebase) { base.Initialize(videosize, timebase); using (var lck = this.Display.Renderer.GetDrawLock()) { this.vertices = new vertices <vertex>( new vertex[] { new vertex(new Vector3(0, -1, 0)), new vertex(new Vector3(-1, 1, 0)), new vertex(new Vector3(1, 1, 0)) }); vertices.define("position", "pos"); this.shader = new shader( @"#version 150 core in vec4 position; void main() { gl_Position = position; }", @"#version 150 core precision mediump float; out vec4 outColor; void main() { outColor = vec4(1,0,0,1); } ", this.vertices); } }
protected override void Dispose(bool disposing) { using (var lck = this.Display.Renderer.GetDrawLock()) { this.shader?.Dispose(); this.shader = null; this.vertices?.Dispose(); this.vertices = null; } base.Dispose(disposing); }
private static shader LoadShaderTextures(Effect effect) { try { effect.SetTexture("lastpass", lastPass); } catch { } //throws an exception if this parameter doesn't exist :( try { effect.SetTexture("lastshader", lastShader); } catch { } try { effect.SetTexture("depthframe", depthFrame); } catch { } try { effect.SetValue("rcpres", new Vector4(1f / frameWidth, 1f / frameHeight, 0, 1)); } catch { } try { effect.SetValue("fov", 85f); } catch { } try { effect.SetValue("fogstart", 819.2f); } catch { } try { effect.SetValue("fogrange", 65536.0f); } catch { } try { effect.SetValue("waterlevel", 0f); } catch { } try { effect.SetValue("HDR", new Vector4(0.25f, 0.25f, 0.25f, 02.5f)); } catch { } try { effect.SetValue("eyepos", new Vector3(0f, 0f, 128f)); } catch { } try { effect.SetValue("eyevec", new Vector3(1f, 0f, 0f)); } catch { } int count = 1; while (true) { string texpath; try { texpath = effect.GetString("texname" + count.ToString()); } catch { break; } if (texpath != null) { try { Texture tex = Texture.FromFile(DXMain.device, Statics.runDir + "\\data files\\textures\\" + texpath); effect.SetTexture("tex" + count.ToString(), tex); } catch { } } else { break; } count++; } shader s = new shader(); try { s.ehTime = effect.GetParameter(null, "time"); } catch { s.ehTime = null; } try { s.ehHDR = effect.GetParameter(null, "HDR"); } catch { s.ehHDR = null; } s.effect = effect; return(s); }
static void Main(string[] args) { try { window = new Window("Text", 800, 600, false); //float[] vert = new float[]{ // -0.5f,-0.5f,0.0f, // -0.5f, 0.5f,0.0f, // 0.5f, 0.5f,0.0f, // 0.5f, 0.5f,0.0f, // 0.5f,-0.5f,0.0f, // -0.5f,-0.5f,0.0f, //}; float[] vert = new float[] { 0, 0, 0, 8, 0, 0, 0, 3, 0, 0, 3, 0, 8, 3, 0, 8, 0, 0, }; UInt32[] vbo = new UInt32[2]; gl.GenBuffers(1, vbo); gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, vbo[0]); gl.BufferData(OpenGL.GL_ARRAY_BUFFER, vert, OpenGL.GL_STATIC_DRAW); gl.VertexAttribPointer(0, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero); gl.EnableVertexAttribArray(0); shader s = new shader("minimal.vert", "minimal.frag"); s.enable(); s.SetUniformMatrix("pr_matrix", Matrix.CreateOrthographic(0.0, 16.0, -1.0, 1.0)); s.SetUniformMatrix("ml_matrix", Matrix.CreateTranslation(new Vector3(2, 2, 0))); s.SetUniform("light_pos", new Vector2(4, 1.5f)); s.SetUniform("colour", new Vector4(0f, 0.0f, 1f, 1.0f)); } catch (Exception e) { Console.WriteLine(e.ToString()); } window.SetUpdate(EventUpdate, update); }
void IDockNotify.OnLoaded(IDockPane pane) { Debug.Assert(this.Renderer == null); this.Renderer = factory.Open(xwtrender, this, this, new FPS(1, 25, true), new size(1920, 1080)); using (var lck = this.Renderer.GetDrawLock()) { /* List<Vector3> simpleVertices = new List<Vector3>(); * simpleVertices.Add(new Vector3(0, 0, 0)); * simpleVertices.Add(new Vector3(100, 0, 0)); * simpleVertices.Add(new Vector3(100, 100, 0));*/ this.vertices = new vertices <vertex>( new vertex[] { new vertex(new Vector3(0, -1, 0)), new vertex(new Vector3(-1, 1, 0)), new vertex(new Vector3(1, 1, 0)) }); this.shader = new shader( @"#version 150 core in vec4 position; void main() { gl_Position = position; }", @"#version 150 core precision mediump float; out vec4 outColor; void main() { outColor = vec4(1,0,0,1); } ", this.vertices); vertices.define("position", "pos"); } this.Renderer.Start(); }
internal void OnLoaded() { this.Renderer = this.RenderFactory.Open(this.XwtRender, this, this, new size(1920, 1080)); using (var lck = this.Renderer.GetDrawLock()) { /* List<Vector3> simpleVertices = new List<Vector3>(); * simpleVertices.Add(new Vector3(0, 0, 0)); * simpleVertices.Add(new Vector3(100, 0, 0)); * simpleVertices.Add(new Vector3(100, 100, 0));*/ this.vertices = new vertices <vertex>( new vertex[] { new vertex(new Vector3(0, -1, 0)), new vertex(new Vector3(-1, 1, 0)), new vertex(new Vector3(1, 1, 0)) }); this.shader = new shader( @"#version 150 core in vec4 position; void main() { gl_Position = position; }", @"#version 150 core precision mediump float; out vec4 outColor; void main() { outColor = vec4(0,1,0,1); } ", this.vertices); vertices.define("position", "pos"); } this.Renderer.Start(); }
public void OnLoaded(bool renderlocked) { try { if (!renderlocked) { #if (!TRIANGLE) try { if (BaseLib.Xwt.Platform.OSPlatform == PlatformID.MacOSX) { this.MoviePlayer = new Player(this.owner, @"/Volumes/Projects/movies/Yamaha_final.avi", this.impl.Timebase); } else if (BaseLib.Xwt.Platform.OSPlatform == PlatformID.Unix) { this.MoviePlayer = new Player(this.owner, @"/home/bert/Projects/movies/Yamaha_final.avi", this.impl.Timebase); } else { this.MoviePlayer = new Player(this.owner, @"e:\movies\Yamaha_final.avi", this.impl.Timebase); } } catch { } #endif } else { #if TRIANGLE List <Vector3> simpleVertices = new List <Vector3>(); simpleVertices.Add(new Vector3(0, 0, 0)); simpleVertices.Add(new Vector3(100, 0, 0)); simpleVertices.Add(new Vector3(100, 100, 0)); this.vertices = new vertices <vertex>(new vertex[] { new vertex(0, -1), new vertex(-1, 1), new vertex(1, 1) }); vertices.define("position", "pos"); this.shader = new shader( @"#version 150 core in vec4 position; void main() { gl_Position = position; }", @"#version 150 core precision mediump float; out vec4 outColor; void main() { outColor = vec4(1,0,0,1); } ", this.vertices); #else this.vertices = new vertices <vertex_tex>( new vertex_tex[] { new vertex_tex(-1, -1, 0, 0), new vertex_tex(1, -1, 1, 0), new vertex_tex(-1, 1, 0, 1), new vertex_tex(1, -1, 1, 0), new vertex_tex(-1, 1, 0, 1), new vertex_tex(1, 1, 1, 1) }); this.shader = new shader( @"#version 150 core in vec3 position; in vec2 texcoord0; out vec2 Texcoord0; void main() { gl_Position = vec4(position,1);//*vec4(1,-1,1,1); Texcoord0 = texcoord0; }", @"#version 150 core precision mediump float; in vec2 Texcoord0; uniform sampler2D texure0; out vec4 outColor; void main() { outColor = texture(texure0, Texcoord0); } ", this.vertices); vertices.define("position", "pos"); vertices.define("texcoord0", "tex0"); GL.UseProgram(this.shader); var pos = GL.GetUniformLocation(this.shader, "texture0"); if (pos != -1) { GL.Uniform1(pos, 0); } #endif } } catch (Exception e) { } }
internal void OnLoaded() { try { this.Renderer = this.RenderFactory.Open(this.XwtRender, this, this, new FPS(1, 25, true), new size(1920, 1080)); this.Audio = new AudioOut(48000, AudioFormat.Float32, ChannelsLayout.Stereo, 2); this.Mixer = new Mixer(this.Audio.SampleRate, this.Audio.Format, this.Audio.ChannelLayout); try { if (BaseLib.Xwt.Platform.OSPlatform == PlatformID.MacOSX) { this.MoviePlayer = new Player(this.owner, @"/Volumes/Projects/movies/Yamaha_final.avi", TimeBase); } else if (BaseLib.Xwt.Platform.OSPlatform == PlatformID.Unix) { this.MoviePlayer = new Player(this.owner, @"/home/bert/Projects/movies/Yamaha_final.avi", TimeBase); } else { this.MoviePlayer = new Player(this.owner, @"e:\movies\Yamaha_final.avi", TimeBase); } } catch { } using (var lck = this.Renderer.GetDrawLock()) { /* List<Vector3> simpleVertices = new List<Vector3>(); * simpleVertices.Add(new Vector3(0, 0, 0)); * simpleVertices.Add(new Vector3(100, 0, 0)); * simpleVertices.Add(new Vector3(100, 100, 0));*/ this.vertices = new vertices <vertex>( new vertex[] { new vertex(new Vector3(0, -1, 0)), new vertex(new Vector3(-1, 1, 0)), new vertex(new Vector3(1, 1, 0)) }); vertices.define("position", "pos"); this.shader = new shader( @"#version 150 core in vec4 position; void main() { gl_Position = position; }", @"#version 150 core precision mediump float; out vec4 outColor; void main() { outColor = vec4(1,0,0,1); } ", this.vertices); this.verticestex = new vertices <vertex_tex>( new vertex_tex[] { new vertex_tex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new vertex_tex(new Vector3(1, -1, 0), new Vector2(1, 0)), new vertex_tex(new Vector3(-1, 1, 0), new Vector2(0, 1)), new vertex_tex(new Vector3(1, -1, 0), new Vector2(1, 0)), new vertex_tex(new Vector3(-1, 1, 0), new Vector2(0, 1)), new vertex_tex(new Vector3(1, 1, 0), new Vector2(1, 1)), }); this.shadertex = new shader( @"#version 150 core in vec4 position; in vec2 texcoord0; out vec2 Texcoord0; void main() { gl_Position = position*vec4(1,-1,1,1); Texcoord0 = texcoord0; }", @"#version 150 core precision mediump float; in vec2 Texcoord0; uniform sampler2D texure0; out vec4 outColor; void main() { outColor = texture(texure0, Texcoord0); } ", this.verticestex); verticestex.define("position", "pos"); verticestex.define("texcoord0", "tex0"); GL.UseProgram(this.shadertex); var pos = GL.GetUniformLocation(this.shadertex, "texture0"); GL.Uniform1(pos, 0); } //this.Display.WaitBuffered(); // this.Audio?.Buffered.WaitOne(-1, false); this.audiostop.Reset(); this.audiothread = new Thread(() => { while (!audiostop.WaitOne(0, false)) { try { var data = this.Mixer.Read(0, 48000 / 25); Audio.Write(data, data.Length / 8); } catch { } } }); this.audiothread.Start(); this.Audio.Buffered.WaitOne(-1, false); this.Audio?.Start(); this.Renderer.Start(); //this.movie.p } catch (Exception e) { throw; } }
private static shader LoadShaderTextures(Effect effect) { try { effect.SetValue("thisframe", thisFrame); } catch { } //throws an exception if this parameter doesn't exist :( try { effect.SetValue("lastpass", lastPass); } catch { } try { effect.SetValue("lastshader", lastShader); } catch { } try { effect.SetValue("depthframe", depthFrame); } catch { } try { effect.SetValue("rcpres", new Vector4(1.0f/1024.0f, 1.0f/1024.0f, 0, 1)); } catch { } try { effect.SetValue("HDR", new Vector4(0.5f, 0.5f, 0.5f, 0.5f)); } catch { } //**/try { effect.SetValue("lastframe", lastFrame); } catch { } int count=1; while(true) { string texpath; try { texpath=effect.GetValueString("texname"+count.ToString()); } catch { break; } if(texpath!=null) { try { Texture tex=TextureLoader.FromFile(DXMain.device, Statics.runDir + "\\data files\\textures\\"+texpath); effect.SetValue("tex"+count.ToString(), tex); } catch { } } else break; count++; } shader s = new shader(); try { s.ehTime = effect.GetParameter(null, "time"); } catch { s.ehTime = null; } try { s.ehHDR = effect.GetParameter(null, "HDR"); } catch { s.ehHDR = null; } //**/try { //**/ s.ehSinVar=effect.GetParameter(null, "sinvar"); //**/} catch { //**/ s.ehSinVar = null; //**/} //**/try { //**/ s.ehLinVar=effect.GetParameter(null, "linvar"); //**/} catch { //**/ s.ehLinVar = null; //**/} //**/try { //**/ s.ehTicks=effect.GetParameter(null, "tickcount"); //**/} catch { //**/ s.ehTicks = null; //**/} s.effect=effect; return s; }
public void setterShader(string vert, string frag) { shader = new shader(vert, frag);//instancio shader shader.Use(); }
public void setShader() { shader = new shader("recursos/shaders/shader.vert", "recursos/shaders/shader.frag"); shader.Use(); }
private static shader LoadShaderTextures(Effect effect) { try { effect.SetTexture("lastpass", lastPass); } catch { } //throws an exception if this parameter doesn't exist :( try { effect.SetTexture("lastshader", lastShader); } catch { } try { effect.SetTexture("depthframe", depthFrame); } catch { } try { effect.SetValue("rcpres", new Vector4(1f/frameWidth, 1f/frameHeight, 0, 1)); } catch { } try { effect.SetValue("fov", 85f); } catch { } try { effect.SetValue("fogstart", 819.2f); } catch { } try { effect.SetValue("fogrange", 65536.0f); } catch { } try { effect.SetValue("waterlevel", 0f); } catch { } try { effect.SetValue("HDR", new Vector4(0.25f, 0.25f, 0.25f, 02.5f)); } catch { } try { effect.SetValue("eyepos", new Vector3(0f, 0f, 128f)); } catch { } try { effect.SetValue("eyevec", new Vector3(1f, 0f, 0f)); } catch { } int count=1; while(true) { string texpath; try { texpath=effect.GetString("texname"+count.ToString()); } catch { break; } if(texpath!=null) { try { Texture tex=Texture.FromFile(DXMain.device, Statics.runDir + "\\data files\\textures\\"+texpath); effect.SetTexture("tex"+count.ToString(), tex); } catch { } } else break; count++; } shader s = new shader(); try { s.ehTime = effect.GetParameter(null, "time"); } catch { s.ehTime = null; } try { s.ehHDR = effect.GetParameter(null, "HDR"); } catch { s.ehHDR = null; } s.effect=effect; return s; }