Files
kraken/KREngine/kraken/KRTextureStreamer.mm
Kearwood Gilbert cc5c698b13 Updated to FBX SDK 2014.2
Nodes in the FBX file starting with so_ will no longer be decorated with fbx_##_ prefixes.
Updated import pipeline for compatibility with C++11

--HG--
branch : nfb
2013-11-23 12:16:31 -08:00

98 lines
2.1 KiB
Plaintext

//
// KRTextureStreamer.cpp
// Kraken
//
// Created by Kearwood Gilbert on 11/1/2013.
// Copyright (c) 2013 Kearwood Software. All rights reserved.
//
#include "KREngine-common.h"
#include "KRTextureStreamer.h"
#include "KRContext.h"
#include <chrono>
#if TARGET_OS_IPHONE
EAGLContext *gTextureStreamerContext = nil;
#elif TARGET_OS_MAC
NSOpenGLContext *gTextureStreamerContext = nil;
#else
#error Unsupported Platform
#endif
KRTextureStreamer::KRTextureStreamer(KRContext &context) : m_context(context)
{
m_running = false;
m_stop = false;
}
void KRTextureStreamer::startStreamer()
{
if(!m_running) {
m_running = true;
#if TARGET_OS_IPHONE
gTextureStreamerContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup: [EAGLContext currentContext].sharegroup];
#elif TARGET_OS_MAC
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] =
{
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
0
};
NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes] autorelease];
gTextureStreamerContext = [[[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: [NSOpenGLContext currentContext] ] autorelease];
#else
#error Unsupported Platform
#endif
m_thread = std::thread(&KRTextureStreamer::run, this);
}
}
KRTextureStreamer::~KRTextureStreamer()
{
m_stop = true;
m_thread.join();
[gTextureStreamerContext release];
}
void KRTextureStreamer::run()
{
pthread_setname_np("Kraken - Texture Streamer");
std::chrono::microseconds sleep_duration( 100 );
#if TARGET_OS_IPHONE
[EAGLContext setCurrentContext: gTextureStreamerContext];
#elif TARGET_OS_MAC
[gTextureStreamerContext makeCurrentContext];
#else
#error Unsupported Platform
#endif
while(!m_stop)
{
if(m_context.getStreamingEnabled()) {
m_context.getTextureManager()->doStreaming();
}
std::this_thread::sleep_for( sleep_duration );
}
m_running = false;
}