コード例 #1
0
ファイル: android.go プロジェクト: remogatto/egl
func Initialize(win unsafe.Pointer, configAttr, contextAttr []int32) *platform.EGLState {
	eglState := new(platform.EGLState)
	eglState.Display = getEGLDisp(egl.DEFAULT_DISPLAY)
	eglState.Config = chooseEGLConfig(eglState.Display, configAttr)
	eglState.VisualId = getEGLNativeVisualId(eglState.Display, eglState.Config)
	C.ANativeWindow_setBuffersGeometry((*[0]byte)(win), 0, 0, C.int32_t(eglState.VisualId))
	eglState.Surface = EGLCreateWindowSurface(eglState.Display, eglState.Config, egl.NativeWindowType(win))

	egl.BindAPI(egl.OPENGL_ES_API)
	eglState.Context = egl.CreateContext(eglState.Display, eglState.Config, egl.NO_CONTEXT, &contextAttr[0])

	eglState.SurfaceWidth = int(C.ANativeWindow_getWidth((*C.ANativeWindow)(win)))
	eglState.SurfaceHeight = int(C.ANativeWindow_getHeight((*C.ANativeWindow)(win)))

	return eglState
}
コード例 #2
0
ファイル: main.go プロジェクト: remogatto/goandroid
//export onNativeWindowCreated
func onNativeWindowCreated(act *C.ANativeActivity, win unsafe.Pointer) {
	defer func() {
		handleCallbackError(act, recover())
	}()
	log.Printf("onNativeWindowCreated...\n")
	state := states[act]
	if state.renderState == nil {
		state.renderState = &renderState{
			disp: getEGLDisp(egl.NativeDisplayType(nil)),
		}
		state.renderState.conf = chooseEGLConfig(state.renderState.disp)
	}
	vid := getEGLNativeVisualId(state.renderState.disp, state.renderState.conf)
	C.ANativeWindow_setBuffersGeometry((*[0]byte)(win), 0, 0, C.int32_t(vid))
	state.renderState.surf = EGLCreateWindowSurface(state.renderState.disp, state.renderState.conf, egl.NativeWindowType(win))

	state.mLoop.UpdateRenderState(state.renderState)
	log.Printf("onNativeWindowCreated done\n")
}