ios stuff

This commit is contained in:
Vladislav Khorev 2013-01-28 09:51:30 +00:00
parent 6c7fd92820
commit 8ec1ba5e74
10 changed files with 1029 additions and 901 deletions

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,11 @@ Use global variable ResourceManager to get access to light manager
namespace SE
{
extern const int CONST_SCREEN_FRAMEBUFFER;
struct TFrame
{
cardinal FrameBuffer;

View File

@ -11,8 +11,8 @@ class TSalmonRendererIos : public TSalmonRendererGLES20
protected:
public:
virtual void SwitchToScreen();
};
} //namespace SE

View File

@ -60,4 +60,7 @@ public:
} //namespace SE
#include "include/GUIManager/WidgetTemplatesImpl.h"
#endif

View File

@ -20,5 +20,6 @@ std::string IosGetFileReadPath(const std::string& filename);
std::string IosGetFilePathUserData(const std::string& filename);
void IosSwitchToScreen();
} //namespace SE

View File

@ -5,6 +5,10 @@
namespace SE
{
const int CONST_SCREEN_FRAMEBUFFER = 0;
//===================================================
//================ FRAME MANAGER ====================
@ -23,7 +27,7 @@ void TFrameManager::FreeFrameManager()
{
ResourceManager->TexList.DeleteTexture(i.second.TexName);
glDeleteRenderbuffers(1, &(i.second.DepthRenderBuffer));
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, CONST_SCREEN_FRAMEBUFFER);
glDeleteFramebuffers(1, &(i.second.FrameBuffer));
}
@ -88,7 +92,7 @@ cardinal TFrameManager::AddFrameRenderBuffer(const std::string& frameName,cardin
FrameMap[frameName].Height = height;
FrameMap[frameName].TexName = texName;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, CONST_SCREEN_FRAMEBUFFER);
return FrameMap[frameName].FrameBuffer;
@ -97,7 +101,7 @@ cardinal TFrameManager::AddFrameRenderBuffer(const std::string& frameName,cardin
*Console<<"FrameManager::ERROR - frame buffer can not be added correctly: "+frameName+", with error: "+tostr(status);
ResourceManager->TexList.DeleteTexture(texName);
glDeleteRenderbuffers(1, &depthRenderBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, CONST_SCREEN_FRAMEBUFFER);
glDeleteFramebuffers(1, &frameBuffer);
return 0;
@ -182,7 +186,7 @@ cardinal TFrameManager::AddCubemapBuffer(const std::string& frameName,cardinal w
FrameMap[frameName].Height = height;
FrameMap[frameName].TexName = texName;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, CONST_SCREEN_FRAMEBUFFER);
return FrameMap[frameName].FrameBuffer;
@ -192,7 +196,7 @@ cardinal TFrameManager::AddCubemapBuffer(const std::string& frameName,cardinal w
*Console<<"FrameManager::ERROR - frame buffer can not be added correctly: "+frameName;
ResourceManager->TexList.DeleteTexture(texName);
glDeleteRenderbuffers(1, &depthRenderBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, CONST_SCREEN_FRAMEBUFFER);
glDeleteFramebuffers(1, &frameBuffer);
return 0;
@ -218,7 +222,7 @@ void TFrameManager::DeleteFrameRenderBuffer(const std::string& frameName)
{
ResourceManager->TexList.DeleteTexture(FrameMap[frameName].TexName);
glDeleteRenderbuffers(1, &(FrameMap[frameName].DepthRenderBuffer));
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, CONST_SCREEN_FRAMEBUFFER);
glDeleteFramebuffers(1, &(FrameMap[frameName].FrameBuffer));
FrameMap.erase(frameName);
@ -265,14 +269,14 @@ cardinal TFrameManager::AddDepthBuffer(const std::string& frameName, cardinal wi
FrameMap[frameName].Height = height;
FrameMap[frameName].TexName = texName;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, CONST_SCREEN_FRAMEBUFFER);
return FrameMap[frameName].FrameBuffer;
break;
default:
*Console<<"FrameManager::ERROR - frame buffer can not be added correctly: "+frameName;
ResourceManager->TexList.DeleteTexture(texName);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, CONST_SCREEN_FRAMEBUFFER);
glDeleteFramebuffers(1, &frameBuffer);
return 0;

View File

@ -81,11 +81,11 @@ void TSalmonRendererInterface::InitOpenGL(int screenWidth, int screenHeight, flo
MatrixHeight = matrixHeight;
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
#ifdef TARGET_WIN32
glEnable(GL_LIGHTING);
glEnable(GL_NORMALIZE);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glMaterialfv(GL_FRONT, GL_DIFFUSE, WhiteColor);
glPolygonMode(GL_FRONT_AND_BACK , GL_FILL);
@ -302,7 +302,8 @@ vec3 TSalmonRendererInterface::GetCamPos()
void TSalmonRendererInterface::SwitchToScreen()
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, CONST_SCREEN_FRAMEBUFFER);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

View File

@ -5,5 +5,12 @@
namespace SE
{
void TSalmonRendererIos::SwitchToScreen()
{
IosSwitchToScreen();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
} //namespace SE

View File

@ -20,9 +20,10 @@ void TApplication::OuterInit(int screenWidth, int screenHeight, float matrixWidt
ResourceManager->ScriptManager.BindBasicFunctions();
Renderer->InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight);
InnerInit();
Renderer->InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight);
CheckGlError();
}

View File

@ -7,10 +7,12 @@
//
#import <Foundation/Foundation.h>
#import <GLKit/GLKit.h>
#include "include/Utils/Utils.h"
GLKView* defaultView = 0; //Need to be set up by App!
namespace SE
{
@ -46,6 +48,11 @@ std::string IosGetFilePathUserData(const std::string& filename)
return std::string([[NSFileManager defaultManager] fileSystemRepresentationWithPath:file]);
}
void IosSwitchToScreen()
{
[defaultView bindDrawable];
}
} //namespace SE