|
|
|
|
|
|
gl_resource = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:gl]; |
|
|
|
|
|
|
|
if (gl_resource == nil) { |
|
|
|
CGLReleaseContext(gl.CGLContextObj); |
|
|
|
CGLReleaseContext([gl CGLContextObj]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gl_context_pool_.push_back(GLContextPair(gl, gl_resource)); |
|
|
|
return GLContextPair(gl, gl_resource); |
|
|
|
} |
|
|
|
|
|
|
|
auto context_pair = gl_context_pool_.back(); |
|
|
|
|
|
|
ClearCurrentContext(); |
|
|
|
|
|
|
|
gl_context_pool_.push_back(GLContextPair(gl, gl_resource)); |
|
|
|
} |
|
|
|
|
|
|
|
void UnitySurfaceManager::ReleaseResource() |
|
|
|
{ |
|
|
|
while(gl_context_pool_.size() > 0) |
|
|
|
{ |
|
|
|
auto context_pair = gl_context_pool_.back(); |
|
|
|
CGLReleaseContext([context_pair.gl_context_ CGLContextObj]); |
|
|
|
CGLReleaseContext([context_pair.gl_resource_context_ CGLContextObj]); |
|
|
|
gl_context_pool_.pop_back(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
UnitySurfaceManager::UnitySurfaceManager(IUnityInterfaces* unity_interfaces) |
|
|
|