From 9cf91d6332b98919b3b4e89015bc8c30aa7fd771 Mon Sep 17 00:00:00 2001 From: Kearwood Gilbert Date: Sun, 5 Nov 2017 23:41:22 -0800 Subject: [PATCH] More CMake conversion, compile fixes --- CMakeLists.txt | 6 ++-- kraken/CMakeLists.txt | 54 ++++++++++++++++++++++++++++++++- kraken/KREngine.h | 2 -- kraken/KREngine.mm | 10 +++---- kraken/KRMesh.cpp | 6 ---- kraken/KRMeshStreamer.h | 60 +++++++++++++++++++++++++++++++++++++ kraken/KRMeshStreamer.mm | 1 + kraken/KRNode.cpp | 4 +++ kraken/KROctree.cpp | 2 +- kraken/KRResource+obj.cpp | 3 +- kraken/KRTextureStreamer.h | 60 +++++++++++++++++++++++++++++++++++++ kraken/KRTextureStreamer.mm | 1 + 12 files changed, 191 insertions(+), 18 deletions(-) create mode 100644 kraken/KRMeshStreamer.h create mode 100644 kraken/KRTextureStreamer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4572f9c..06e9ccc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,10 +48,12 @@ IF(APPLE) FIND_LIBRARY(APPKIT_LIBRARY AppKit) FIND_LIBRARY(OPENGL_LIBRARY OpenGL) FIND_LIBRARY(AUDIO_TOOLBOX_LIBRARY AudioToolbox) + FIND_LIBRARY(ACCELERATE_LIBRARY Accelerate) MARK_AS_ADVANCED (APPKIT_LIBRARY OPENGL_LIBRARY - AUDIO_TOOLBOX_LIBRARY) - SET(EXTRA_LIBS ${APPKIT_LIBRARY} ${OPENGL_LIBRARY} ${AUDIO_TOOLBOX_LIBRARY}) + AUDIO_TOOLBOX_LIBRARY + ACCELERATE_LIBRARY) + SET(EXTRA_LIBS ${APPKIT_LIBRARY} ${OPENGL_LIBRARY} ${AUDIO_TOOLBOX_LIBRARY} ${ACCELERATE_LIBRARY}) FIND_PATH(COCOA_INCLUDE_DIR OpenGL/gl3.h) ENDIF (APPLE) diff --git a/kraken/CMakeLists.txt b/kraken/CMakeLists.txt index b1dcd34..b1c1f38 100644 --- a/kraken/CMakeLists.txt +++ b/kraken/CMakeLists.txt @@ -25,7 +25,6 @@ add_sources(KRAudioManager.cpp) add_sources(KRAudioSample.cpp) add_sources(KRAudioSource.cpp) add_sources(KRBehavior.cpp) -add_sources(KRDataBlock.cpp) add_sources(KRBone.cpp) add_sources(KRBundle.cpp) add_sources(KRBundleManager.cpp) @@ -33,9 +32,62 @@ add_sources(KRCamera.cpp) add_sources(KRCollider.cpp) add_sources(KRContext.cpp) IF(APPLE) + add_sources(KREngine.mm) + add_sources(KRStreamer.mm) + add_sources(KRMeshStreamer.mm) + add_sources(KRTextureStreamer.mm) IF(IOS) add_sources(KRContext_ios.mm) ELSE() add_sources(KRContext_osx.mm) ENDIF() ENDIF (APPLE) +add_sources(KRContextObject.cpp) +add_sources(KRDataBlock.cpp) +add_sources(KRDirectionalLight.cpp) +IF(APPLE) + add_sources(KRDSP_vDSP.cpp) +ELSE() + add_sources(KRDSP_slow.cpp) +ENDIF() +add_sources(KRHelpers.cpp) +add_sources(KRLight.cpp) +add_sources(KRLocator.cpp) +add_sources(KRLODGroup.cpp) +add_sources(KRLODSet.cpp) +add_sources(KRMaterial.cpp) +add_sources(KRMaterialManager.cpp) +add_sources(KRMesh.cpp) +add_sources(KRMeshCube.cpp) +add_sources(KRMeshManager.cpp) +add_sources(KRMeshQuad.cpp) +add_sources(KRMeshSphere.cpp) +add_sources(KRModel.cpp) +add_sources(KRNode.cpp) +add_sources(KROctree.cpp) +add_sources(KROctreeNode.cpp) +add_sources(KRParticleSystem.cpp) +add_sources(KRParticleSystemNewtonian.h) +add_sources(KRPointLight.cpp) +add_sources(KRRenderSettings.cpp) +add_sources(KRResource+blend.cpp) +# add_sources(KRResource+fbx.cpp) # TODO - Locate FBX SDK dependencies +add_sources(KRResource+obj.cpp) +add_sources(KRResource.cpp) +add_sources(KRReverbZone.cpp) +add_sources(KRScene.cpp) +add_sources(KRShader.cpp) +add_sources(KRShaderManager.cpp) +add_sources(KRSpotLight.cpp) +add_sources(KRSprite.cpp) +add_sources(KRTexture.cpp) +add_sources(KRTexture2D.cpp) +add_sources(KRTextureAnimated.cpp) +add_sources(KRTextureCube.cpp) +add_sources(KRTextureKTX.cpp) +add_sources(KRTextureManager.cpp) +add_sources(KRTexturePVR.cpp) +add_sources(KRTextureTGA.cpp) +add_sources(KRUnknown.cpp) +add_sources(KRUnknownManager.cpp) +add_sources(KRViewport.cpp) diff --git a/kraken/KREngine.h b/kraken/KREngine.h index 1fa71fd..ca81c56 100755 --- a/kraken/KREngine.h +++ b/kraken/KREngine.h @@ -30,8 +30,6 @@ // // #include "KRTextureManager.h" -#include "Matrix4.h" -#include "Vector3.h" #include "KRMesh.h" #include "KRScene.h" #include "KRContext.h" diff --git a/kraken/KREngine.mm b/kraken/KREngine.mm index c0523a9..e49f2f1 100755 --- a/kraken/KREngine.mm +++ b/kraken/KREngine.mm @@ -32,7 +32,6 @@ #include "KREngine-common.h" #include "KREngine.h" -#include "KRVector3.h" #include "KRScene.h" #include "KRSceneManager.h" #include "KRNode.h" @@ -256,6 +255,7 @@ void kraken::set_debug_text(const std::string &print_text) if(_context) { delete _context; _context = NULL; } + [super dealloc]; } -(int)getParameterCount @@ -732,7 +732,7 @@ void kraken::set_debug_text(const std::string &print_text) -(void) setSunTemperature:(float)t { float i = [self getSunIntensity]; - _settings.light_intensity = KRVector3( + _settings.light_intensity = Vector3( (t < 0.5f ? t * 2.0f : 1.0f) * i, (t < 0.5f ? t * 2.0f : (1.0f - t) * 2.0f) * i, (t < 0.5f ? 1.0f : (1.0f - t) * 2.0f) * i @@ -742,7 +742,7 @@ void kraken::set_debug_text(const std::string &print_text) -(void) setSunIntensity:(float)i { float t = [self getSunTemperature]; - _settings.light_intensity = KRVector3( + _settings.light_intensity = Vector3( (t < 0.5f ? t * 2.0f : 1.0f) * i, (t < 0.5f ? t * 2.0f : (1.0f - t) * 2.0f) * i, (t < 0.5f ? 1.0f : (1.0f - t) * 2.0f) * i @@ -778,7 +778,7 @@ void kraken::set_debug_text(const std::string &print_text) -(void) setAmbientTemperature:(float)t { float i = [self getAmbientIntensity]; - _settings.ambient_intensity = KRVector3( + _settings.ambient_intensity = Vector3( (t < 0.5f ? t * 2.0f : 1.0f) * i, (t < 0.5f ? t * 2.0f : (1.0f - t) * 2.0f) * i, (t < 0.5f ? 1.0f : (1.0f - t) * 2.0f) * i @@ -788,7 +788,7 @@ void kraken::set_debug_text(const std::string &print_text) -(void) setAmbientIntensity:(float)i { float t = [self getAmbientTemperature]; - _settings.ambient_intensity = KRVector3( + _settings.ambient_intensity = Vector3( (t < 0.5f ? t * 2.0f : 1.0f) * i, (t < 0.5f ? t * 2.0f : (1.0f - t) * 2.0f) * i, (t < 0.5f ? 1.0f : (1.0f - t) * 2.0f) * i diff --git a/kraken/KRMesh.cpp b/kraken/KRMesh.cpp index 3ba28bc..6b83209 100755 --- a/kraken/KRMesh.cpp +++ b/kraken/KRMesh.cpp @@ -37,12 +37,7 @@ #include "KRShader.h" #include "KRShaderManager.h" #include "KRContext.h" -#if defined(_WIN32) || defined(_WIN64) #include "../3rdparty/forsyth/forsyth.h" -#else -#include "forsyth.h" -#endif - KRMesh::KRMesh(KRContext &context, std::string name) : KRResource(context, name) { setName(name); @@ -52,7 +47,6 @@ KRMesh::KRMesh(KRContext &context, std::string name) : KRResource(context, name) m_pMetaData = NULL; m_pIndexBaseData = NULL; m_constant = false; - } KRMesh::KRMesh(KRContext &context, std::string name, KRDataBlock *data) : KRResource(context, name) { diff --git a/kraken/KRMeshStreamer.h b/kraken/KRMeshStreamer.h new file mode 100644 index 0000000..beb3666 --- /dev/null +++ b/kraken/KRMeshStreamer.h @@ -0,0 +1,60 @@ +// +// KRMeshManager.h +// KREngine +// +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + +#ifndef KRMESHSTREAMER_H +#define KRMESHSTREAMER_H + +#include "KREngine-common.h" + +#include +#include + +class KRContext; + +class KRMeshStreamer +{ +public: + KRMeshStreamer(KRContext &context); + ~KRMeshStreamer(); + + void startStreamer(); + +private: + KRContext &m_context; + + std::thread m_thread; + std::atomic m_stop; + std::atomic m_running; + + void run(); +}; + +#endif /* defined(KRMESHSTREAMER_H) */ diff --git a/kraken/KRMeshStreamer.mm b/kraken/KRMeshStreamer.mm index 82f101c..30dd46c 100755 --- a/kraken/KRMeshStreamer.mm +++ b/kraken/KRMeshStreamer.mm @@ -12,6 +12,7 @@ #include "KRContext.h" #include +#include #if TARGET_OS_IPHONE diff --git a/kraken/KRNode.cpp b/kraken/KRNode.cpp index c43545d..6a5fe1a 100755 --- a/kraken/KRNode.cpp +++ b/kraken/KRNode.cpp @@ -850,6 +850,10 @@ void KRNode::SetAttribute(node_attribute_type attrib, float v) case KRENGINE_NODE_SCALE_OFFSET_Z: setScalingOffset(Vector3(m_scalingOffset.x, m_scalingOffset.y, v)); break; + case KRENGINE_NODE_ATTRIBUTE_NONE: + case KRENGINE_NODE_ATTRIBUTE_COUNT: + // Suppress warnings + break; } } diff --git a/kraken/KROctree.cpp b/kraken/KROctree.cpp index 8d0c65b..4451435 100755 --- a/kraken/KROctree.cpp +++ b/kraken/KROctree.cpp @@ -6,9 +6,9 @@ // Copyright (c) 2012 Kearwood Software. All rights reserved. // +#include "public/kraken.h" #include "KROctree.h" #include "KRNode.h" -#include "HitInfo.h" #include "KRCollider.h" KROctree::KROctree() diff --git a/kraken/KRResource+obj.cpp b/kraken/KRResource+obj.cpp index e044b44..b1473ae 100755 --- a/kraken/KRResource+obj.cpp +++ b/kraken/KRResource+obj.cpp @@ -246,7 +246,8 @@ std::vector KRResource::LoadObj(KRContext &context, const std::str while(*pFace != 0 && iVertex < cVertexData) { pMaterial->start_vertex = iVertex; - int *pMaterialEndFace = pFace + *pFace++; + int *pMaterialEndFace = pFace + *pFace; + ++pFace; while(pFace < pMaterialEndFace && iVertex < cVertexData) { int cFaceVertexes = *pFace; Vector3 firstFaceVertex; diff --git a/kraken/KRTextureStreamer.h b/kraken/KRTextureStreamer.h new file mode 100644 index 0000000..39f3705 --- /dev/null +++ b/kraken/KRTextureStreamer.h @@ -0,0 +1,60 @@ +// +// KRTextureManager.h +// KREngine +// +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + +#ifndef KRTEXTURESTREAMER_H +#define KRTEXTURESTREAMER_H + +#include "KREngine-common.h" + +#include +#include + +class KRContext; + +class KRTextureStreamer +{ +public: + KRTextureStreamer(KRContext &context); + ~KRTextureStreamer(); + + void startStreamer(); + +private: + KRContext &m_context; + + std::thread m_thread; + std::atomic m_stop; + std::atomic m_running; + + void run(); +}; + +#endif /* defined(KRTEXTURESTREAMER_H) */ diff --git a/kraken/KRTextureStreamer.mm b/kraken/KRTextureStreamer.mm index 4aa1230..8fd497f 100755 --- a/kraken/KRTextureStreamer.mm +++ b/kraken/KRTextureStreamer.mm @@ -12,6 +12,7 @@ #include "KRContext.h" #include +#include #if TARGET_OS_IPHONE