static void DrawImage(ShaderProgram shader, STGenericTexture texture, Vector2 scale, bool showAlpha) { ImageBlendState.RenderBlendState(); //Draw main texture quad inside boundings (0, 1) shader.SetVector2("scale", scale); // shader.SetVector2("scale", new Vector2(1)); shader.SetVector4("uColor", new Vector4(1)); shader.SetBoolToInt("isSRGB", texture.IsSRGB); shader.SetBoolToInt("displayAlpha", showAlpha); shader.SetVector2("texCoordScale", new Vector2(1)); shader.SetFloat("width", texture.Width); shader.SetFloat("height", texture.Height); shader.SetInt("currentMipLevel", 0); GL.ActiveTexture(TextureUnit.Texture1); BindTexture(texture); shader.SetInt("textureInput", 1); shader.SetInt("hasTexture", 1); //Draw background vao.Enable(shader); vao.Use(); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, Length); }
public static void Draw(STGenericTexture texture, STGenericTextureMap textureMap, int width, int height, Vector2 aspectScale, Viewport2D.Camera2D camera) { Vector2 bgscale = new Vector2(100, 100); Init(); GL.Disable(EnableCap.CullFace); var shader = GlobalShaders.GetShader("UV_WINDOW"); shader.Enable(); var cameraMtx = camera.ViewMatrix * camera.ProjectionMatrix; shader.SetMatrix4x4("mtxCam", ref cameraMtx); GL.ActiveTexture(TextureUnit.Texture1); BindTexture(texture, textureMap); shader.SetInt("uvTexture", 1); shader.SetInt("hasTexture", 1); shader.SetVector2("scale", bgscale * aspectScale); shader.SetVector2("texCoordScale", bgscale); shader.SetVector4("uColor", new Vector4(0.5f, 0.5f, 0.5f, 1.0f)); if (texture != null) { shader.SetBoolToInt("isSRGB", texture.IsSRGB); } //Draw background vao.Enable(shader); vao.Use(); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, Length); //Draw main texture quad inside boundings (0, 1) shader.SetVector2("scale", aspectScale); shader.SetVector2("texCoordScale", new Vector2(1)); shader.SetVector4("uColor", new Vector4(1)); vao.Enable(shader); vao.Use(); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, Length); //Draw outline of boundings (0, 1) shader.SetInt("hasTexture", 0); shader.SetVector2("scale", aspectScale); shader.SetVector2("texCoordScale", new Vector2(1)); shader.SetVector4("uColor", new Vector4(0, 0, 0, 1)); vao.Enable(shader); vao.Use(); GL.LineWidth(1); GL.DrawArrays(PrimitiveType.LineLoop, 0, Length); GL.Enable(EnableCap.CullFace); }
public void DrawColorPicking(GLContext control) { if (control.ColorPicker.PickingMode == ColorPicker.SelectionMode.Mesh) { control.ColorPicker.SetPickingColor(this, control.CurrentShader); } //Draw the mesh vao.Enable(control.CurrentShader); vao.Use(); Draw(); }
public void DrawCenter() { using (fullGrid.Use()) { GL.DrawElements(BeginMode.Triangles, fullGrid.Buffer.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); } }
public void DrawOuter(int numLevels) { using (hollowGrid.Use()) { GL.Ext.DrawElementsInstanced(BeginMode.Triangles, hollowGrid.Buffer.Count, DrawElementsType.UnsignedInt, IntPtr.Zero, numLevels); } }
private void InitializeBuffer <T>(VertexBufferObject <T> buffer, bool setPointer) where T : struct { buffer.Create(); using (buffer.Use()) { buffer.Upload(); if (setPointer) { buffer.SetPointer(); } } }
public static void Draw(GLContext control, GLTexture colorPass, GLTexture bloomPass) { Initialize(control); GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.CullFace); control.CurrentShader = DefaultShaderProgram; DefaultShaderProgram.SetInt("ENABLE_BLOOM", 0); DefaultShaderProgram.SetInt("ENABLE_LUT", 0); DefaultShaderProgram.SetBoolToInt("ENABLE_SRGB", control.UseSRBFrameBuffer); GL.ActiveTexture(TextureUnit.Texture1); colorPass.Bind(); DefaultShaderProgram.SetInt("uColorTex", 1); if (bloomPass != null && control.EnableBloom) { DefaultShaderProgram.SetInt("ENABLE_BLOOM", 1); GL.ActiveTexture(TextureUnit.Texture24); bloomPass.Bind(); DefaultShaderProgram.SetInt("uBloomTex", 24); } /* * * * if (LightingEngine.LightSettings.ColorCorrectionTable != null) * { * DefaultShaderProgram.SetInt("ENABLE_LUT", 1); * * GL.ActiveTexture(TextureUnit.Texture25); * LightingEngine.LightSettings.ColorCorrectionTable.Bind(); * DefaultShaderProgram.SetInt("uLutTex", 25); * } */ vao.Enable(DefaultShaderProgram); vao.Use(); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, Length); GL.BindTexture(TextureTarget.Texture2D, 0); GL.UseProgram(0); }
public static void Draw(GLContext control, GLTexture screen, GLTexture brightnessTexture) { Initialize(control); GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); control.CurrentShader = DefaultShaderProgram; DefaultShaderProgram.SetFloat("exposure", 1.0f); GL.ActiveTexture(TextureUnit.Texture23); screen.Bind(); DefaultShaderProgram.SetInt("scene", 23); GL.ActiveTexture(TextureUnit.Texture24); brightnessTexture.Bind(); DefaultShaderProgram.SetInt("bloomBlur", 24); vao.Enable(DefaultShaderProgram); vao.Use(); GL.DrawArrays(PrimitiveType.QuadStrip, 0, Length); }
public void Draw(UVViewport.Camera2D camera, Vector2 scale) { GL.Disable(EnableCap.CullFace); var shader = GlobalShaders.GetShader("UV_WINDOW"); shader.Enable(); var cameraMtx = camera.ViewMatrix * camera.ProjectionMatrix; //shader.SetMatrix4x4("mtxMdl", ref scaleMtx); shader.SetMatrix4x4("mtxCam", ref cameraMtx); shader.SetInt("hasTexture", 0); shader.SetVector2("scale", scale); shader.SetVector4("uColor", ColorUtility.ToVector4(Runtime.UVEditor.UVColor)); vao.Enable(shader); vao.Use(); GL.DrawArrays(PrimitiveType.LineLoop, 0, Points.Count); GL.Enable(EnableCap.CullFace); }
private void Draw(ShaderProgram shader) { vbo.Enable(ShaderProgram); vbo.Use(); GL.DrawArrays(PrimitiveType.Lines, 0, Vertices.Length); }
private void BindBuffer() { vao.Enable(defaultShaderProgram); vao.Use(); GL.DrawArrays(PrimitiveType.Triangles, 0, 3); }