WIP Kraken updated OSX support
This commit is contained in:
26
kraken/Info.plist
Normal file
26
kraken/Info.plist
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.krakenengine.kraken</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -105,7 +105,7 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
|
||||
}
|
||||
m_last_frame_start = current_time;
|
||||
|
||||
GLint defaultFBO;
|
||||
GLint defaultFBO = -1;
|
||||
GLDEBUG(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO));
|
||||
|
||||
createBuffers(renderBufferWidth, renderBufferHeight);
|
||||
|
||||
@@ -18,6 +18,19 @@ int KRContext::KRENGINE_MAX_TEXTURE_DIM;
|
||||
int KRContext::KRENGINE_MIN_TEXTURE_DIM;
|
||||
int KRContext::KRENGINE_PRESTREAM_DISTANCE;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
|
||||
#elif TARGET_OS_MAC
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported Platform
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
const char *KRContext::extension_names[KRENGINE_NUM_EXTENSIONS] = {
|
||||
"GL_EXT_texture_storage"
|
||||
};
|
||||
@@ -48,7 +61,7 @@ KRContext::KRContext() : m_streamer(*this)
|
||||
m_pUnknownManager = new KRUnknownManager(*this);
|
||||
m_streamingEnabled = true;
|
||||
|
||||
|
||||
createDeviceContexts();
|
||||
}
|
||||
|
||||
KRContext::~KRContext() {
|
||||
@@ -103,6 +116,8 @@ KRContext::~KRContext() {
|
||||
delete m_pBundleManager;
|
||||
m_pBundleManager = NULL;
|
||||
}
|
||||
|
||||
destroyDeviceContexts();
|
||||
}
|
||||
|
||||
void KRContext::SetLogCallback(log_callback *log_callback, void *user_data)
|
||||
|
||||
@@ -87,6 +87,13 @@ public:
|
||||
|
||||
void doStreaming();
|
||||
void receivedMemoryWarning();
|
||||
|
||||
static void activateStreamerContext();
|
||||
static void activateRenderContext();
|
||||
|
||||
#if TARGET_OS_MAC
|
||||
static void attachToView(void *view);
|
||||
#endif
|
||||
|
||||
private:
|
||||
KRBundleManager *m_pBundleManager;
|
||||
@@ -117,6 +124,9 @@ private:
|
||||
static void *s_log_callback_user_data;
|
||||
|
||||
KRStreamer m_streamer;
|
||||
|
||||
static void createDeviceContexts();
|
||||
void destroyDeviceContexts();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
40
kraken/KRContext_ios.mm
Normal file
40
kraken/KRContext_ios.mm
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// KRContext-ios.mm
|
||||
// Kraken
|
||||
//
|
||||
// Created by Kearwood Gilbert on 11/1/2013.
|
||||
// Copyright (c) 2013 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#include "KREngine-common.h"
|
||||
|
||||
#include "KRContext.h"
|
||||
|
||||
EAGLContext *gStreamerContext = nil;
|
||||
EAGLContext *gRenderContext = nil;
|
||||
|
||||
void KRContext::destroyDeviceContexts()
|
||||
{
|
||||
[gStreamerContext release];
|
||||
[gRenderContext release];
|
||||
}
|
||||
|
||||
void KRContext::createDeviceContexts()
|
||||
{
|
||||
gRenderContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
gTextureStreamerContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup: gStreamerContext.sharegroup];
|
||||
|
||||
// FIXME: need to add code check for iOS 7 and also this appears to cause crashing
|
||||
|
||||
//gTextureStreamerContext.multiThreaded = TRUE;
|
||||
}
|
||||
|
||||
void KRContext::activateStreamerContext()
|
||||
{
|
||||
[EAGLContext setCurrentContext: gStreamerContext];
|
||||
}
|
||||
|
||||
void KRContext::activateRenderContext()
|
||||
{
|
||||
[EAGLContext setCurrentContext: gRenderContext];
|
||||
}
|
||||
82
kraken/KRContext_osx.mm
Normal file
82
kraken/KRContext_osx.mm
Normal file
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// KRContext-osx.mm
|
||||
// Kraken
|
||||
//
|
||||
// Created by Kearwood Gilbert on 11/1/2013.
|
||||
// Copyright (c) 2013 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#include "KREngine-common.h"
|
||||
|
||||
#include "KRContext.h"
|
||||
|
||||
NSOpenGLContext *gStreamerContext = nil;
|
||||
NSOpenGLContext *gRenderContext = nil;
|
||||
|
||||
void KRContext::destroyDeviceContexts()
|
||||
{
|
||||
[gStreamerContext release];
|
||||
[gRenderContext release];
|
||||
}
|
||||
|
||||
void KRContext::createDeviceContexts()
|
||||
{
|
||||
if(gRenderContext == nil) {
|
||||
|
||||
/*
|
||||
NSOpenGLPixelFormatAttribute attribs[] =
|
||||
{
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
NSOpenGLPFADepthSize, 32,
|
||||
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
|
||||
0
|
||||
};
|
||||
*/
|
||||
NSOpenGLPixelFormatAttribute attribs[] = {
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
NSOpenGLPFAAccelerated,
|
||||
NSOpenGLPFAColorSize, 24,
|
||||
NSOpenGLPFAAlphaSize, 8,
|
||||
NSOpenGLPFADepthSize, 24,
|
||||
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
|
||||
0
|
||||
};
|
||||
NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attribs] autorelease];
|
||||
gRenderContext = [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: nil ];
|
||||
gStreamerContext = [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: gRenderContext ];
|
||||
|
||||
// set synch to VBL to eliminate tearing
|
||||
GLint vblSynch = 1;
|
||||
[gRenderContext setValues:&vblSynch forParameter:NSOpenGLCPSwapInterval];
|
||||
|
||||
/*
|
||||
CGLEnable([gRenderContext CGLContextObj], kCGLCESurfaceBackingSize);
|
||||
|
||||
const GLint dim[2] = {1920, 1080};
|
||||
|
||||
[gRenderContext setValues: &dim[0] forParameter: NSOpenGLCPSurfaceBackingSize];
|
||||
[gRenderContext update];
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void KRContext::activateStreamerContext()
|
||||
{
|
||||
createDeviceContexts();
|
||||
[gStreamerContext makeCurrentContext];
|
||||
}
|
||||
|
||||
void KRContext::activateRenderContext()
|
||||
{
|
||||
createDeviceContexts();
|
||||
[gRenderContext update];
|
||||
[gRenderContext makeCurrentContext];
|
||||
}
|
||||
|
||||
void KRContext::attachToView(void *view)
|
||||
{
|
||||
createDeviceContexts();
|
||||
NSView *v = (NSView *)view;
|
||||
[gRenderContext setView: v];
|
||||
[gRenderContext update];
|
||||
}
|
||||
@@ -107,6 +107,16 @@ using std::hash;
|
||||
#define GL_ANY_SAMPLES_PASSED_EXT GL_ANY_SAMPLES_PASSED
|
||||
#define GL_QUERY_RESULT_EXT GL_QUERY_RESULT
|
||||
|
||||
#define GL_OES_mapbuffer 1
|
||||
#define glMapBufferOES glMapBuffer
|
||||
#define glUnmapBufferOES glUnmapBuffer
|
||||
#define GL_WRITE_ONLY_OES GL_WRITE_ONLY
|
||||
|
||||
#define GL_OES_vertex_array_object 1
|
||||
#define glGenVertexArraysOES glGenVertexArrays
|
||||
#define glBindVertexArrayOES glBindVertexArray
|
||||
#define glDeleteVertexArraysOES glDeleteVertexArrays
|
||||
|
||||
#endif
|
||||
|
||||
#include <Accelerate/Accelerate.h>
|
||||
|
||||
@@ -558,7 +558,7 @@ bool KRShader::bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &
|
||||
setUniform(KRENGINE_UNIFORM_VOLUMETRIC_ENVIRONMENT_FRAME, 2);
|
||||
|
||||
#if DEBUG
|
||||
if(shander_changed) {
|
||||
if(shander_changed) { // FINDME!! KIP!! HACK!!
|
||||
GLint logLength;
|
||||
|
||||
GLint validate_status = GL_FALSE;
|
||||
|
||||
@@ -145,7 +145,7 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#else
|
||||
stream << "\n#version 120";
|
||||
stream << "\n#version 150";
|
||||
stream << "\n#define lowp";
|
||||
stream << "\n#define mediump";
|
||||
stream << "\n#define highp";
|
||||
|
||||
@@ -14,19 +14,6 @@
|
||||
#include <chrono>
|
||||
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
EAGLContext *gTextureStreamerContext = nil;
|
||||
|
||||
#elif TARGET_OS_MAC
|
||||
|
||||
NSOpenGLContext *gTextureStreamerContext = nil;
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported Platform
|
||||
#endif
|
||||
|
||||
KRStreamer::KRStreamer(KRContext &context) : m_context(context)
|
||||
{
|
||||
m_running = false;
|
||||
@@ -37,29 +24,7 @@ void KRStreamer::startStreamer()
|
||||
{
|
||||
if(!m_running) {
|
||||
m_running = true;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
gTextureStreamerContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup: [EAGLContext currentContext].sharegroup];
|
||||
// FIXME: need to add code check for iOS 7 and also this appears to cause crashing
|
||||
|
||||
//gTextureStreamerContext.multiThreaded = TRUE;
|
||||
|
||||
|
||||
#elif TARGET_OS_MAC
|
||||
|
||||
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] =
|
||||
{
|
||||
// NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy,
|
||||
0
|
||||
};
|
||||
NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes] autorelease];
|
||||
gTextureStreamerContext = [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: [NSOpenGLContext currentContext] ];
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported Platform
|
||||
#endif
|
||||
KRContext::activateStreamerContext();
|
||||
|
||||
m_thread = std::thread(&KRStreamer::run, this);
|
||||
}
|
||||
@@ -72,8 +37,6 @@ KRStreamer::~KRStreamer()
|
||||
m_thread.join();
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
[gTextureStreamerContext release];
|
||||
}
|
||||
|
||||
void KRStreamer::run()
|
||||
@@ -82,13 +45,7 @@ void KRStreamer::run()
|
||||
|
||||
std::chrono::microseconds sleep_duration( 15000 );
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
[EAGLContext setCurrentContext: gTextureStreamerContext];
|
||||
#elif TARGET_OS_MAC
|
||||
[gTextureStreamerContext makeCurrentContext];
|
||||
#else
|
||||
#error Unsupported Platform
|
||||
#endif
|
||||
KRContext::activateStreamerContext();
|
||||
|
||||
while(!m_stop)
|
||||
{
|
||||
|
||||
19
kraken/kraken.h
Normal file
19
kraken/kraken.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// kraken.h
|
||||
// kraken
|
||||
//
|
||||
// Created by Kearwood Gilbert on 2015-11-06.
|
||||
// Copyright © 2015 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
//! Project version number for kraken.
|
||||
FOUNDATION_EXPORT double krakenVersionNumber;
|
||||
|
||||
//! Project version string for kraken.
|
||||
FOUNDATION_EXPORT const unsigned char krakenVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <kraken/PublicHeader.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user