Cleanup context handling and IOS API
This commit is contained in:
@@ -95,7 +95,7 @@ const std::string KRCamera::getSkyBox() const
|
||||
return m_skyBox;
|
||||
}
|
||||
|
||||
void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint renderBufferHeight)
|
||||
void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint renderBufferHeight)
|
||||
{
|
||||
// ----====---- Record timing information for measuring FPS ----====----
|
||||
uint64_t current_time = m_pContext->getAbsoluteTimeMilliseconds();
|
||||
@@ -104,9 +104,6 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
|
||||
if(m_frame_times_filled < KRAKEN_FPS_AVERAGE_FRAME_COUNT) m_frame_times_filled++;
|
||||
}
|
||||
m_last_frame_start = current_time;
|
||||
|
||||
GLint defaultFBO = -1;
|
||||
GLDEBUG(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO));
|
||||
|
||||
createBuffers(renderBufferWidth, renderBufferHeight);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
KRCamera(KRScene &scene, std::string name);
|
||||
virtual ~KRCamera();
|
||||
|
||||
void renderFrame(float deltaTime, GLint renderBufferWidth, GLint renderBufferHeight);
|
||||
void renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint renderBufferHeight);
|
||||
|
||||
KRRenderSettings settings;
|
||||
|
||||
|
||||
@@ -15,26 +15,29 @@ EAGLContext *gRenderContext = nil;
|
||||
|
||||
void KRContext::destroyDeviceContexts()
|
||||
{
|
||||
[gStreamerContext release];
|
||||
[gRenderContext release];
|
||||
}
|
||||
|
||||
void KRContext::createDeviceContexts()
|
||||
{
|
||||
gRenderContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
gStreamerContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup: gStreamerContext.sharegroup];
|
||||
|
||||
// FIXME: need to add code check for iOS 7 and also this appears to cause crashing
|
||||
|
||||
//gTextureStreamerContext.multiThreaded = TRUE;
|
||||
if(!gRenderContext) {
|
||||
gRenderContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
gStreamerContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup: gRenderContext.sharegroup];
|
||||
|
||||
// FIXME: need to add code check for iOS 7 and also this appears to cause crashing
|
||||
|
||||
//gTextureStreamerContext.multiThreaded = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void KRContext::activateStreamerContext()
|
||||
{
|
||||
createDeviceContexts();
|
||||
[EAGLContext setCurrentContext: gStreamerContext];
|
||||
}
|
||||
|
||||
void KRContext::activateRenderContext()
|
||||
{
|
||||
createDeviceContexts();
|
||||
[EAGLContext setCurrentContext: gRenderContext];
|
||||
}
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ namespace kraken {
|
||||
-(void)setParameterValueWithName: (NSString *)name Value: (float)v;
|
||||
-(int)getParameterIndexWithName: (NSString *)name;
|
||||
|
||||
- (void)renderScene: (KRScene *)pScene WithDeltaTime: (float)deltaTime AndWidth: (int)width AndHeight: (int)height;
|
||||
- (void)renderScene: (KRScene *)pScene WithDeltaTime: (float)deltaTime;
|
||||
- (void)renderScene: (KRScene *)pScene WithDeltaTime: (float)deltaTime AndWidth: (int)width AndHeight: (int)height AndDefaultFBO: (GLint)defaultFBO;
|
||||
//- (void)renderScene: (KRScene *)pScene WithDeltaTime: (float)deltaTime;
|
||||
- (void)setNearZ: (float)dNearZ;
|
||||
- (void)setFarZ: (float)dFarZ;
|
||||
|
||||
|
||||
@@ -193,15 +193,16 @@ void kraken::set_debug_text(const std::string &print_text)
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)renderScene: (KRScene *)pScene WithDeltaTime: (float)deltaTime AndWidth: (int)width AndHeight: (int)height
|
||||
- (void)renderScene: (KRScene *)pScene WithDeltaTime: (float)deltaTime AndWidth: (int)width AndHeight: (int)height AndDefaultFBO: (GLint)defaultFBO
|
||||
{
|
||||
KRCamera *camera = pScene->find<KRCamera>("default_camera");
|
||||
if(camera) {
|
||||
camera->settings = _settings;
|
||||
}
|
||||
pScene->renderFrame(deltaTime, width, height);
|
||||
pScene->renderFrame(defaultFBO, deltaTime, width, height);
|
||||
}
|
||||
|
||||
/*
|
||||
- (void)renderScene: (KRScene *)pScene WithDeltaTime: (float)deltaTime
|
||||
{
|
||||
GLint renderBufferWidth = 0, renderBufferHeight = 0;
|
||||
@@ -209,6 +210,7 @@ void kraken::set_debug_text(const std::string &print_text)
|
||||
GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &renderBufferHeight));
|
||||
[self renderScene:pScene WithDeltaTime:deltaTime AndWidth:renderBufferWidth AndHeight:renderBufferHeight];
|
||||
}
|
||||
*/
|
||||
|
||||
- (BOOL)loadShaders
|
||||
{
|
||||
@@ -250,11 +252,10 @@ void kraken::set_debug_text(const std::string &print_text)
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_parameter_names release]; _parameter_names = nil;
|
||||
_parameter_names = nil;
|
||||
if(_context) {
|
||||
delete _context; _context = NULL;
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(int)getParameterCount
|
||||
@@ -721,9 +722,7 @@ void kraken::set_debug_text(const std::string &print_text)
|
||||
|
||||
- (void)setDebug_text:(NSString *)value
|
||||
{
|
||||
[_debug_text release];
|
||||
_debug_text = value;
|
||||
[_debug_text retain];
|
||||
|
||||
_settings.m_debug_text = value.UTF8String;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ KRScene::~KRScene() {
|
||||
m_pRootNode = NULL;
|
||||
}
|
||||
|
||||
void KRScene::renderFrame(float deltaTime, int width, int height) {
|
||||
void KRScene::renderFrame(GLint defaultFBO, float deltaTime, int width, int height) {
|
||||
getContext().startFrame(deltaTime);
|
||||
KRCamera *camera = find<KRCamera>("default_camera");
|
||||
if(camera == NULL) {
|
||||
@@ -73,7 +73,7 @@ void KRScene::renderFrame(float deltaTime, int width, int height) {
|
||||
getContext().getAudioManager()->setReverbMaxLength(camera->settings.siren_reverb_max_length);
|
||||
getContext().getTextureManager()->setMaxAnisotropy(camera->settings.max_anisotropy);
|
||||
|
||||
camera->renderFrame(deltaTime, width, height);
|
||||
camera->renderFrame(defaultFBO, width, height);
|
||||
getContext().endFrame(deltaTime);
|
||||
physicsUpdate(deltaTime);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
bool rayCast(const KRVector3 &v0, const KRVector3 &dir, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool sphereCast(const KRVector3 &v0, const KRVector3 &v1, float radius, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
|
||||
void renderFrame(float deltaTime, int width, int height);
|
||||
void renderFrame(GLint defaultFBO, float deltaTime, int width, int height);
|
||||
void render(KRCamera *pCamera, unordered_map<KRAABB, int> &visibleBounds, const KRViewport &viewport, KRNode::RenderPass renderPass, bool new_frame);
|
||||
|
||||
void render(KROctreeNode *pOctreeNode, unordered_map<KRAABB, int> &visibleBounds, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass, std::vector<KROctreeNode *> &remainingOctrees, std::vector<KROctreeNode *> &remainingOctreesTestResults, std::vector<KROctreeNode *> &remainingOctreesTestResultsOnly, bool bOcclusionResultsPass, bool bOcclusionTestResultsOnly);
|
||||
|
||||
Reference in New Issue
Block a user