My first time posting here or on any mailing list, so please go gentle on
I'm writing a small project using OpenGL and I am trying to create a
function to make a screenshot, I've done this before in C and C++ with no
problem, but I'm struggling here. The bindings I use
(https://github.com/go-gl/glow) have the pixels returned in the format of
unsafe.Pointer, rather than a byte array. That's an useless format for me
and I'm trying to convert the unsafe.Pointer to a byte.
Here's my current code:
width, height := r.window.GetSize()
m := image.NewRGBA(image.Rect(0, 0, width, height))
pixels := make(byte, len(m.Pix))
// Read in the pixels
gl.ReadPixels(0, 0, int32(width), int32(height), gl.RGBA, gl.UNSIGNED_BYTE,
Which results in the following error:
video\renderer.go:94: cannot use pixels (type byte) as type
unsafe.Pointer in argument gl.ReadPixels
That makes sense of course, but I have no idea how unsafe.Pointer works and
I'm struggling to find a good example on the internet. I've tried a couple
of things (storing the result in var buf unsafe.Pointer) and then
converting that to a byte, but that doesn't work.
Anyone care to show me how it's done? Just to note: I'm using the result
with the image package to write an .png to disk.
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
For more options, visit https://groups.google.com/d/optout.