Documentation ¶
Overview ¶
Package glcaps provides a nice interface to declare OpenGL capabilities you care about, including minimum required extensions or capabilities. Glcaps has no dependencies and is agnostic to the exact OpenGL binding used.
OpenGL® and the oval logo are trademarks or registered trademarks of Hewlett Packard Enterprise in the United States and/or other countries worldwide.
Examples ¶
Example using glcaps with an OpenGL binding and a struct with tags.
See https://godoc.org/tawesoft.co.uk/go/glcaps#Parse for a description of the struct annotation syntax.
https://www.tawesoft.co.uk/go/doc/glcaps/examples/example/
FROZEN - PLEASE MIGRATE ¶
These packages are moving to https://github.com/tawesoft/golib.
This is to increase security against possible supply chain attacks such as our domain name expiring in the future and being registered by someone else.
Please migrate to https://github.com/tawesoft/golib (when available) instead.
Most programs relying on a package in this monorepo, such as the dialog or lxstrconv packages, will continue to work for the foreseeable future.
Rarely used packages have been hidden for now - they are in the git commit history at https://github.com/tawesoft/go if you need to resurrect one.
Package Information ¶
License: MIT (see LICENSE.txt)
Stable: yes
For more information, documentation, source code, examples, support, links, etc. please see https://www.tawesoft.co.uk/go and https://www.tawesoft.co.uk/go/glcaps
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse(binding *Binding, target interface{}) (extensions Extensions, errors Errors)
Parse parses a struct and parses struct tag annotations to identify the required OpenGL information. It fills the target struct with the results, and returns zero or more Errors if any defined requirements are not met. It also returns a sorted string list of all supported OpenGL extensions.
The struct tag key is `glcaps`. The struct tag syntax is a space-separated list of commands, optionally followed by a colon and a space-separated list of requirements.
Commands:
and command1 command2 - return true if command1 and command2 are true or command1 command2 - return true if either command1 or command2 are true not command - return the boolean opposite of a command ext GL_EXT_name - return true if the given extension is supported GetIntegerv GL_name - lookup and return an integer value GetFloatv GL_name - lookup and return a float value if command1 command2 command3 - if command1 is true, return the result of command2 otherwise return command3 eq|neq|lt|lte|gt|gte command1 command2 - return true if command1 ==/!=/</<=/>/>= command2 respectively value - a value literal (e.g. true, false, 123, 1.23, 128KiB)
Requirements:
required - generate an error if the result is not true eq|neq|lt|lte|gt|gte value - generate an error if the command is not ==, !=, <, <=, >, >= value respectively
Types ¶
type Binding ¶
type Binding struct { GetIntegerv func(name uint32, data *int32) GetFloatv func(name uint32, data *float32) GetString func(name uint32) string // required to return a Go string, not a C string! GetStringi func(name uint32, index uint32) string // required to return a Go string, not a C string! }
Binding implements a binding between this package and a specific OpenGL implementation (e.g. a specific `go-gl` module).
func (*Binding) QueryExtensions ¶
func (b *Binding) QueryExtensions() Extensions
QueryExtensions returns all extensions supported by the current OpenGL context as a sorted list of strings. It is an error to call this method if a current OpenGL context does not exist.
type Error ¶
type Error struct { Field string // the name of the field in the struct that failed Tag string // the original tag string Requirement requirement // the requirement that failed Message string // a human-readable message }
Error implements an error result type for reporting a capability that doesn't meet a requirement.
type Extensions ¶
type Extensions []string
Extensions is an ordered list of supported OpenGL extensions.
func (Extensions) Contains ¶
func (extensions Extensions) Contains(key string) bool
HaveExtension returns true iff the ordered list of supported OpenGL extensions contains a given extension.