public static int GetBoundTexture2D() { var prevTexture = 0; GL.GetInteger(GetPName.TextureBinding2D, out prevTexture); GraphicsExtensions.LogGLError("GraphicsExtensions.GetBoundTexture2D() GL.GetInteger"); return(prevTexture); }
private ShaderProgram Link(Shader vertexShader, Shader pixelShader) { // NOTE: No need to worry about background threads here // as this is only called at draw time when we're in the // main drawing thread. var program = GL.CreateProgram(); GraphicsExtensions.CheckGLError(); GL.AttachShader(program, vertexShader.GetShaderHandle()); GraphicsExtensions.CheckGLError(); GL.AttachShader(program, pixelShader.GetShaderHandle()); GraphicsExtensions.CheckGLError(); //vertexShader.BindVertexAttributes(program); GL.LinkProgram(program); GraphicsExtensions.CheckGLError(); GL.UseProgram(program); GraphicsExtensions.CheckGLError(); vertexShader.GetVertexAttributeLocations(program); pixelShader.ApplySamplerTextureUnits(program); var linked = 0; GL.GetProgram(program, GetProgramParameterName.LinkStatus, out linked); GraphicsExtensions.LogGLError("VertexShaderCache.Link(), GL.GetProgram"); if (linked == (int)Bool.False) { var log = GL.GetProgramInfoLog(program); Console.WriteLine(log); GL.DetachShader(program, vertexShader.GetShaderHandle()); GL.DetachShader(program, pixelShader.GetShaderHandle()); #if MONOMAC GL.DeleteProgram(1, ref program); #else GL.DeleteProgram(program); #endif throw new InvalidOperationException("Unable to link effect program"); } return(new ShaderProgram(program)); }
private void PlatformSetViewport(ref Viewport value) { if (IsRenderTargetBound) { GL.Viewport(value.X, value.Y, value.Width, value.Height); } else { GL.Viewport(value.X, PresentationParameters.BackBufferHeight - value.Y - value.Height, value.Width, value.Height); } GraphicsExtensions.LogGLError("GraphicsDevice.Viewport_set() GL.Viewport"); #if GLES GL.DepthRange(value.MinDepth, value.MaxDepth); #else GL.DepthRange(value.MinDepth, value.MaxDepth); #endif GraphicsExtensions.LogGLError("GraphicsDevice.Viewport_set() GL.DepthRange"); // In OpenGL we have to re-apply the special "posFixup" // vertex shader uniform if the viewport changes. _vertexShaderDirty = true; }