2012-04-12 19:43:08 +00:00
|
|
|
//
|
|
|
|
|
// KRContext.h
|
|
|
|
|
// KREngine
|
|
|
|
|
//
|
|
|
|
|
// Created by Kearwood Gilbert on 12-04-12.
|
|
|
|
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifndef KREngine_KRContext_h
|
|
|
|
|
#define KREngine_KRContext_h
|
|
|
|
|
|
2013-01-11 03:21:19 +00:00
|
|
|
#include "KREngine-common.h"
|
|
|
|
|
#include "KRBundleManager.h"
|
|
|
|
|
#include "KRSceneManager.h"
|
|
|
|
|
#include "KRTextureManager.h"
|
|
|
|
|
#include "KRMaterialManager.h"
|
|
|
|
|
#include "KRShaderManager.h"
|
|
|
|
|
#include "KRMeshManager.h"
|
|
|
|
|
#include "KRAnimationManager.h"
|
|
|
|
|
#include "KRAnimationCurveManager.h"
|
|
|
|
|
#include "KRAudioManager.h"
|
|
|
|
|
#include "KRUnknownManager.h"
|
2014-05-13 21:56:06 -07:00
|
|
|
#include "KRStreamer.h"
|
2012-10-19 23:17:43 +00:00
|
|
|
|
2012-04-12 19:43:08 +00:00
|
|
|
class KRContext {
|
|
|
|
|
public:
|
2012-10-19 23:17:43 +00:00
|
|
|
static int KRENGINE_MAX_SHADER_HANDLES;
|
2014-06-01 15:34:31 -07:00
|
|
|
static int KRENGINE_GPU_MEM_MAX;
|
|
|
|
|
static int KRENGINE_GPU_MEM_TARGET;
|
2012-10-19 23:17:43 +00:00
|
|
|
static int KRENGINE_MAX_TEXTURE_DIM;
|
|
|
|
|
static int KRENGINE_MIN_TEXTURE_DIM;
|
2014-04-23 01:43:00 -07:00
|
|
|
static int KRENGINE_PRESTREAM_DISTANCE;
|
2012-10-19 23:17:43 +00:00
|
|
|
|
|
|
|
|
|
2012-04-13 23:24:07 +00:00
|
|
|
KRContext();
|
2012-04-12 19:43:08 +00:00
|
|
|
~KRContext();
|
|
|
|
|
|
2012-09-11 03:06:35 +00:00
|
|
|
void loadResource(const std::string &file_name, KRDataBlock *data);
|
2012-04-12 19:43:08 +00:00
|
|
|
void loadResource(std::string path);
|
|
|
|
|
|
2012-09-11 03:06:35 +00:00
|
|
|
KRBundleManager *getBundleManager();
|
2012-04-12 19:43:08 +00:00
|
|
|
KRSceneManager *getSceneManager();
|
|
|
|
|
KRTextureManager *getTextureManager();
|
|
|
|
|
KRMaterialManager *getMaterialManager();
|
|
|
|
|
KRShaderManager *getShaderManager();
|
2014-05-13 21:56:06 -07:00
|
|
|
KRMeshManager *getMeshManager();
|
2012-12-01 02:03:18 +00:00
|
|
|
KRAnimationManager *getAnimationManager();
|
2012-12-07 00:20:06 +00:00
|
|
|
KRAnimationCurveManager *getAnimationCurveManager();
|
2013-01-05 04:04:58 +00:00
|
|
|
KRAudioManager *getAudioManager();
|
2013-01-02 22:00:29 +00:00
|
|
|
KRUnknownManager *getUnknownManager();
|
2012-04-12 19:43:08 +00:00
|
|
|
|
2012-08-17 01:04:49 +00:00
|
|
|
KRCamera *createCamera(int width, int height);
|
|
|
|
|
|
2012-11-01 22:16:59 +00:00
|
|
|
enum {
|
|
|
|
|
KRENGINE_GL_EXT_texture_storage,
|
|
|
|
|
KRENGINE_NUM_EXTENSIONS
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char * extension_names[KRENGINE_NUM_EXTENSIONS];
|
|
|
|
|
static bool extension_available[KRENGINE_NUM_EXTENSIONS];
|
|
|
|
|
|
2012-12-07 01:49:17 +00:00
|
|
|
void startFrame(float deltaTime);
|
2012-11-23 01:02:22 +00:00
|
|
|
void endFrame(float deltaTime);
|
2012-11-17 00:15:52 +00:00
|
|
|
|
2012-11-23 01:02:22 +00:00
|
|
|
long getCurrentFrame() const;
|
|
|
|
|
float getAbsoluteTime() const;
|
2013-03-21 19:58:35 -07:00
|
|
|
|
2013-03-22 17:17:12 -07:00
|
|
|
long getAbsoluteTimeMilliseconds();
|
|
|
|
|
|
2013-05-06 12:58:57 -07:00
|
|
|
std::vector<KRResource *> getResources();
|
2013-11-13 23:52:17 -08:00
|
|
|
bool getStreamingEnabled();
|
|
|
|
|
void setStreamingEnabled(bool enable);
|
2013-05-06 12:58:57 -07:00
|
|
|
|
2013-11-16 02:34:18 -08:00
|
|
|
void getMemoryStats(long &free_memory);
|
|
|
|
|
|
2013-12-14 16:06:44 -08:00
|
|
|
typedef enum {
|
|
|
|
|
LOG_LEVEL_INFORMATION,
|
|
|
|
|
LOG_LEVEL_WARNING,
|
|
|
|
|
LOG_LEVEL_ERROR
|
|
|
|
|
} log_level;
|
|
|
|
|
|
|
|
|
|
typedef void log_callback(void *userdata, const std::string &message, log_level level);
|
|
|
|
|
|
|
|
|
|
static void SetLogCallback(log_callback *log_callback, void *user_data);
|
|
|
|
|
static void Log(log_level level, const std::string &message_format, ...);
|
|
|
|
|
|
2014-05-13 21:56:06 -07:00
|
|
|
void doStreaming();
|
|
|
|
|
|
2012-04-12 19:43:08 +00:00
|
|
|
private:
|
2012-09-11 03:06:35 +00:00
|
|
|
KRBundleManager *m_pBundleManager;
|
2012-04-12 19:43:08 +00:00
|
|
|
KRSceneManager *m_pSceneManager;
|
|
|
|
|
KRTextureManager *m_pTextureManager;
|
|
|
|
|
KRMaterialManager *m_pMaterialManager;
|
|
|
|
|
KRShaderManager *m_pShaderManager;
|
2014-05-13 21:56:06 -07:00
|
|
|
KRMeshManager *m_pMeshManager;
|
2012-12-01 02:03:18 +00:00
|
|
|
KRAnimationManager *m_pAnimationManager;
|
2012-12-07 00:20:06 +00:00
|
|
|
KRAnimationCurveManager *m_pAnimationCurveManager;
|
2013-01-05 04:04:58 +00:00
|
|
|
KRAudioManager *m_pSoundManager;
|
2013-01-02 22:00:29 +00:00
|
|
|
KRUnknownManager *m_pUnknownManager;
|
2012-11-01 22:16:59 +00:00
|
|
|
|
|
|
|
|
void detectExtensions();
|
|
|
|
|
bool m_bDetectedExtensions;
|
2012-11-17 00:15:52 +00:00
|
|
|
|
|
|
|
|
long m_current_frame;
|
2012-11-23 01:02:22 +00:00
|
|
|
float m_absolute_time;
|
2013-03-06 15:46:54 -08:00
|
|
|
|
|
|
|
|
mach_timebase_info_data_t m_timebase_info;
|
2013-11-13 23:52:17 -08:00
|
|
|
|
|
|
|
|
std::atomic<bool> m_streamingEnabled;
|
2013-12-14 16:06:44 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
static log_callback *s_log_callback;
|
|
|
|
|
static void *s_log_callback_user_data;
|
2014-05-13 21:56:06 -07:00
|
|
|
|
|
|
|
|
KRStreamer m_streamer;
|
2012-04-12 19:43:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|