example

package
v0.0.0-...-3c4337b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package example contains the core logic of the demo. The Run() function demonstrates how a typical application would create a UI. The function herein is not concerned about technology-specific things, such as which abstraction library or which drawing interface is used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(p Platform, r Renderer)

Run implements the main program loop of the demo. It returns when the platform signals to stop. This demo application shows some basic features of ImGui, as well as exposing the standard demo window.

Types

type Platform

type Platform interface {
	// ShouldStop is regularly called as the abort condition for the program loop.
	ShouldStop() bool
	// ProcessEvents is called once per render loop to dispatch any pending events.
	ProcessEvents()
	// DisplaySize returns the dimension of the display.
	DisplaySize() [2]float32
	// FramebufferSize returns the dimension of the framebuffer.
	FramebufferSize() [2]float32
	// NewFrame marks the begin of a render pass. It must update the cimgui IO state according to user input (mouse, keyboard, ...)
	NewFrame()
	// PostRender marks the completion of one render pass. Typically this causes the display buffer to be swapped.
	PostRender()
	// ClipboardText returns the current text of the clipboard, if available.
	ClipboardText() (string, error)
	// SetClipboardText sets the text as the current text of the clipboard.
	SetClipboardText(text string)
}

Platform covers mouse/keyboard/gamepad inputs, cursor shape, timing, windowing.

type Renderer

type Renderer interface {
	// PreRender causes the display buffer to be prepared for new output.
	PreRender(clearColor [3]float32)
	// Render draws the provided cimgui draw data.
	Render(displaySize [2]float32, framebufferSize [2]float32, drawData imgui.DrawData)
}

Renderer covers rendering cimgui draw data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL