private MyApplication() { //registers a callback for drawing a frame gameWindow.RenderFrame += GameWindow_RenderFrame; gameWindow.RenderFrame += (sender, e) => gameWindow.SwapBuffers(); //register a callback for updating the game logic gameWindow.UpdateFrame += GameWindow_UpdateFrame; gameWindow.KeyDown += GameWindow_KeyDown; texBackground = TextureLoader.FromBitmap(Resources.background); texBird = TextureLoader.FromBitmap(Resources.bird); postProcessing = new PostProcessing(gameWindow.Width, gameWindow.Height); try { postProcessing.SetShader(Encoding.UTF8.GetString(Resources.EdgeDetect)); } catch (ShaderException e) { Console.WriteLine(e.Log); } //for transparency in textures we use blending GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.Blend); globalTime.Start(); }
public Visual(IRenderState renderState, IContentLoader contentLoader) { fbo = new FBO(Texture2dGL.Create(70, 70)); fbo.Texture.Filter = TextureFilterMode.Nearest; copyToFrameBuffer = new PostProcessing(contentLoader.LoadPixelShader("copy.frag")); renderState.Set(BlendStates.AlphaBlend); renderState.Set(new LineSmoothing(true)); renderState.Set(new LineWidth(5f)); GL.Enable(EnableCap.PointSmooth); }
public Rasterizer(IContentLoader contentLoader, int resolutionX, int resolutionY, Action drawHandler) { if (drawHandler is null) { throw new ArgumentException("Draw handler must not equal null!"); } this.drawHandler = drawHandler; copyToFrameBuffer = new PostProcessing(contentLoader.LoadPixelShader("copy.frag")); var texRenderSurface = Texture2dGL.Create(resolutionX, resolutionY); texRenderSurface.Filter = TextureFilterMode.Nearest; fbo = new FBO(texRenderSurface); }
private MyVisual(int width, int height) { texBackground = TextureLoader.FromBitmap(Resources.background); texBird = TextureLoader.FromBitmap(Resources.bird); postProcessing = new PostProcessing(width, height); try { postProcessing.SetShader(Encoding.UTF8.GetString(Resources.EdgeDetect)); } catch (ShaderException e) { Console.WriteLine(e.ShaderLog); } //for transparency in textures we use blending GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.Blend); globalTime.Start(); }