OSX Build now running, although some textures will not appear and the frame buffer size is hard-coded. (Will need DXT compression for desktop).
This commit is contained in:
@@ -60,16 +60,19 @@ KRCamera::~KRCamera() {
|
|||||||
void KRCamera::renderFrame(float deltaTime)
|
void KRCamera::renderFrame(float deltaTime)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
GLint defaultFBO;
|
||||||
|
GLDEBUG(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO));
|
||||||
|
|
||||||
createBuffers();
|
createBuffers();
|
||||||
|
|
||||||
KRScene &scene = getScene();
|
KRScene &scene = getScene();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
KRMat4 viewMatrix = KRMat4::Invert(getModelMatrix());
|
KRMat4 viewMatrix = KRMat4::Invert(getModelMatrix());
|
||||||
getContext().getAudioManager()->setViewMatrix(viewMatrix); // FINDME, TODO - Should we support de-coupling the audio listener location from the camera?
|
getContext().getAudioManager()->setViewMatrix(viewMatrix); // FINDME, TODO - Should we support de-coupling the audio listener location from the camera?
|
||||||
|
|
||||||
GLint defaultFBO;
|
|
||||||
GLDEBUG(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO));
|
|
||||||
|
|
||||||
settings.setViewportSize(KRVector2(backingWidth, backingHeight));
|
settings.setViewportSize(KRVector2(backingWidth, backingHeight));
|
||||||
KRMat4 projectionMatrix;
|
KRMat4 projectionMatrix;
|
||||||
@@ -391,7 +394,6 @@ void KRCamera::renderFrame(float deltaTime)
|
|||||||
|
|
||||||
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO));
|
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO));
|
||||||
renderPost();
|
renderPost();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -402,8 +404,8 @@ void KRCamera::createBuffers() {
|
|||||||
GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &renderBufferWidth));
|
GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &renderBufferWidth));
|
||||||
GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &renderBufferHeight));
|
GLDEBUG(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &renderBufferHeight));
|
||||||
#else
|
#else
|
||||||
renderBufferWidth = 576; // FINDME - HACK for OSX
|
renderBufferWidth = 1920; // FINDME - HACK for OSX
|
||||||
renderBufferHeight = 374;
|
renderBufferHeight = 1200;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(renderBufferWidth != backingWidth || renderBufferHeight != backingHeight) {
|
if(renderBufferWidth != backingWidth || renderBufferHeight != backingHeight) {
|
||||||
@@ -476,6 +478,7 @@ void KRCamera::createBuffers() {
|
|||||||
GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, backingWidth, backingHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL));
|
GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, backingWidth, backingHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL));
|
||||||
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, lightAccumulationTexture, 0));
|
GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, lightAccumulationTexture, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
int targetVolumetricBufferWidth = 0;
|
int targetVolumetricBufferWidth = 0;
|
||||||
int targetVolumetricBufferHeight = 0;
|
int targetVolumetricBufferHeight = 0;
|
||||||
if(settings.volumetric_environment_enable && settings.volumetric_environment_downsample != 0) {
|
if(settings.volumetric_environment_enable && settings.volumetric_environment_downsample != 0) {
|
||||||
@@ -498,6 +501,7 @@ void KRCamera::createBuffers() {
|
|||||||
volumetricLightAccumulationBuffer = 0;
|
volumetricLightAccumulationBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(targetVolumetricBufferWidth != 0 && targetVolumetricBufferHeight != 0) {
|
if(targetVolumetricBufferWidth != 0 && targetVolumetricBufferHeight != 0) {
|
||||||
// ===== Create offscreen compositing framebuffer object for volumetric lighting =====
|
// ===== Create offscreen compositing framebuffer object for volumetric lighting =====
|
||||||
GLDEBUG(glGenFramebuffers(1, &volumetricLightAccumulationBuffer));
|
GLDEBUG(glGenFramebuffers(1, &volumetricLightAccumulationBuffer));
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ using namespace std;
|
|||||||
BOOL isRetina = false;
|
BOOL isRetina = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
if(isIpad && isRetina) {
|
if(isIpad && isRetina) {
|
||||||
KRContext::KRENGINE_MAX_VBO_HANDLES = 10000;
|
KRContext::KRENGINE_MAX_VBO_HANDLES = 10000;
|
||||||
KRContext::KRENGINE_MAX_VBO_MEM = 128000000 * 2;
|
KRContext::KRENGINE_MAX_VBO_MEM = 128000000 * 2;
|
||||||
@@ -94,6 +95,18 @@ using namespace std;
|
|||||||
KRContext::KRENGINE_MIN_TEXTURE_DIM = 64;
|
KRContext::KRENGINE_MIN_TEXTURE_DIM = 64;
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT = 32000000;
|
KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT = 32000000;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
KRContext::KRENGINE_MAX_VBO_HANDLES = 10000;
|
||||||
|
KRContext::KRENGINE_MAX_VBO_MEM = 256000000;
|
||||||
|
KRContext::KRENGINE_MAX_SHADER_HANDLES = 100;
|
||||||
|
KRContext::KRENGINE_MAX_TEXTURE_HANDLES = 10000;
|
||||||
|
KRContext::KRENGINE_MAX_TEXTURE_MEM = 256000000;
|
||||||
|
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX = 192000000;
|
||||||
|
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MIN = 96000000;
|
||||||
|
KRContext::KRENGINE_MAX_TEXTURE_DIM = 2048;
|
||||||
|
KRContext::KRENGINE_MIN_TEXTURE_DIM = 64;
|
||||||
|
KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT = 32000000;
|
||||||
|
#endif
|
||||||
|
|
||||||
_context = NULL;
|
_context = NULL;
|
||||||
if ((self = [super init])) {
|
if ((self = [super init])) {
|
||||||
@@ -168,12 +181,13 @@ using namespace std;
|
|||||||
- (BOOL)loadShaders
|
- (BOOL)loadShaders
|
||||||
{
|
{
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
NSString *bundleName = @"kraken_standard_assets_ios.bundle";
|
NSString *bundleName = @"kraken_standard_assets_ios";
|
||||||
#else
|
#else
|
||||||
NSString *bundleName = @"kraken_standard_assets_osx.bundle";
|
NSString *bundleName = @"kraken_standard_assets_osx";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NSString *bundlePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:bundleName];
|
// NSString *bundlePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:bundleName];
|
||||||
|
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:bundleName ofType:@"bundle"];
|
||||||
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
|
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
|
||||||
if(bundle == nil) {
|
if(bundle == nil) {
|
||||||
NSLog(@"ERROR - Standard asset bundle could not be found.");
|
NSLog(@"ERROR - Standard asset bundle could not be found.");
|
||||||
|
|||||||
@@ -259,7 +259,11 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRLight *> &lights, const KR
|
|||||||
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, lights, 0, viewport, occlusion_test_sphere_matrix, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass)) {
|
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, lights, 0, viewport, occlusion_test_sphere_matrix, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass)) {
|
||||||
|
|
||||||
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
GLDEBUG(glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, m_occlusionQuery));
|
GLDEBUG(glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, m_occlusionQuery));
|
||||||
|
#else
|
||||||
|
GLDEBUG(glBeginQuery(GL_SAMPLES_PASSED, m_occlusionQuery));
|
||||||
|
#endif
|
||||||
|
|
||||||
std::vector<KRMesh *> sphereModels = getContext().getModelManager()->getModel("__sphere");
|
std::vector<KRMesh *> sphereModels = getContext().getModelManager()->getModel("__sphere");
|
||||||
if(sphereModels.size()) {
|
if(sphereModels.size()) {
|
||||||
@@ -268,7 +272,11 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRLight *> &lights, const KR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
GLDEBUG(glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT));
|
GLDEBUG(glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT));
|
||||||
|
#else
|
||||||
|
GLDEBUG(glEndQuery(GL_SAMPLES_PASSED));
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,11 @@ void KROctreeNode::beginOcclusionQuery()
|
|||||||
{
|
{
|
||||||
if(!m_occlusionTested){
|
if(!m_occlusionTested){
|
||||||
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
GLDEBUG(glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, m_occlusionQuery));
|
GLDEBUG(glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, m_occlusionQuery));
|
||||||
|
#else
|
||||||
|
GLDEBUG(glBeginQuery(GL_SAMPLES_PASSED, m_occlusionQuery));
|
||||||
|
#endif
|
||||||
m_occlusionTested = true;
|
m_occlusionTested = true;
|
||||||
m_activeQuery = true;
|
m_activeQuery = true;
|
||||||
}
|
}
|
||||||
@@ -58,7 +62,11 @@ void KROctreeNode::endOcclusionQuery()
|
|||||||
{
|
{
|
||||||
if(m_activeQuery) {
|
if(m_activeQuery) {
|
||||||
// Only end a query if we started one
|
// Only end a query if we started one
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
GLDEBUG(glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT));
|
GLDEBUG(glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT));
|
||||||
|
#else
|
||||||
|
GLDEBUG(glEndQuery(GL_SAMPLES_PASSED));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#extension GL_EXT_shadow_samplers : require
|
//#extension GL_EXT_shadow_samplers : require
|
||||||
|
|
||||||
#if FOG_TYPE > 0
|
#if FOG_TYPE > 0
|
||||||
// FOG_TYPE 1 - Linear
|
// FOG_TYPE 1 - Linear
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#extension GL_EXT_shadow_samplers : require
|
//#extension GL_EXT_shadow_samplers : require
|
||||||
|
|
||||||
varying mediump vec2 texCoord;
|
varying mediump vec2 texCoord;
|
||||||
|
|
||||||
@@ -39,5 +39,5 @@ uniform mediump vec3 light_color;
|
|||||||
varying lowp float intensity_modulate;
|
varying lowp float intensity_modulate;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_FragColor = vec4(light_color, 1.0) * shadow2DProjEXT(shadowTexture1, shadowMapCoord1) * max(1.0 - texCoord.x*texCoord.x-texCoord.y*texCoord.y, 0.0) * intensity_modulate;
|
gl_FragColor = vec4(light_color, 1.0) * shadow2DProj(shadowTexture1, shadowMapCoord1) * max(1.0 - texCoord.x*texCoord.x-texCoord.y*texCoord.y, 0.0) * intensity_modulate;
|
||||||
}
|
}
|
||||||
@@ -25,8 +25,6 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#extension GL_EXT_shadow_samplers : require
|
|
||||||
|
|
||||||
varying mediump vec4 shadowMapCoord1;
|
varying mediump vec4 shadowMapCoord1;
|
||||||
uniform sampler2DShadow shadowTexture1;
|
uniform sampler2DShadow shadowTexture1;
|
||||||
uniform lowp sampler2D depthFrame;
|
uniform lowp sampler2D depthFrame;
|
||||||
@@ -37,5 +35,5 @@ void main()
|
|||||||
{
|
{
|
||||||
if(gl_FragCoord.z > texture2D(depthFrame, vec2(gl_FragCoord.xy / viewport.zw)).r) discard;
|
if(gl_FragCoord.z > texture2D(depthFrame, vec2(gl_FragCoord.xy / viewport.zw)).r) discard;
|
||||||
|
|
||||||
gl_FragColor = vec4(light_color, 1.0) * shadow2DProjEXT(shadowTexture1, shadowMapCoord1);
|
gl_FragColor = vec4(light_color, 1.0) * shadow2DProj(shadowTexture1, shadowMapCoord1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,13 +25,11 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#extension GL_EXT_shadow_samplers : require
|
|
||||||
|
|
||||||
varying mediump vec4 shadowMapCoord1;
|
varying mediump vec4 shadowMapCoord1;
|
||||||
uniform sampler2DShadow shadowTexture1;
|
uniform sampler2DShadow shadowTexture1;
|
||||||
uniform mediump vec3 light_color;
|
uniform mediump vec3 light_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_FragColor = vec4(light_color, 1.0) * shadow2DProjEXT(shadowTexture1, shadowMapCoord1);
|
gl_FragColor = vec4(light_color, 1.0) * shadow2DProj(shadowTexture1, shadowMapCoord1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user