goxjs / gl Goto Github PK
View Code? Open in Web Editor NEWGo cross-platform OpenGL bindings.
License: BSD 3-Clause "New" or "Revised" License
Go cross-platform OpenGL bindings.
License: BSD 3-Clause "New" or "Revised" License
When I try this go get -u github.com/goxjs/gl/...
I get this error
package golang.org/x/mobile/event/config: cannot find package "golang.org/x/mobile/event/config" in any of:
/usr/local/go/src/golang.org/x/mobile/event/config (from $GOROOT)
this maybe because of the this refactor in this commit,
golang/mobile@f632204
Both the WebGL and Windows backends (glweb.gl
and gl_windows.go
) are partially implemented. Most common funcs are there (for all my tests and gxui tests), but far from all.
All remaining funcs are marked with "not yet implemented" panics.
bash-3.2$ GOOS=windows GOARCH=386 go build -o g4.exe g4.go
../github.com/goxjs/gl/gl_opengl.go:10:2: no buildable Go source files in /p/lorgenome/src/github.com/go-gl/gl/v2.1/gl
../github.com/goxjs/glfw/desktop.go:10:2: no buildable Go source files in /p/lorgenome/src/github.com/go-gl/glfw/v3.2/glfw
Has any one tried to cross compile this?
Is there any plans for WebGL 2?
I gave the Windows build a try, and unfortunately we get a fatal error on start up initializing gl:
gl.Init: glActiveTexture
I believe the problem is that
gl.Init
must be called after MakeCurrentContext as wglGetProcAddress requires a bound context: When no current rendering context exists or the function fails, the return value is NULL.
Originally reported in google/gxui#86 (comment).
As mentioned at google/gxui#86 (comment):
Calling
gl.Init()
every time a context is made current isn't good. You mentioned exactly my concern on this bug: GXUI can make frequent switches between contexts when we have multiple windows open. If you have two windows animating, I'm guessing performance is going to suck.
This is a followup to #6.
It seems odd that you are using OpenGL 2.1 for desktops but ES2 for mobile. Doesn't the ES2 spec basically match OpenGL 3.3? Is there more detail that I'm missing?
In attempting to cross-compile a program for both WebGL and Desktop OpenGL, I've noticed that the Attrib type is uint
for the former, and int
for the latter. This makes it a little hard to manipulate these in a portable way.
Is there a technical reason why these are different, or could they be brought into alignment?
go get github.com/goxjs/gl
github.com/goxjs/gl
code/go/src/github.com/goxjs/gl/gl_opengles.go:24: ContextWatcher redeclared in this block
previous declaration at code/go/src/github.com/goxjs/gl/gl_opengl.go:17
code/go/src/github.com/goxjs/gl/gl_opengles.go:26: contextWatcher redeclared in this block
previous declaration at code/go/src/github.com/goxjs/gl/gl_opengl.go:19
code/go/src/github.com/goxjs/gl/gl_opengles.go:29: contextWatcher.OnDetach redeclared in this block
previous declaration at code/go/src/github.com/goxjs/gl/gl_opengl.go:33
code/go/src/github.com/goxjs/gl/gl_opengles.go:31: ActiveTexture redeclared in this block
previous declaration at code/go/src/github.com/goxjs/gl/gl_opengl.go:38
code/go/src/github.com/goxjs/gl/gl_opengles.go:35: AttachShader redeclared in this block
previous declaration at code/go/src/github.com/goxjs/gl/gl_opengl.go:45
code/go/src/github.com/goxjs/gl/gl_opengles.go:39: BindAttribLocation redeclared in this block
previous declaration at code/go/src/github.com/goxjs/gl/gl_opengl.go:53
code/go/src/github.com/goxjs/gl/gl_opengles.go:45: BindBuffer redeclared in this block
previous declaration at code/go/src/github.com/goxjs/gl/gl_opengl.go:60
code/go/src/github.com/goxjs/gl/gl_opengles.go:49: BindFramebuffer redeclared in this block
previous declaration at code/go/src/github.com/goxjs/gl/gl_opengl.go:67
code/go/src/github.com/goxjs/gl/gl_opengles.go:53: BindRenderbuffer redeclared in this block
previous declaration at code/go/src/github.com/goxjs/gl/gl_opengl.go:74
code/go/src/github.com/goxjs/gl/gl_opengles.go:57: BindTexture redeclared in this block
previous declaration at code/go/src/github.com/goxjs/gl/gl_opengl.go:81
code/go/src/github.com/goxjs/gl/gl_opengles.go:57: too many errors`
any plans to support headless gl ?
TypeError: Argument 9 of WebGLRenderingContext.texImage2D does not implement interface ArrayBufferViewOrNull
on Firefox 42.0 and Uncaught TypeError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': parameter 9 is not of type 'ArrayBufferView'
on Chrome 48.0.2564.109.
AFAIK the data
parameter of gl.TexImage2D
is a []byte
which becomes a Uint8Array
in GopherJS... which should satisfy the WebGL standard which calls for an ArrayBufferView.
For comparison, gl.BufferData
takes a []byte
and works fine. The only difference I can see is that the WebGL spec for bufferData
specifies a BufferDataSource?
(which is defined as an ArrayBufferView
or an ArrayBuffer
in the spec) and not an ArrayBufferView?
type for the data parameter.
The funcs in goxjs/gl
have destination first, but OpenGL spec tends to have it last.
Think about this, whether it's an issue or not, and how it can be resolved, if at all.
I am sorry, this may be very basic but I am trying to use this library and I try to run
GOARCH=js go get -u -d github.com/goxjs/gl/...
I get unsupported GOOS/GOARCH pair darwin/js
I have tried a series of pairs like js/js
or /js
or js/darwin
and I get the same message everytime.
Am I doing something wrong? does the library need to be updated?
This package is fully functional, but may eventually become superceded by the new x/mobile/gl plan.
Yet, over 4 years after that sentence was written, I couldn't find any updates on WebGL support being added to the golang.org/x/mobile/gl
package.
Is there actually any work at all being done with that (and I just missed it), or is supersession by x/mobile/gl
entirely a hypothetical?
If it's the latter, it might be about time that the README sees another update to more accurately reflect the current state of this package..?
Go 1.6 will be released end of this month and reject passing go memory block to cgo. Do you have any plant to support 1.6?
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 1 [running, locked to thread]:
github.com/go-gl/gl/v2.1/gl.ShaderSource(0x100000002, 0xc82002e088, 0x0)
/Users/shibukawa.yoshiki/gopath/src/github.com/go-gl/gl/v2.1/gl/package.go:24310 +0x4c
github.com/goxjs/gl.ShaderSource(0xc800000002, 0xc82009e1e0, 0x1ce)
/Users/shibukawa.yoshiki/gopath/src/github.com/goxjs/gl/gl_opengl.go:861 +0xc0
github.com/shibukawa/nanovgo.(*glShader).createShader(0xc82008c000, 0x42ccda0, 0x6, 0x4365cc0, 0x33, 0x0, 0x0, 0x4517840, 0x199, 0x4518040, ...)
/Users/shibukawa.yoshiki/gopath/src/github.com/shibukawa/nanovgo/gl_backend.go:41 +0x182
github.com/shibukawa/nanovgo.(*glParams).renderCreate(0xc82000a410, 0x0, 0x0)
/Users/shibukawa.yoshiki/gopath/src/github.com/shibukawa/nanovgo/gl_backend.go:409 +0x259
github.com/shibukawa/nanovgo.createInternal(0x4d442e0, 0xc82000a410, 0x45efde0, 0x0, 0x0)
/Users/shibukawa.yoshiki/gopath/src/github.com/shibukawa/nanovgo/nanovgo.go:1362 +0x421
github.com/shibukawa/nanovgo.NewContext(0x0, 0x4514828, 0x0, 0x0)
/Users/shibukawa.yoshiki/gopath/src/github.com/shibukawa/nanovgo/gl_backend.go:25 +0xe1
main.main()
/Users/shibukawa.yoshiki/gopath/src/github.com/shibukawa/nanovgo/sample/sample.go:45 +0x19e
(tested my sample code with go 1.6 beta1 on Mac)
Wanted to give some feedback that this seems to be functional. I will probably be confirming a few more of these over the next few days.
gl.GetIntegerv(gl.VIEWPORT, viewport)
returns [0 0 300 150]
and I checked my context and it says WebGLRenderingContext {canvas: canvas, drawingBufferWidth: 300, drawingBufferHeight: 150}
Hi,
I took the triangle example and just added the lines bellow:
...
attribute vec3 aVertexPosition;
attribute vec3 aVertexPosition2;
...
vertexPositionAttrib := gl.GetAttribLocation(program, "aVertexPosition")
fmt.Printf("vertexPositionAttrib = %d", vertexPositionAttrib)
vertexPositionAttrib2 := gl.GetAttribLocation(program, "aVertexPosition2")
fmt.Printf("vertexPositionAttrib2 = %d", vertexPositionAttrib2)
...
I build it with gopherjs and the value of vertexPositionAttrib2 is -1.
Did I missed something?
Regards,
Marc
There are points where I need to get the current frame buffer, bind another, then bind the first one however right now it is not really possible to do that in web gl. Normally I would call gl.GetInteger(gl.FRAMEBUFFER_BINDING)
but that always returns 0 and wont allow me to bind to it. According to this https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bindFramebuffer I would need to call getParameter on the context to get the current frame buffer. It is hard to name a solution to this since adding a GetCurrentFrameBuffer()
method would change the whole api. Also I was thinking exposing the context so I can call any function on it but again that does not work for a uniform API.
Let me know if I have missed a solution, that could be possible as well.
I'm currently investigating my options for writing an OpenGL application for both desktop and web and this repository seems the be the best candidate - good work!
It is a while since it was forked from "golang.org/x/mobile/gl" and it seems that there were quite some major changes - adding WebGL support wasn't one of them.
One change I like particularly is the render-thread: Applications use a glctx-object that exposes the OpenGL functionality, but the calls to that context are only pushed into a channel and executed later by a dedicated render thread. This improves multithreading / go-routine support greatly.
I'm not able to use "golang.org/x/mobile/gl" due to the lack of WebGL support (I don't need to support mobile). And I also don't like the fact that desktop applications require the ANGLE dlls instead of using the OpenGL bindings from go-gl - but I can live with that.
Is it possible for goxjs to adapt those features or to be updated to the newest version of golang.org/x/mobile/gl?
Which changes would be required to do so?
I presume this needs go 1.5 since its using gomobile ?
Whats the difference between this library https://github.com/ajhager/webgl and yours it seems both support the same functionality and API, and both are cross platform and I see you made a commit there also
Right now this package supports OS X, Linux, and browsers.
Windows is currently not supported. I can add it very easily, it would take me an hour or so, but I wouldn't want to spend time on it unless people actually want/need it (I don't use Windows myself).
If you're using this package (or considering it) and want Windows backend added, just leave a +1 here.
any chance on getting some basic examples, to have a base to work from ?
i am quite excited about this project and eager to see how well opengl and webgl can work together.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.