コード例 #1
0
// 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
}
コード例 #2
0
// 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
}
コード例 #3
0
// 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
}
コード例 #4
0
// 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
}
コード例 #5
0
// 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
}
コード例 #6
0
ファイル: opengl_windows.go プロジェクト: sixteng/goGLPro
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
}