Socket
Socket
Sign inDemoInstall

github.com/notsatvrn/gl

Package Overview
Dependencies
3
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/notsatvrn/gl

Package gl is a Go cross-platform binding for OpenGL, with an OpenGL ES 3-like API. It supports: - macOS, Linux and Windows via OpenGL 4.3 backend, - iOS and Android via OpenGL ES 3.0 backend, - Modern Browsers (desktop and mobile) via WebGL 2.0 backend. This is a fork of golang.org/x/mobile/gl package with [CL 8793](https://go-review.googlesource.com/8793) merged in and Windows support added. This package is fully functional, but may eventually become superceded by the new x/mobile/gl plan. It will exist and be fully supported until it can be safely replaced by a better package. This OpenGL binding has a ContextWatcher, which implements [glfw.ContextWatcher](https://godoc.org/github.com/notsatvrn/glfw#ContextWatcher) interface. Recommended usage is with github.com/notsatvrn/glfw package, which accepts a ContextWatcher in its Init, and takes on the responsibility of notifying it when context is made current or detached. If you're not using a ContextWatcher-aware glfw library, you must call methods of gl.ContextWatcher yourself whenever you make a context current or detached.


Version published

Readme

Source

XGL

Go Reference

XGL is a cross-platform binding to OpenGL for Go, exposing an OpenGL ES-like API.

The API is very similar to OpenGL ES, with a few important changes.

  • Addition of GetBoundFramebuffer function.
  • Functions which use pointers to arrays for returning data have versions for getting a single value.
    • For example, you can use GetShaderiv to store integer values from a parameter in an array, or GetShaderi to return only one.
    • The purpose of this is simply ease of use.
  • All Gen functions are renamed to Create.
    • For example, GenBuffers becomes CreateBuffers.
    • There are also functions for simply generating 1 of each type, such as CreateBuffer.
  • No GetVertexAttribPointerv or ShaderBinary functions.
    • GetVertexAttribPointerv requires a complicated implementation and wont be used by most programs.
    • ShaderBinary is impossible to implement for WebGL. Other platforms can support ShaderBinary, but its usage is considered a security risk anyways, and we want to provide a consistent API on all platforms. No platform-specific functions.
  • Functions which fail if an argument doesn't have a specific value don't ask the user for that argument.
    • Because, really, why?

Support

Below is a table showing the versions of XGL and the minimum required GL versions for each platform.

XGLOpenGL (Desktop)OpenGL ES (Mobile)WebGL (Browser)
2.02.12.01.0

Support for OpenGL ES 3.0 and 3.1 is planned.

OpenGL ES 3.2 is not planned, due to WebGL not supporting it yet.

Installation

go get -u github.com/notsatvrn/gl/...
GOARCH=js go get -u -d github.com/notsatvrn/gl/...

Usage

These bindings implement a glfw.ContextWatcher interface. Recommended usage is with github.com/notsatvrn/glfw package, which accepts a ContextWatcher in its Init, and takes on the responsibility of notifying it when context is made current or detached.

if err := glfw.Init(gl.ContextWatcher); err != nil {
	// Handle error.
}
defer glfw.Terminate()

If you're not using a ContextWatcher-aware glfw library, you must call methods of gl.ContextWatcher yourself whenever you make a context current or detached.

window.MakeContextCurrent()
gl.ContextWatcher.OnMakeCurrent(nil)

glfw.DetachCurrentContext()
gl.ContextWatcher.OnDetach()

FAQs

Last updated on 17 Dec 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc