// Temporary deactivate the context func (ic *contextInternal) release() ThreadError { // disable the current context if C.wglMakeCurrent(ic.hdc, nil) == C.FALSE { return NewThreadError(fmt.Errorf("wglMakeCurrent failed (%d)", C.GetLastError()), true) } return nil }
// Temporary activate the context func (ic *contextInternal) take() ThreadError { // start up the context if C.wglMakeCurrent(ic.hdc, ic.context) == C.FALSE { return NewThreadError(fmt.Errorf("wglMakeCurrent failed (%d)", C.GetLastError()), true) } return nil }
// Deactivate, signal, wait for response, activate func (ic *contextInternal) pause(signal chan bool) ThreadError { // disable the current context if C.wglMakeCurrent(ic.hdc, nil) == C.FALSE { return NewThreadError(fmt.Errorf("wglMakeCurrent failed (%d)", C.GetLastError()), true) } // let the other thread know and then wait for them signal <- true <-signal // start up the context if C.wglMakeCurrent(ic.hdc, ic.context) == C.FALSE { return NewThreadError(fmt.Errorf("wglMakeCurrent failed (%d)", C.GetLastError()), true) } return nil }
// Deactivate the context as the current target for rendering func (ic *contextInternal) deactivate() ThreadError { // disable the current context if C.wglMakeCurrent(ic.hdc, nil) == C.FALSE { return NewThreadError(fmt.Errorf("wglMakeCurrent failed (%d)", C.GetLastError()), true) } // end by signaling ic.signalDeactivation() return nil }
// Activate the context as the current target for rendering func (ic *contextInternal) activate() ThreadError { // start by waiting for deactivation to finish <-ic.deactivateSignal // start up the context if C.wglMakeCurrent(ic.hdc, ic.context) == C.FALSE { return NewThreadError(fmt.Errorf("wglMakeCurrent failed (%d)", C.GetLastError()), true) } // Load all the functions and such C.wglLoadProcs(&ic.procs) return nil }
func CreateContext(win window.Window) C.HGLRC { hdc := win.GetHDC() if hdc == nil { //TODO: Handle error somehow ??? return nil } tmpContext := C.wglCreateContext(*(*C.HDC)(hdc)) C.wglMakeCurrent(*(*C.HDC)(hdc), tmpContext) C.glewInit() var context C.HGLRC if C.wglewIsSupported(C.CString("WGL_ARB_create_context")) == 1 { //TODO: Figure out how to send attr to c func so it works!!! context = C.openglCreateContextAttribsARB(*(*C.HDC)(hdc), nil) C.wglMakeCurrent(nil, nil) C.wglDeleteContext(tmpContext) C.wglMakeCurrent(*(*C.HDC)(hdc), context) } return tmpContext }