func (ctx *context) cStringPtr(str string) (uintptr, func()) {
	s, free := ctx.cString(str)
	ptr := C.malloc(C.size_t(unsafe.Sizeof((*int)(nil))))
	*(*uintptr)(ptr) = s
	return uintptr(ptr), func() {
		free()
		C.free(ptr)
	}
}
cString creates a pointer to a C string off the Go heap.
ret is a **char.
package gl
import "C"
import "unsafe"
const workbufLen = 3
type context struct {
	cptr  uintptr
	debug int32
	workAvailable chan struct{}
	work chan call
	retvalue chan C.uintptr_t
	cargs [workbufLen]C.struct_fnargs
	parg  [workbufLen]*C.char
}
func (ctx *context) WorkAvailable() <-chan struct{} { return ctx.workAvailable }
type context3 struct {
	*context
}
func NewContext() (Context, Worker) {
	glctx := &context{
		workAvailable: make(chan struct{}, 1),
		work:          make(chan call, workbufLen),
		retvalue:      make(chan C.uintptr_t),
	}
	if C.GLES_VERSION == "GL_ES_2_0" {
		return glctx, glctx
	}
	return context3{glctx}, glctx
}
func Version() string {
	return C.GLES_VERSION
}
func (ctx *context) enqueue(c call) uintptr {
	ctx.work <- c
	select {
	case ctx.workAvailable <- struct{}{}:
	default:
	}
	if c.blocking {
		return uintptr(<-ctx.retvalue)
	}
	return 0
}
func (ctx *context) DoWork() {
	queue := make([]call, 0, workbufLen)
	for {
		select {
		case w := <-ctx.work:
			queue = append(queue, w)
		default:
			return
		}
		blocking := queue[len(queue)-1].blocking
	enqueue:
		for len(queue) < cap(queue) && !blocking {
			select {
			case w := <-ctx.work:
				queue = append(queue, w)
				blocking = queue[len(queue)-1].blocking
			default:
				break enqueue
			}
		}
		for i, q := range queue {
			ctx.cargs[i] = *(*C.struct_fnargs)(unsafe.Pointer(&q.args))
			ctx.parg[i] = (*C.char)(q.parg)
		}
		ret := C.process(&ctx.cargs[0], ctx.parg[0], ctx.parg[1], ctx.parg[2], C.int(len(queue)))
		queue = queue[:0]
		if blocking {
			ctx.retvalue <- ret
		}
	}
}
func init() {
	if unsafe.Sizeof(C.GLint(0)) != unsafe.Sizeof(int32(0)) {
		panic("GLint is not an int32")
	}
}
func (ctx *context) cString(str string) (uintptr, func()) {
	ptr := unsafe.Pointer(C.CString(str))
	return uintptr(ptr), func() { C.free(ptr) }
}