diff --git a/KREngine/kraken/KRMeshStreamer.h b/KREngine/kraken/KRMeshStreamer.h deleted file mode 100644 index beb3666..0000000 --- a/KREngine/kraken/KRMeshStreamer.h +++ /dev/null @@ -1,60 +0,0 @@ -// -// 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/KREngine/kraken/KRMeshStreamer.mm b/KREngine/kraken/KRMeshStreamer.mm deleted file mode 100644 index 96e2a7b..0000000 --- a/KREngine/kraken/KRMeshStreamer.mm +++ /dev/null @@ -1,93 +0,0 @@ -// -// KRMeshStreamer.cpp -// Kraken -// -// Created by Kearwood Gilbert on 11/1/2013. -// Copyright (c) 2013 Kearwood Software. All rights reserved. -// - -#include "KRMeshStreamer.h" - -#include "KREngine-common.h" -#include "KRContext.h" - -#include - -#if TARGET_OS_IPHONE - -EAGLContext *gMeshStreamerContext = nil; - -#elif TARGET_OS_MAC - -NSOpenGLContext *gMeshStreamerContext = nil; - -#else - -#error Unsupported Platform -#endif - -KRMeshStreamer::KRMeshStreamer(KRContext &context) : m_context(context) -{ - m_running = false; - m_stop = false; -} - -void KRMeshStreamer::startStreamer() -{ - if(!m_running) { - m_running = true; - -#if TARGET_OS_IPHONE - // FIXME: need to add code check for iOS 7 and also this appears to cause crashing - gMeshStreamerContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup: [EAGLContext currentContext].sharegroup]; - //gMeshStreamerContext.multiThreaded = TRUE; -#elif TARGET_OS_MAC - NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = - { -// NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy, - 0 - }; - NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes] autorelease]; - gMeshStreamerContext = [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: [NSOpenGLContext currentContext] ]; -#else - #error Unsupported Platform -#endif - - m_thread = std::thread(&KRMeshStreamer::run, this); - } -} - -KRMeshStreamer::~KRMeshStreamer() -{ - if(m_running) { - m_stop = true; - m_thread.join(); - m_running = false; - } - - [gMeshStreamerContext release]; -} - -void KRMeshStreamer::run() -{ - pthread_setname_np("Kraken - Mesh Streamer"); - - std::chrono::microseconds sleep_duration( 100 ); - -#if TARGET_OS_IPHONE - [EAGLContext setCurrentContext: gMeshStreamerContext]; -#elif TARGET_OS_MAC - [gMeshStreamerContext makeCurrentContext]; -#else - #error Unsupported Platform -#endif - - - while(!m_stop) - { - if(m_context.getStreamingEnabled()) { - - } - std::this_thread::sleep_for( sleep_duration ); - } -} diff --git a/KREngine/kraken/KRTextureStreamer.h b/KREngine/kraken/KRStreamer.h similarity index 90% rename from KREngine/kraken/KRTextureStreamer.h rename to KREngine/kraken/KRStreamer.h index 39f3705..af6d545 100644 --- a/KREngine/kraken/KRTextureStreamer.h +++ b/KREngine/kraken/KRStreamer.h @@ -29,8 +29,8 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRTEXTURESTREAMER_H -#define KRTEXTURESTREAMER_H +#ifndef KRSTREAMER_H +#define KRSTREAMER_H #include "KREngine-common.h" @@ -39,11 +39,11 @@ class KRContext; -class KRTextureStreamer +class KRStreamer { public: - KRTextureStreamer(KRContext &context); - ~KRTextureStreamer(); + KRStreamer(KRContext &context); + ~KRStreamer(); void startStreamer(); @@ -57,4 +57,4 @@ private: void run(); }; -#endif /* defined(KRTEXTURESTREAMER_H) */ +#endif /* defined(KRSTREAMER_H) */ diff --git a/KREngine/kraken/KRTextureStreamer.mm b/KREngine/kraken/KRStreamer.mm similarity index 79% rename from KREngine/kraken/KRTextureStreamer.mm rename to KREngine/kraken/KRStreamer.mm index 81dd5df..a7a79f0 100644 --- a/KREngine/kraken/KRTextureStreamer.mm +++ b/KREngine/kraken/KRStreamer.mm @@ -1,5 +1,5 @@ // -// KRTextureStreamer.cpp +// KRStreamer.cpp // Kraken // // Created by Kearwood Gilbert on 11/1/2013. @@ -8,7 +8,7 @@ #include "KREngine-common.h" -#include "KRTextureStreamer.h" +#include "KRStreamer.h" #include "KRContext.h" #include @@ -27,13 +27,13 @@ NSOpenGLContext *gTextureStreamerContext = nil; #error Unsupported Platform #endif -KRTextureStreamer::KRTextureStreamer(KRContext &context) : m_context(context) +KRStreamer::KRStreamer(KRContext &context) : m_context(context) { m_running = false; m_stop = false; } -void KRTextureStreamer::startStreamer() +void KRStreamer::startStreamer() { if(!m_running) { m_running = true; @@ -61,11 +61,11 @@ void KRTextureStreamer::startStreamer() #error Unsupported Platform #endif - m_thread = std::thread(&KRTextureStreamer::run, this); + m_thread = std::thread(&KRStreamer::run, this); } } -KRTextureStreamer::~KRTextureStreamer() +KRStreamer::~KRStreamer() { if(m_running) { m_stop = true; @@ -76,10 +76,10 @@ KRTextureStreamer::~KRTextureStreamer() [gTextureStreamerContext release]; } -void KRTextureStreamer::run() +void KRStreamer::run() { - pthread_setname_np("Kraken - Texture Streamer"); - + pthread_setname_np("Kraken - Streamer"); + std::chrono::microseconds sleep_duration( 100 ); #if TARGET_OS_IPHONE @@ -92,9 +92,7 @@ void KRTextureStreamer::run() while(!m_stop) { - if(m_context.getStreamingEnabled()) { - m_context.getTextureManager()->doStreaming(); - } + m_context.doStreaming(); std::this_thread::sleep_for( sleep_duration ); } }