From 36759cc253dcb99d9d3462fb96485cee55821ac0 Mon Sep 17 00:00:00 2001 From: Babz Date: Sat, 16 Jan 2021 14:30:11 +0100 Subject: [PATCH 1/2] switch to GLES 3.1 (should improve compatibility) --- glc/buffer.go | 2 +- glc/init.go | 2 +- glc/program.go | 2 +- glc/shader.go | 15 +++++++++++---- glc/sync.go | 2 +- go.mod | 1 + go.sum | 3 ++- 7 files changed, 18 insertions(+), 9 deletions(-) diff --git a/glc/buffer.go b/glc/buffer.go index 5ee5226..799b6ef 100644 --- a/glc/buffer.go +++ b/glc/buffer.go @@ -5,7 +5,7 @@ import ( "runtime" "unsafe" - "github.com/go-gl/gl/v4.3-core/gl" + gl "github.com/adraenwan/opengl-es-go/v3.1/gl" ) // const ( diff --git a/glc/init.go b/glc/init.go index 71ef0fc..b420b7f 100644 --- a/glc/init.go +++ b/glc/init.go @@ -1,7 +1,7 @@ package glc import ( - "github.com/go-gl/gl/v4.3-core/gl" + gl "github.com/adraenwan/opengl-es-go/v3.1/gl" "github.com/remogatto/egl" "fmt" diff --git a/glc/program.go b/glc/program.go index bc668b4..94b81d1 100644 --- a/glc/program.go +++ b/glc/program.go @@ -5,7 +5,7 @@ import ( "runtime" "strings" - "github.com/go-gl/gl/v4.3-core/gl" + gl "github.com/adraenwan/opengl-es-go/v3.1/gl" ) // Hight-level wrapper for shader programs diff --git a/glc/shader.go b/glc/shader.go index e88a197..a2a54b7 100644 --- a/glc/shader.go +++ b/glc/shader.go @@ -6,9 +6,15 @@ import ( "runtime" "strings" - "github.com/go-gl/gl/v4.3-core/gl" + gl "github.com/adraenwan/opengl-es-go/v3.1/gl" ) +/* +#include +*/ +import "C" +import "unsafe" + // wrapper for shaders // not necessary since Program // handles the creation/deletion @@ -58,10 +64,11 @@ func (s *Shader) check() error { } func (s *Shader) CompileStr(source string) error { - csource, csourceFree := gl.Strs(source) - defer csourceFree() + csource := C.CString(source) + defer C.free(unsafe.Pointer(csource)) + ln := int32(len(source)) - gl.ShaderSource(s.id, 1, csource, &ln) + gl.ShaderSource(s.id, 1, (**uint8)(unsafe.Pointer(&csource)), &ln) gl.CompileShader(s.id) err := s.check() diff --git a/glc/sync.go b/glc/sync.go index cc7ec13..c86adae 100644 --- a/glc/sync.go +++ b/glc/sync.go @@ -3,7 +3,7 @@ package glc import ( "time" - "github.com/go-gl/gl/v4.3-core/gl" + gl "github.com/adraenwan/opengl-es-go/v3.1/gl" ) // memory barrier diff --git a/go.mod b/go.mod index c6a0a57..0f564d1 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/adraenwan/glcompute go 1.15 require ( + github.com/adraenwan/opengl-es-go v0.0.0-20150603063834-39b7066af7c2 github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 github.com/remogatto/egl v0.0.0-20140203134355-fea5ba3496ba ) diff --git a/go.sum b/go.sum index 4780910..f9abddf 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,5 @@ -github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw= +github.com/adraenwan/opengl-es-go v0.0.0-20150603063834-39b7066af7c2 h1:Yzm59/hcTu6zRrJzR5rmsuGiwB1g8jbHR4cIr9hwPKg= +github.com/adraenwan/opengl-es-go v0.0.0-20150603063834-39b7066af7c2/go.mod h1:uSgZwepxb/uB8Sat8WRdDEr9uJ2N/0QUeQBm++q8YyU= github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk= github.com/remogatto/egl v0.0.0-20140203134355-fea5ba3496ba h1:0EE2haDQAnaldV7OhCWqltUPcgsZUZttKOGcHKZyxdM= github.com/remogatto/egl v0.0.0-20140203134355-fea5ba3496ba/go.mod h1:/SxS0px6zZIo/owvUHed3K8JBZQ10aIpTdMOkjeWlmo= From ab8367a6cf43bae304a962c7cdfd6d783bdc4422 Mon Sep 17 00:00:00 2001 From: Babz Date: Sat, 16 Jan 2021 15:23:24 +0100 Subject: [PATCH 2/2] readme : gl 4.3 -> gles 3.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e35b5a5..c78eb9b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # GLcompute [![Documentation](https://godoc.org/github.com/adraenwan/glcompute?status.svg)](https://godoc.org/github.com/adraenwan/glcompute) -GLcompute (aka glc) is a Go library for GPGPU using OpenGL 4.3 compute shaders as the backend. +GLcompute (aka glc) is a Go library for GPGPU using OpenGL ES 3.1 compute shaders as the backend. * `glc/` contains the actual library * `demo/` contains a short example to get started with glc