protected override void OnUpdateFrame(FrameEventArgs e) { base.OnUpdateFrame(e); queue.TryDequeue(out ShaderInfo info); if (info != null) { try { SetShaders(info.VertexCode, info.FragmentCode); } catch (Exception ex) { Logger.Error($"Could not apply shader program. Maybe it invalid. Exception: {ex}"); } } UniformResolution.Set2F(ClientRectangle.Width, ClientRectangle.Height); time += e.Time * Config.TimeScale; UniformTime.Set1F((float)time); if (Config.MouseInteract) { MouseState mouse = Mouse.GetState(); UniformMouse.Set4F(SystemCursor.Position.X, SystemCursor.Position.Y, mouse.LeftButton == ButtonState.Pressed ? 1 : 0, mouse.RightButton == ButtonState.Pressed ? 1 : 0); } }
void InitShader(params Shader[] shaders) { Program = new ShaderProgram(shaders); CheckOpenGLError(); AttributePosition.GetLocation(Program); UniformTime.GetLocation(Program); UniformResolution.GetLocation(Program); UniformMouse.GetLocation(Program); Program.Use(); CheckOpenGLError(); }