From a36cfb17b4301178857115d694dd60f3999c88c1 Mon Sep 17 00:00:00 2001 From: mlange-42 Date: Fri, 14 Apr 2023 11:33:38 +0200 Subject: [PATCH] add method Window.Hide, minor formatting and doc fixes --- pixelgl/glshader.go | 10 +++++----- pixelgl/window.go | 12 ++++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pixelgl/glshader.go b/pixelgl/glshader.go index 6352519..2588df2 100644 --- a/pixelgl/glshader.go +++ b/pixelgl/glshader.go @@ -46,10 +46,10 @@ var defaultCanvasVertexFormat = glhf.AttrFormat{ canvasColor: glhf.Attr{Name: "aColor", Type: glhf.Vec4}, canvasTexCoords: glhf.Attr{Name: "aTexCoords", Type: glhf.Vec2}, canvasIntensity: glhf.Attr{Name: "aIntensity", Type: glhf.Float}, - canvasClip: glhf.Attr{Name: "aClipRect", Type: glhf.Vec4}, + canvasClip: glhf.Attr{Name: "aClipRect", Type: glhf.Vec4}, } -// Sets up a base shader with everything needed for a Pixel +// NewGLShader sets up a base shader with everything needed for a Pixel // canvas to render correctly. The defaults can be overridden // by simply using the SetUniform function. func NewGLShader(fragmentShader string) *GLShader { @@ -109,10 +109,10 @@ func (gs *GLShader) getUniform(Name string) int { // SetUniform appends a custom uniform name and value to the shader. // if the uniform already exists, it will simply be overwritten. // -// example: +// Example: // -// utime := float32(time.Since(starttime)).Seconds()) -// mycanvas.shader.AddUniform("u_time", &utime) +// utime := float32(time.Since(starttime)).Seconds()) +// mycanvas.shader.AddUniform("u_time", &utime) func (gs *GLShader) SetUniform(name string, value interface{}) { t, p := getAttrType(value) if loc := gs.getUniform(name); loc > -1 { diff --git a/pixelgl/window.go b/pixelgl/window.go index 8ceb77f..31dd46f 100644 --- a/pixelgl/window.go +++ b/pixelgl/window.go @@ -232,7 +232,7 @@ func (w *Window) ClipboardText() string { } // SetClipboardText passes the given string to the underlying glfw window to set the -// systems clipboard. +// systems clipboard. func (w *Window) SetClipboardText(text string) { w.window.SetClipboardString(text) } @@ -527,6 +527,14 @@ func (w *Window) Show() { }) } +// Hide hides the window, if it was previously visible. If the window is already +// hidden or is in full screen mode, this function does nothing. +func (w *Window) Hide() { + mainthread.Call(func() { + w.window.Hide() + }) +} + // Clipboard returns the contents of the system clipboard. func (w *Window) Clipboard() string { var clipboard string @@ -536,7 +544,7 @@ func (w *Window) Clipboard() string { return clipboard } -// SetClipboardString sets the system clipboard to the specified UTF-8 encoded string. +// SetClipboard sets the system clipboard to the specified UTF-8 encoded string. func (w *Window) SetClipboard(str string) { mainthread.Call(func() { w.window.SetClipboardString(str)