public static void Draw(STGenericTexture texture, int width, int height, Viewport2D.Camera2D camera, bool showAlpha) { Vector3 scale = new Vector3(1, 1, 1); scale = UpdateAspectScale(scale, width, height, texture); Init(); var shader = GlobalShaders.GetShader("IMAGE_EDITOR"); shader.Enable(); var cameraMtx = Matrix4.CreateScale(100) * camera.ProjectionMatrix; shader.SetMatrix4x4("mtxCam", ref cameraMtx); GL.Disable(EnableCap.Blend); DrawBackground(shader); cameraMtx = camera.ViewMatrix * camera.ProjectionMatrix; shader.SetMatrix4x4("mtxCam", ref cameraMtx); DrawImage(shader, texture, scale.Xy, showAlpha); }
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); }