public override void Load(ProgramWindow parent) { this.parent = parent; GL.Disable(EnableCap.Dither); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.DepthTest); GL.ClearColor(System.Drawing.Color.Black); var vs = parent.CreateShader(ShaderType.VertexShader, VERTEXSHADER); var fs = parent.CreateShader(ShaderType.FragmentShader, FRAGMENTSHADER); program = parent.CreateProgram(vs, fs); GL.DeleteShader(vs); GL.DeleteShader(fs); this.bitmap = this.bitmap ?? new System.Drawing.Bitmap(parent.Width, parent.Height); texture = parent.LoadTexture(this.bitmap, unit); CreateVBO(); }
public override void Load(ProgramWindow parent) { parent.MakeCurrent(); base.Load(parent); GL.Disable(EnableCap.Dither); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.DstAlpha); GL.ClearColor(System.Drawing.Color.FromArgb(0,0,0,0)); var vs = parent.CreateShader(ShaderType.VertexShader, VSLighting); var fs = parent.CreateShader(ShaderType.FragmentShader, FSLighting); program = parent.CreateProgram(vs, fs); GL.DeleteShader(vs); GL.DeleteShader(fs); dynamicProgram.Load(); textures = new MultipleTextures(this); Bitmap white = new Bitmap(101, 101); QuickDraw.Start(white) .Fill(Color.White).Finish(); Bitmap gridBot = new Bitmap(101, 101); QuickDraw.Start(gridBot) .All((x, y) => { var lpp = 10; var xm = x % lpp; var ym = y % lpp; if (xm == 0 || ym == 0) return Color.Gray; return Color.FromArgb(150, 50, 50, 50); }, false).Finish(); Bitmap[] maps = new Bitmap[] { white, gridBot }; textures.Load(maps); if (lightStudio != null) lights = lightStudio.Lights; else lights = new MoveableLights(8); dynamicRenderer = new Renderer(dynamics = (Dynamight.ImageProcessing.CameraCalibration.Range.OfInts(6)).Select(_ => new DynamicRenderable()).ToArray()); staticRenderer = new Renderer(null, (new Renderable[] { Grid = new Renderable() { Visible = false, Shape = new Quad(new Vector3(0,0,0), 10, new Vector3(1,0,0), new Vector3(0,0,1), (v) => textures.Transform(v, 1)), Animatable = new Translator() }, }).Concat(LightsObjects = lights.Select(l => new LightRenderable(l, (v) => textures.Transform(v, 0))).ToArray()).ToArray()); windowSize = parent.Size; SetupCamera(); staticRenderer.Load(); dynamicRenderer.Load(); staticRenderer.Start(); dynamicRenderer.Start(); keyl = new KeyboardListener(parent.Keyboard); keyl.AddAction(() => Selection = (Selection == null ? (int?)1 : null), Key.C); keyl.AddAction(() => Grid.Visible = !Grid.Visible, Key.G); keyl.AddBinaryAction(0.01f, -0.01f, Key.Right, Key.Left, null, (f) => MoveX(f)); keyl.AddBinaryAction(0.01f, -0.01f, Key.Down, Key.Up, null, (f) => MoveY(f)); keyl.AddBinaryAction(0.01f, -0.01f, Key.Down, Key.Up, new Key[] { Key.ShiftLeft }, (f) => MoveZ(f)); keyl.AddBinaryAction(0.05f, -0.05f, Key.Right, Key.Left, new Key[] { Key.ControlLeft }, (f) => MoveX(f)); keyl.AddBinaryAction(0.05f, -0.05f, Key.Down, Key.Up, new Key[] { Key.ControlLeft }, (f) => MoveY(f)); keyl.AddBinaryAction(0.05f, -0.05f, Key.Down, Key.Up, new Key[] { Key.ShiftLeft, Key.ControlLeft }, (f) => MoveZ(f)); GL.Enable(EnableCap.Lighting); GL.Enable(EnableCap.Light0); GL.Enable(EnableCap.Light1); GL.Enable(EnableCap.Light2); GL.Enable(EnableCap.Light3); GL.Enable(EnableCap.Light4); GL.Enable(EnableCap.Light5); GL.Enable(EnableCap.Light6); GL.Enable(EnableCap.Light7); }
public override void Load(ProgramWindow parent) { this.parent = parent; GL.Disable(EnableCap.Dither); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.DepthTest); GL.ClearColor(System.Drawing.Color.Black); var vs = parent.CreateShader(ShaderType.VertexShader, GetVertexShader()); var fs = parent.CreateShader(ShaderType.FragmentShader, GetFragmentShader()); var gss = GetGeometryShader(); int? gs = null; if (gss != null) gs = parent.CreateShader(ShaderType.GeometryShader, gss); program = parent.CreateProgram(vs, fs, gs); GL.DeleteShader(vs); GL.DeleteShader(fs); base.Load(parent); }