Esempio n. 1
0
func CreateContext(disp Display, config Config,
	shareContext Context, attribList *int32) Context {

	return Context(C.eglCreateContext(C.EGLDisplay(unsafe.Pointer(disp)),
		C.EGLConfig(unsafe.Pointer(config)),
		C.EGLContext(unsafe.Pointer(shareContext)),
		(*C.EGLint)(attribList)))
}
Esempio n. 2
0
func (display *Display) CreateContext(config Config, shareContext *Context, attribList []Attrib) (*Context, error) {
	var eglShareContext C.EGLContext
	if shareContext != nil {
		eglShareContext = shareContext.eglContext
	}

	var eglAttribs *C.EGLint
	if attribList != nil {
		eglAttribs = (*C.EGLint)(&(attribList[0]))
	}

	eglContext := C.eglCreateContext(display.eglDisplay, C.EGLConfig(config), eglShareContext, eglAttribs)
	if eglContext == noContext {
		return nil, getError()
	}

	context := new(Context)
	//runtime.SetFinalizer(context, destroyContext)
	context.eglContext = eglContext
	context.Display = display
	return context, nil
}