public void Init(Flat6Window window) { Window = window; Lumberjack.Debug("Creating framebuffers"); FramebufferScene = new Framebuffer(8); FramebufferScene.Init(Window.Width, Window.Height); FramebufferInterface = new Framebuffer(8); FramebufferInterface.Init(Window.Width, Window.Height); CreateScreenVao(); Lumberjack.Debug("Creating shaders"); ShaderDefault = new ShaderProgram(EmbeddedResources.FsDefault, EmbeddedResources.VsDefault); ShaderDefault.Uniforms.SetValue("texModel", 0); ShaderDefault.Uniforms.SetValue("texRandom", 1); ShaderScreen = new ShaderProgram(EmbeddedResources.FsScreen, EmbeddedResources.VsScreen); ShaderScreen.Uniforms.SetValue("width", Window.Width); ShaderScreen.Uniforms.SetValue("height", Window.Height); ShaderScreen.Uniforms.SetValue("texScene", 0); ShaderScreen.Uniforms.SetValue("texInterface", 1); ShaderScreen.Uniforms.SetValue("samplesScene", FramebufferScene.Width); ShaderScreen.Uniforms.SetValue("samplesInterface", FramebufferInterface.Samples); TextureDefault = TexturePointer.Create(EmbeddedResources.ImgNoTexture); TextureRandom = TexturePointer.Create(EmbeddedResources.ImgRandom); Lumberjack.Debug("Creating NanoVG context"); Nvg = GlNanoVg.CreateGl(NvgCreateFlags.StencilStrokes); Nvg.CreateFont("engine_mono", EmbeddedResources.IBMPlexMono_Text); // Just so ProcGraph is happy for now, TODO Nvg.CreateFont("sans", EmbeddedResources.IBMPlexMono_Text); UserInterface = new DebugUserInterface(); Lumberjack.Debug("Creating scene"); Camera = new Camera(); Scene = new Scene(); Flat6Window.SuppressGlMessage(131218); // "Shader will be recompiled due to..." WindowCreated?.Invoke(this, EventArgs.Empty); }
public RenderManager(GameWindow window, CsTerrainGenerator generator) { _window = window; _generator = generator; _fgJobs = new ConcurrentQueue <IJob>(); _bgJobs = new ConcurrentQueue <IJob>(); _nvg = GlNanoVg.CreateGl(NvgCreateFlags.StencilStrokes | NvgCreateFlags.AntiAlias); _ui = new KuatWindow(window, new KuatFont("sans", 16)); KuatButton b; KuatKnob k; KuatIndicator i; _ui.Controls.Add(b = new KuatButton("bTest") { Location = new Point(50, 50), Size = new Size(60, 23), Text = "Button" }); b.Click += (sender, args) => { Lumberjack.Info("Click!"); }; _ui.Controls.Add(new KuatCheckbox("cbTest") { Location = new Point(50, 90), Size = new Size(14, 14), Text = "Checkbox" }); _ui.Controls.Add(k = new KuatKnob("kTest") { Location = new Point(50, 130) }); _ui.Controls.Add(i = new KuatIndicator("iTest") { Location = new Point(120, 130) }); k.ValueChanged += (sender, args) => { i.Lit = k.Value > 0; }; _ui.Controls.Add(new KuatTextBox("tbTest") { Location = new Point(170, 90), Size = new Size(120, 23), ForeColor = Color.Black }); var rMono = _nvg.CreateFont("mono", EmbeddedFiles.ibmplexmono); if (rMono == -1) { throw new ApplicationException("Unable to load mono font"); } var rSans = _nvg.CreateFont("sans", EmbeddedFiles.ibmplexsans); if (rSans == -1) { throw new ApplicationException("Unable to load sans font"); } _perfGraphFps = new PerfGraph(GraphRenderStyle.Fps, null, 40); _framebuffer = new Framebuffer(8); _framebuffer.Init(window.Width, window.Height); _framebufferUi = new Framebuffer(1); _framebufferUi.Init(window.Width, window.Height); _texRandom = LoadGlTexture(EmbeddedFiles.random); _shaderModel = new ShaderProgram(EmbeddedFiles.fs_model, EmbeddedFiles.vs_model); _shaderModel.Init(); _shaderScreen = new ShaderProgram(EmbeddedFiles.fs_screen, EmbeddedFiles.vs_screen); _shaderScreen.Init(); _workerHandle = new EventWaitHandle(false, EventResetMode.ManualReset); CreateChunks(); CreateScreenVao(); }