...
Tawesoft Logo

Package glcaps

import "tawesoft.co.uk/go/glcaps"
Overview
Index
Subdirectories

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/

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

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

type Binding

Binding implements a binding between this package and a specific OpenGL implementation (e.g. a specific `go-gl` module).

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!
}

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

Error implements an error result type for reporting a capability that doesn't meet a requirement.

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
}

type Errors

type Errors []Error

type Extensions

Extensions is an ordered list of supported OpenGL extensions.

type Extensions []string

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.

Subdirectories

Name Synopsis
examples
example