video

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

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

type Video

type Video struct {
	GLVersion string
	Window    WindowInterface
	Geom      libretro.GameGeometry
	Font      *glfont.Font
	// contains filtered or unexported fields
}

Video holds the state of the video package

func Init

func Init(fullscreen bool, GLVersion string) *Video

Init instanciates the video package

func (*Video) Configure

func (video *Video) Configure(fullscreen bool)

Configure instanciates the video package

func (*Video) CoreRatioViewport

func (video *Video) CoreRatioViewport(fbWidth int, fbHeight int)

CoreRatioViewport configures the vertex array to display the game at the center of the window while preserving the original ascpect ratio of the game or core

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 float32, scale float32, c Color)

DrawRect draws a colored rectangle

func (*Video) DrawRoundedRect

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

DrawRoundedRect draws a rectangle with rounded corners

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) 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) TakeScreenshot

func (video *Video) TakeScreenshot()

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

type WindowInterface

type WindowInterface interface {
	GetFramebufferSize() (width, height int)
	Destroy()
	MakeContextCurrent()
	SetSizeLimits(minw, minh, maxw, maxh int)
	SetInputMode(mode glfw.InputMode, value int)
	GetKey(key glfw.Key) glfw.Action
	SetShouldClose(bool)
	ShouldClose() bool
	SetTitle(string)
	SwapBuffers()
}

WindowInterface lists all the methods from glfw.Window that we are using. It is there only to allow mocking during tests.

Jump to

Keyboard shortcuts

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