Ejemplo n.º 1
0
func (ic *contextInternal) close() ThreadError {
	// start by waiting for deactivation to finish
	<-ic.deactivateSignal

	// Destroy the OpenGL context
	if ic.context != nil {
		C.wglDeleteContext(ic.context)
	}

	// Destroy the device context
	if ic.hdc != nil {
		C.ReleaseDC(ic.window, ic.hdc)
	}

	// Destroy the window if we own it
	if ic.window != nil && ic.ownsWindow {
		C.DestroyWindow(ic.window)
	}

	return nil
}
Ejemplo n.º 2
0
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
}