func (state *renderState) init(eglState *platform.EGLState) error { state.eglState = eglState display := eglState.Display surface := eglState.Surface context := eglState.Context width := eglState.SurfaceWidth height := eglState.SurfaceHeight if ok := egl.MakeCurrent(display, surface, surface, context); !ok { return egl.NewError(egl.GetError()) } // Create and setup the 3D world state.world = cubelib.NewWorld(width, height) state.world.SetCamera(0.0, 0.0, 5.0) state.cube = cubelib.NewCube() if err := state.cube.AttachTextureFromFile(TEXTURE_PNG); err != nil { return err } state.world.Attach(state.cube) state.angle = 0.0 return nil }
// MakeContextCurrent bind the OpenGL context to the current thread. func (win *window) MakeContextCurrent() { if ok := egl.MakeCurrent( win.eglState.Display, win.eglState.Surface, win.eglState.Surface, win.eglState.Context); !ok { Fatalf("%s", egl.NewError(egl.GetError())) } }