video

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: GPL-3.0 Imports: 21 Imported by: 8

Documentation

Overview

Package video takes care on the game display. It also creates the window using GLFW. It exports the Refresh callback used by the libretro implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewImage

func NewImage(file string) uint32

NewImage opens an image file, upload it the the GPU and returns the texture id

func XYWHTo4points

func XYWHTo4points(x, y, w, h, fbh float32) (x1, y1, x2, y2, x3, y3, x4, y4 float32)

XYWHTo4points converts coordinates from (x, y, width, height) to (x1, y1, x2, y2, x3, y3, x4, y4)

Types

type Color

type Color struct {
	R, G, B, A float32
}

Color is an RGBA type that we use in the menu

func (Color) Alpha added in v0.12.0

func (color Color) Alpha(alpha float32) Color

Alpha sets the alpha channel of a color

type Direction added in v0.11.1

type Direction uint8

Direction represents the direction in which strings should be rendered.

const (
	LeftToRight Direction = iota // E.g.: Latin
	RightToLeft                  // E.g.: Arabic
	TopToBottom                  // E.g.: Chinese
)

Known directions.

type Font added in v0.11.1

type Font struct {
	// contains filtered or unexported fields
}

A Font allows rendering of text to an OpenGL context.

func LoadFont added in v0.11.1

func LoadFont(file string, scale int32, windowWidth int, windowHeight int) (*Font, error)

LoadFont loads the specified font at the given scale.

func LoadTrueTypeFont added in v0.11.1

func LoadTrueTypeFont(program uint32, r io.Reader, scale int32, low, high rune, dir Direction) (*Font, error)

LoadTrueTypeFont builds a set of textures based on a ttf files gylphs

func (*Font) Printf added in v0.11.1

func (f *Font) Printf(x, y float32, scale float32, fs string, argv ...interface{}) error

Printf draws a string to the screen, takes a list of arguments like printf

func (*Font) SetColor added in v0.11.1

func (f *Font) SetColor(color Color)

SetColor allows you to set the text color to be used when you draw the text

func (*Font) UpdateResolution added in v0.11.1

func (f *Font) UpdateResolution(windowWidth int, windowHeight int)

UpdateResolution passes the new framebuffer size to the font shader

func (*Font) Width added in v0.11.1

func (f *Font) Width(scale float32, fs string, argv ...interface{}) float32

Width returns the width of a piece of text in pixels

type Video

type Video struct {
	Window *glfw.Window
	Geom   libretro.GameGeometry
	Font   *Font
	// contains filtered or unexported fields
}

Video holds the state of the video package

func Init

func Init(fullscreen bool) *Video

Init instanciates the video package

func (*Video) Configure

func (video *Video) Configure(fullscreen bool)

Configure instanciates the video package

func (*Video) DrawBorder

func (video *Video) DrawBorder(x, y, w, h, borderWidth float32, c Color)

DrawBorder draws a colored rectangle border

func (*Video) DrawCircle

func (video *Video) DrawCircle(x, y, r float32, c Color)

DrawCircle draws a circle

func (*Video) DrawImage

func (video *Video) DrawImage(image uint32, x, y, w, h float32, scale float32, c Color)

DrawImage draws an image with x, y, w, h

func (*Video) DrawRect

func (video *Video) DrawRect(x, y, w, h, r float32, c Color)

DrawRect draws a rectangle and supports rounded corners

func (*Video) GetFramebufferSize added in v0.14.0

func (video *Video) GetFramebufferSize() (int, int)

GetFramebufferSize retrieves the size, in pixels, of the framebuffer of the specified window.

func (*Video) Reconfigure

func (video *Video) Reconfigure(fullscreen bool)

Reconfigure destroys and recreates the window with new attributes

func (*Video) Refresh

func (video *Video) Refresh(data unsafe.Pointer, width int32, height int32, pitch int32)

Refresh the texture framebuffer

func (*Video) Render

func (video *Video) Render()

Render the current frame

func (*Video) ResetPitch added in v0.7.1

func (video *Video) ResetPitch()

ResetPitch should be called when unloading a game so that the next game won't be rendered with the wrong pitch

func (*Video) ResetRot added in v0.10.3

func (video *Video) ResetRot()

ResetRot should be called when unloading a game so that the next game won't be rendered with the wrong rotation

func (*Video) ResizeViewport added in v0.5.0

func (video *Video) ResizeViewport()

ResizeViewport resizes the GL viewport to the framebuffer size

func (*Video) ScissorEnd added in v0.8.6

func (video *Video) ScissorEnd()

ScissorEnd closes a GL scissor box

func (*Video) ScissorStart added in v0.8.6

func (video *Video) ScissorStart(x, y, w, h int32)

ScissorStart starts a GL scissor box, don't forget to call ScissorEnd

func (*Video) SetPixelFormat

func (video *Video) SetPixelFormat(format uint32) bool

SetPixelFormat is a callback passed to the libretro implementation. It allows the core or the game to tell us which pixel format should be used for the display.

func (*Video) SetRotation added in v0.10.3

func (video *Video) SetRotation(rot uint) bool

SetRotation rotates the game image as requested by the core

func (*Video) SetShouldClose added in v0.14.0

func (video *Video) SetShouldClose(b bool)

SetShouldClose sets the value of the close flag of the window.

func (*Video) SetTitle added in v0.14.0

func (video *Video) SetTitle(title string)

SetTitle sets the window title, encoded as UTF-8, of the window.

func (*Video) TakeScreenshot

func (video *Video) TakeScreenshot(name string) error

TakeScreenshot captures the ouput of video.Render and writes it to a file

func (*Video) UpdateFilter added in v0.5.2

func (video *Video) UpdateFilter(filter string)

UpdateFilter configures the game texture filter and shader. We currently support 4 modes: Raw: nearest Smooth: linear Pixel Perfect: sharp-bilinear CRT: zfast-crt LCD: zfast-lcd

Jump to

Keyboard shortcuts

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