aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libjin/Audio/SDL/je_sdl_audio.cpp146
-rw-r--r--src/libjin/Audio/SDL/je_sdl_audio.h138
-rw-r--r--src/libjin/Audio/SDL/je_sdl_source.cpp404
-rw-r--r--src/libjin/Audio/SDL/je_sdl_source.h272
-rw-r--r--src/libjin/Audio/je_audio_manager.cpp15
-rw-r--r--src/libjin/Audio/je_audio_manager.h87
-rw-r--r--src/libjin/Audio/je_source.cpp30
-rw-r--r--src/libjin/Audio/je_source.h116
-rw-r--r--src/libjin/Common/je_array.hpp123
-rw-r--r--src/libjin/Common/je_common.h7
-rw-r--r--src/libjin/Common/je_exception.cpp46
-rw-r--r--src/libjin/Common/je_exception.h45
-rw-r--r--src/libjin/Common/je_noncopyable.h24
-rw-r--r--src/libjin/Common/je_object.h16
-rw-r--r--src/libjin/Common/je_pool.hpp177
-rw-r--r--src/libjin/Common/je_singleton.hpp80
-rw-r--r--src/libjin/Common/je_stringmap.hpp143
-rw-r--r--src/libjin/Common/je_subsystem.hpp78
-rw-r--r--src/libjin/Common/je_temporary.h31
-rw-r--r--src/libjin/Common/je_types.h34
-rw-r--r--src/libjin/Common/je_utf8.cpp42
-rw-r--r--src/libjin/Common/je_utf8.h34
-rw-r--r--src/libjin/Core/README.md1
-rw-r--r--src/libjin/Core/je_configuration.h58
-rw-r--r--src/libjin/Core/je_version.h52
-rw-r--r--src/libjin/Filesystem/je_asset_database.cpp85
-rw-r--r--src/libjin/Filesystem/je_asset_database.h114
-rw-r--r--src/libjin/Filesystem/je_buffer.h169
-rw-r--r--src/libjin/Game/je_application.cpp81
-rw-r--r--src/libjin/Game/je_application.h88
-rw-r--r--src/libjin/Game/je_entity.cpp0
-rw-r--r--src/libjin/Game/je_entity.h27
-rw-r--r--src/libjin/Game/je_gameobject.cpp11
-rw-r--r--src/libjin/Game/je_gameobject.h83
-rw-r--r--src/libjin/Game/je_scene.cpp0
-rw-r--r--src/libjin/Game/je_scene.h73
-rw-r--r--src/libjin/Graphics/particles/je_particle.h2
-rw-r--r--src/libjin/Input/je_event.cpp8
-rw-r--r--src/libjin/Input/je_event.h121
-rw-r--r--src/libjin/Input/je_input.h9
-rw-r--r--src/libjin/Input/je_joypad.cpp0
-rw-r--r--src/libjin/Input/je_joypad.h56
-rw-r--r--src/libjin/Input/je_keyboard.cpp0
-rw-r--r--src/libjin/Input/je_keyboard.h20
-rw-r--r--src/libjin/Input/je_mouse.cpp28
-rw-r--r--src/libjin/Input/je_mouse.h49
-rw-r--r--src/libjin/Math/README.md1
-rw-r--r--src/libjin/Math/je_bezier_curve.cpp0
-rw-r--r--src/libjin/Math/je_bezier_curve.h17
-rw-r--r--src/libjin/Math/je_constant.h10
-rw-r--r--src/libjin/Math/je_ellipse.cpp0
-rw-r--r--src/libjin/Math/je_ellipse.h0
-rw-r--r--src/libjin/Math/je_math.h83
-rw-r--r--src/libjin/Math/je_matrix.cpp194
-rw-r--r--src/libjin/Math/je_matrix.h159
-rw-r--r--src/libjin/Math/je_quad.h23
-rw-r--r--src/libjin/Math/je_random.cpp52
-rw-r--r--src/libjin/Math/je_random.h33
-rw-r--r--src/libjin/Math/je_transform.cpp99
-rw-r--r--src/libjin/Math/je_transform.h49
-rw-r--r--src/libjin/Math/je_vector2.hpp63
-rw-r--r--src/libjin/Math/je_vector3.hpp41
-rw-r--r--src/libjin/Math/je_vector4.hpp45
-rw-r--r--src/libjin/Net/je_net_manager.cpp24
-rw-r--r--src/libjin/Net/je_net_manager.h50
-rw-r--r--src/libjin/Net/je_socket.cpp190
-rw-r--r--src/libjin/Net/je_socket.h144
-rw-r--r--src/libjin/Time/je_timer.cpp122
-rw-r--r--src/libjin/Time/je_timer.h137
-rw-r--r--src/libjin/Utils/je_endian.h23
-rw-r--r--src/libjin/Utils/je_log.cpp81
-rw-r--r--src/libjin/Utils/je_log.h63
-rw-r--r--src/libjin/Utils/je_macros.h17
-rw-r--r--src/libjin/Utils/je_unittest.cpp108
-rw-r--r--src/libjin/Utils/je_utils.h9
-rw-r--r--src/libjin/graphics/particles/je_particle.h2
76 files changed, 2 insertions, 5060 deletions
diff --git a/src/libjin/Audio/SDL/je_sdl_audio.cpp b/src/libjin/Audio/SDL/je_sdl_audio.cpp
deleted file mode 100644
index c21d077..0000000
--- a/src/libjin/Audio/SDL/je_sdl_audio.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-#include "../../core/je_configuration.h"
-#if defined(jin_audio) && (jin_audio == jin_audio_sdl)
-
-#include <iostream>
-
-#include "../../math/je_math.h"
-#include "../../utils/je_log.h"
-
-#include "je_sdl_audio.h"
-#include "je_sdl_source.h"
-
-using namespace JinEngine::Math;
-
-namespace JinEngine
-{
- namespace Audio
- {
- namespace SDL
- {
-
- /* עcallbackƵ̵߳ */
- static void defaultCallback(void *userdata, Uint8 *stream, int size)
- {
- static SDLAudio* audio = static_cast<SDLAudio*>(userdata);
- if (!audio->goOnProcess())
- return;
- audio->lock();
- audio->processCommands();
- audio->processSources(stream, size);
- audio->processBuffer(stream, size);
- audio->unlock();
- }
-
- /*call only once*/ bool SDLAudio::initSystem(const SettingBase* s)
- {
- jin_log_info("Initialize audio system.");
-
- if (SDL_Init(SDL_INIT_AUDIO) < 0)
- return false;
-
- SDL_AudioSpec spec;
- Setting* setting = (Setting*)s;
- if (setting == nullptr)
- return false;
-
- unsigned int samplerate = setting->samplerate;
- unsigned int samples = clamp<int>(setting->samples, 1, setting->samplerate);
-
- spec.freq = samplerate; // ÿsample,õ 11025, 22050, 44100 and 48000 Hz.
- spec.format = AUDIO_S16SYS; // signed 16-bit samples in native byte order
- spec.channels = SDLAUDIO_CHANNELS; //
- spec.samples = samples; // ÿβʱһã=setting->samplerateÿֻ1
- spec.userdata = this;
- spec.callback = defaultCallback;
-
- audioDevice = SDL_OpenAudioDevice(NULL, 0, &spec, NULL, 0);
- if (audioDevice == 0)
- return false;
- /* start audio */
- SDL_PauseAudioDevice(audioDevice, 0);
- return true;
- }
-
- /*call only once*/ void SDLAudio::quitSystem()
- {
- jin_log_info("Quit audio system.");
- SDL_CloseAudio();
- }
-
- void SDLAudio::lock()
- {
- SDL_LockAudioDevice(audioDevice);
- }
-
- void SDLAudio::unlock()
- {
- SDL_UnlockAudioDevice(audioDevice);
- }
-
- bool SDLAudio::goOnProcess()
- {
- if (state == SDLAudio::State::STOP)
- {
- SDLSourceManager::get()->removeAllSource();
- pause();
- return false;
- }
- else if (state == SDLAudio::State::PAUSE)
- return false;
- else
- return true;
- }
-
- void SDLAudio::processCommands()
- {
- SDLSourceManager::get()->processCommands();
- }
-
- void SDLAudio::processSources(void* buffer, size_t len)
- {
- SDLSourceManager::get()->processSources(buffer, len);
- }
-
- void SDLAudio::processBuffer(void* buff, size_t len)
- {
- short* buffer = (short*)buff;
- int samples = (len / SDLAUDIO_BYTEDEPTH) >> 1; // ˫
- const char L = 0, R = 1;
- for (int i = 0; i < samples; ++i)
- {
- short* clip = buffer + (i << 1);
- clip[L] *= volume;
- clip[R] *= volume;
- }
- }
-
- void SDLAudio::play()
- {
- state = State::PLAY;
- }
-
- void SDLAudio::stop()
- {
- state = State::STOP;
- }
-
- void SDLAudio::pause()
- {
- state = State::PAUSE;
- }
-
- void SDLAudio::resume()
- {
- state = State::PLAY;
- }
-
- void SDLAudio::setVolume(float volume)
- {
- this->volume = clamp(volume, 0.0f, 1.0f);
- }
-
- } // namespace SDL
- } // namespace Audio
-} // namespace JinEngine
-
-#endif // (jin_audio) && (jin_audio == jin_audio_sdl) \ No newline at end of file
diff --git a/src/libjin/Audio/SDL/je_sdl_audio.h b/src/libjin/Audio/SDL/je_sdl_audio.h
deleted file mode 100644
index 77162d4..0000000
--- a/src/libjin/Audio/SDL/je_sdl_audio.h
+++ /dev/null
@@ -1,138 +0,0 @@
-#ifndef __JE_AUDIO_SDL_H__
-#define __JE_AUDIO_SDL_H__
-#include "../../core/je_configuration.h"
-#if defined(jin_audio) && (jin_audio == jin_audio_sdl)
-
-#include <vector>
-
-#include "../je_audio_manager.h"
-
-#include "je_sdl_source.h"
-
-namespace JinEngine
-{
- namespace Audio
- {
- namespace SDL
- {
-
-#define SDLAUDIO_BITDEPTH 16
-#define SDLAUDIO_BYTEDEPTH (SDLAUDIO_BITDEPTH >> 3)
-#define SDLAUDIO_CHANNELS 2
-
- ///
- /// Audio system SDL implementation.
- ///
- class SDLAudio : public AudioManager<SDLAudio>
- {
- public:
- ///
- /// SDL audio setting.
- ///
- struct Setting : SettingBase
- {
- public:
- int samplerate; // Ƶ
- int samples; // sample<=samplerate
- };
-
- ///
- /// Play all sources whose state is playing.
- ///
- void play() override;
-
- ///
- /// Stop and remove all sources from the queue.
- ///
- void stop() override;
-
- ///
- /// Pause audio.
- ///
- void pause() override;
-
- ///
- /// Resume audio.
- ///
- void resume() override;
-
- ///
- /// Set global audio volume.
- ///
- void setVolume(float volume) override;
-
- ///
- /// Process all commands in the queue.
- ///
- void processCommands();
-
- ///
- /// Process all sources.
- ///
- /// @param buffer Source buffer.
- /// @param len Source length.
- ///
- void processSources(void* buffer, size_t len);
-
- ///
- /// Process audio buffer.
- ///
- /// @param buffer Audio stream buffer.
- /// @param len Length of stream buffer.
- ///
- void processBuffer(void* buffer, size_t len);
-
- ///
- /// Goon process.
- ///
- /// @return True if sucessful, otherwise return false.
- ///
- bool goOnProcess();
-
- ///
- /// Lock audio device.
- ///
- void lock();
-
- ///
- /// Unlock audio device.
- ///
- void unlock();
-
- private:
- singleton(SDLAudio);
-
- ///
- /// SDL audio constructor.
- ///
- SDLAudio() {};
-
- ///
- /// SDL audio destructor.
- ///
- ~SDLAudio() {};
-
- ///
- /// Initialize audio system.
- ///
- /// @param setting Audio setting.
- ///
- bool initSystem(const SettingBase* setting) override;
-
- ///
- /// Quit audio system.
- ///
- void quitSystem() override;
-
- // Audio device id.
- unsigned int audioDevice;
-
- };
-
- } // namespace SDL
- } // namespace Audio
-} // namespace JinEngine
-
-#endif // (jin_audio) && (jin_audio == jin_audio_sdl)
-
-#endif // __JE_AUDIO_SDL_H__ \ No newline at end of file
diff --git a/src/libjin/Audio/SDL/je_sdl_source.cpp b/src/libjin/Audio/SDL/je_sdl_source.cpp
deleted file mode 100644
index d417bf7..0000000
--- a/src/libjin/Audio/SDL/je_sdl_source.cpp
+++ /dev/null
@@ -1,404 +0,0 @@
-#include "../../core/je_configuration.h"
-#if defined(jin_audio) && (jin_audio == jin_audio_sdl)
-
-#include <exception>
-#include <fstream>
-#include <climits>
-
-#define STB_VORBIS_HEADER_ONLY
-#include "stb/stb_vorbis.c"
-#include "wav/wav.h"
-
-#include "../../math/je_math.h"
-#include "../../utils/je_macros.h"
-
-#include "je_sdl_audio.h"
-#include "je_sdl_source.h"
-
-using namespace JinEngine::Math;
-
-namespace JinEngine
-{
- namespace Audio
- {
- namespace SDL
- {
-
-
-#define BITS 8
-
- typedef struct SDLSourceCommand
- {
- typedef enum Action
- {
- Nothing = 0,
- Play,
- Stop,
- Pause,
- Resume,
- Rewind,
- SetVolume,
- SetLoop,
- SetRate,
- };
- Action action;
- union {
- int _integer;
- float _float;
- bool _boolean;
- const char* _string;
- } parameter;
-
- SDLSource* source;
- };
-
- typedef enum CHANNEL
- {
- MONO = 1, //
- STEREO = 2, //
- };
-
- typedef /*mask*/ enum STATUS
- {
- PLAYING = 1,
- PAUSED = 2,
- STOPPED = 4
- };
-
-#define Command SDLSourceCommand
-#define Action Command::Action
-#define Manager SDLSourceManager
-
- //std::queue<Command*> Manager::commands;
- //std::stack<Command*> Manager::commandsPool;
- //std::vector<SDLSource*> Manager::sources;
- Manager* Manager::manager = nullptr;
-
- SDLSource* SDLSource::createSource(const char* file)
- {
- std::ifstream fs;
- fs.open(file, std::ios::binary);
- if (!fs.is_open())
- {
- fs.close();
- return nullptr;
- }
- fs.seekg(0, std::ios::end);
- int size = fs.tellg();
- fs.seekg(0, std::ios::beg);
- char* buffer = (char*)malloc(size);
- memset(buffer, 0, size);
- fs.read(buffer, size);
- fs.close();
- SDLSource* source = createSource(buffer, size);
- free(buffer);
- return source;
- }
-
- SDLSource* SDLSource::createSource(void* mem, size_t size)
- {
- if (mem == nullptr)
- return nullptr;
- SDLSource* source = new SDLSource();
- try
- {
- SourceType format = getType(mem, size);
- switch (format)
- {
- case OGG: source->decode_ogg(mem, size); break;
- case WAV: source->decode_wav(mem, size); break;
- }
- }
- catch (SourceException& exp)
- {
- delete source;
- return nullptr;
- };
- return source;
- }
-
- SDLSource::SDLSource()
- {
- memset(&status, 0, sizeof(status));
- memset(&raw, 0, sizeof(raw));
- status.volume = 1;
- }
-
- SDLSource::~SDLSource()
- {
- delete raw.data;
- raw.end = 0;
- raw.data = 0;
- }
-
- void SDLSource::decode_wav(void* mem, int size)
- {
- wav_t wav;
- if (wav_read(&wav, mem, size) == 0)
- {
- raw.data = wav.data;
- raw.length = wav.length * wav.channels * wav.bitdepth / 8;
- raw.channels = clamp<int>(wav.channels, CHANNEL::MONO, CHANNEL::STEREO);
- raw.end = (char*)raw.data + raw.length;
- raw.samplerate = wav.samplerate;
- raw.bitdepth = wav.bitdepth;
- raw.samples = wav.length;
- }
- else
- throw SourceException();
- }
-
- void SDLSource::decode_ogg(void* _mem, int size)
- {
- unsigned char* mem = (unsigned char*)_mem;
- int channels;
- int samplerate;
- short* data = (short*)raw.data;
- int samples = stb_vorbis_decode_memory(
- mem,
- size,
- &channels,
- &samplerate,
- &data
- );
- const int bitdepth = sizeof(short) * BITS;
- raw.channels = channels;
- raw.samplerate = samplerate;
- raw.data = data;
- raw.samples = samples; // һsample
- raw.length = samples * channels * sizeof(short); // һsample
- raw.bitdepth = bitdepth;
- raw.end = (char*)data + raw.length;
- }
-
-#define ActionNone(T)\
- do{\
- Command* cmd = Manager::get()->getCommand();\
- cmd->action = Action::T; \
- cmd->source = this; \
- Manager::get()->pushCommand(cmd); \
- } while (0)
-
-#define ActionArg(T, ARGT, ARG)\
- do{\
- Command* cmd = Manager::get()->getCommand();\
- cmd->action = Action::T; \
- cmd->parameter.ARGT = ARG; \
- cmd->source = this; \
- Manager::get()->pushCommand(cmd); \
- }while(0)
-
-#define ActionInt(T, INT) ActionArg(T, _integer, INT)
-#define ActionFloat(T, FLT) ActionArg(T, _float, FLT)
-#define ActionString(T, STR) ActionArg(T, _string, STR)
-#define ActionBool(T, BOL) ActionArg(T, _boolean, BOL)
-
- void SDLSource::play()
- {
- ActionNone(Play);
- }
-
- void SDLSource::stop()
- {
- ActionNone(Stop);
- }
-
- void SDLSource::pause()
- {
- ActionNone(Pause);
- }
-
- void SDLSource::resume()
- {
- ActionNone(Resume);
- }
-
- void SDLSource::rewind()
- {
- ActionNone(Rewind);
- }
-
- inline bool SDLSource::isStopped() const
- {
- return is(STOPPED);
- }
-
- bool SDLSource::isPaused() const
- {
- return is(PAUSED);
- }
-
- void SDLSource::setPitch(float pitch)
- {
- }
-
- void SDLSource::setVolume(float volume)
- {
- ActionFloat(SetVolume, clamp(volume, 0.0f, 1.0f));
- }
-
- void SDLSource::setLoop(bool loop)
- {
- ActionBool(SetLoop, loop);
- }
-
- void SDLSource::setRate(float rate)
- {
- ActionFloat(SetRate, rate);
- }
-
- inline void SDLSource::handle(
- SDLSourceManager* manager,
- SDLSourceCommand* cmd
- )
- {
- switch (cmd->action)
- {
- case Command::Action::Play:
- manager->removeSource(this);
- manager->pushSource(this);
- status.state = PLAYING;
- status.pos = 0; // rewind
- break;
- case Command::Action::Stop:
- manager->removeSource(this);
- status.state = STOPPED;
- status.pos = 0; // rewind
- break;
- case Command::Action::Pause:
- manager->removeSource(this);
- status.state = PAUSED;
- break;
- case Command::Action::Resume:
- manager->removeSource(this);
- manager->pushSource(this);
- status.state = PLAYING;
- break;
- case Command::Action::Rewind:
- status.state = PLAYING;
- status.pos = 0;
- break;
- case Command::Action::SetVolume:
- status.volume = cmd->parameter._float;
- break;
- case Command::Action::SetLoop:
- status.loop = cmd->parameter._boolean;
- break;
- }
- }
-
- inline void SDLSource::process(void* buf, size_t size)
- {
- short* buffer = (short*)buf; // AUDIO_S16SYS
- int samples = (size / SDLAUDIO_BYTEDEPTH) >> 1; // ˫
- const char L = 0, R = 1;
- for (int i = 0; i < samples; ++i)
- {
- char* source = (char*)raw.data + status.pos * (raw.bitdepth / 8) * raw.channels;
- short l = 0;
- short r = 0;
- if (raw.bitdepth == 16)
- {
- l = ((short*)source)[L] * status.volume;
- r = ((short*)source)[L + raw.channels - 1] * status.volume;
- }
- else if (raw.bitdepth == 8)
- {
- l = source[L] << 8; // << 8 Ŵ16bits
- r = source[L + raw.channels - 1] << 8;
- }
- short* sample = buffer + (i << 1);
- sample[L] = clamp(sample[L] + l, SHRT_MIN, SHRT_MAX); //
- sample[R] = clamp(sample[R] + r, SHRT_MIN, SHRT_MAX); //
- ++status.pos;
- if (status.pos > raw.samples && status.loop)
- status.pos = 0; // rewind
- else if (status.pos > raw.samples && !status.loop)
- break;
- }
- }
-
- Manager* Manager::get()
- {
- return (manager == nullptr ? manager = new Manager() : manager);
- }
-
- void Manager::processCommands()
- {
- Command* cmd = nullptr;
- SDLSource* source = nullptr;
- while (!commands.empty())
- {
- cmd = commands.front();
- if (cmd != nullptr)
- {
- source = cmd->source;
- if (source != nullptr)
- source->handle(manager, cmd);
- }
- commands.pop();
- }
- }
-
- /* AUDIO_S16SYS[size>>1] buffer */
- void Manager::processSources(void* buf, size_t size)
- {
- /* clear render buffer */
- memset(buf, 0, size);
- SDLSource* src = nullptr;
- std::vector<SDLSource*>::iterator it = sources.begin();
- for (; it != sources.end();)
- {
- src = *it;
- if (src != nullptr)
- src->process(buf, size);
- ++it;
- }
- }
-
- void Manager::removeSource(SDLSource* source)
- {
- std::vector<SDLSource*>::iterator it = sources.begin();
- for (it = sources.begin(); it != sources.end(); )
- {
- if (*it == source)
- {
- it = sources.erase(it);
- return;
- }
- ++it;
- }
- }
-
- void Manager::removeAllSource()
- {
- sources.clear();
- }
-
- void Manager::pushSource(SDLSource* source)
- {
- if (source != nullptr)
- sources.push_back(source);
- }
-
- void Manager::pushCommand(SDLSourceCommand* cmd)
- {
- commands.push(cmd);
- }
-
- Command* Manager::getCommand()
- {
- if (!commandsPool.empty())
- {
- Command* cmd = commandsPool.top();
- commandsPool.pop();
- return cmd;
- }
- return new Command();
- }
-
- } // namespace SDL
- } // namespace Audio
-} // namespace JinEngine
-
-#endif // (jin_audio) && (jin_audio == jin_audio_sdl) \ No newline at end of file
diff --git a/src/libjin/Audio/SDL/je_sdl_source.h b/src/libjin/Audio/SDL/je_sdl_source.h
deleted file mode 100644
index bbc8c7a..0000000
--- a/src/libjin/Audio/SDL/je_sdl_source.h
+++ /dev/null
@@ -1,272 +0,0 @@
-#ifndef __JE_SOURCE_SDL_H__
-#define __JE_SOURCE_SDL_H__
-#include "../../core/je_configuration.h"
-#if defined(jin_audio) && (jin_audio == jin_audio_sdl)
-
-#include <vector>
-#include <queue>
-#include <stack>
-#include <exception>
-
-#include "../je_source.h"
-
-namespace JinEngine
-{
- namespace Audio
- {
- namespace SDL
- {
-
- typedef struct SDLSourceCommand;
-
- class SDLSourceManager;
-
- ///
- /// Audio source SDL implementation.
- ///
- class SDLSource : public Source
- {
- public:
- ///
- /// Create source from raw source data file.
- ///
- /// @param file Audio source file.
- /// @return Return source if create successful, otherwise return null.
- ///
- static SDLSource* createSource(const char* file);
-
- ///
- /// Create source from raw source data.
- ///
- /// @param mem Source data.
- /// @param size Source data size.
- /// @return Return source if create successful, otherwise return null.
- ///
- static SDLSource* createSource(void* mem, size_t size);
-
- ///
- /// Source destructor.
- ///
- ~SDLSource();
-
- ///
- /// Play source.
- ///
- void play() override;
-
- ///
- /// Stop source.
- ///
- void stop() override;
-
- ///
- /// Pause source.
- ///
- void pause() override;
-
- ///
- /// Resume source.
- ///
- void resume() override;
-
- ///
- /// Rewind source.
- ///
- void rewind() override;
-
- ///
- /// Return if the source is stopped.
- ///
- /// @return True if the source is stopped, otherwise return false.
- ///
- bool isStopped() const override;
-
- ///
- /// Return if the source is paused.
- ///
- /// @return True if the source is paused(, otherwise return false.
- ///
- bool isPaused() const override;
-
- ///
- /// Set pitch.
- ///
- /// @param pitch Pitch of source.
- ///
- void setPitch(float pitch) override;
-
- ///
- /// Set volume.
- ///
- /// @param volume Volume of source.
- ///
- void setVolume(float volume) override;
-
- ///
- /// Set source loop.
- ///
- /// @param loop Looping or not.
- ///
- void setLoop(bool loop) override;
-
- ///
- /// Set source rate.
- ///
- /// @param rate Rate of source.
- ///
- void setRate(float rate) override;
-
- ///
- /// Handle a specific command.
- ///
- /// @param manager Audio manager.
- /// @param cmd Source commad.
- ///
- inline void handle(SDLSourceManager* manager, SDLSourceCommand* cmd);
-
- ///
- /// Process decoded source data.
- ///
- /// @param buffer Source data.
- /// @param size Data size.
- ///
- inline void process(void* buffer, size_t size);
-
- protected:
- ///
- /// Source constructor.
- ///
- SDLSource();
-
- ///
- /// Decode wav file.
- ///
- /// @param mem Wav file data.
- /// @param size Wav data size.
- ///
- void decode_wav(void* mem, int size);
-
- ///
- /// Decode ogg file.
- ///
- /// @param mem ogg file data.
- /// @param size ogg data size.
- ///
- void decode_ogg(void* mem, int size);
-
- ///
- /// Check source state.
- ///
- /// @param state State to be checked.
- /// @return True if state is given state, otherwise return false.
- ///
- inline bool is(int state) const
- {
- return (status.state & state) == state;
- }
-
- // Source data.
- struct {
- const void* data; // Ƶ
- int length; // dataֽڳ
- const void* end; // dataβ = (unsigned char*)data + size
- int samplerate; // Ƶ
- unsigned char bitdepth; // ÿsampleıس
- int samples; // sample = size / (bitdepth / 8)
- unsigned char channels; // channel1(mono)2(stereo)
- } raw;
- // Procedure controller variable.
- struct {
- int pos; // ǰŵsample
- int pitch; // pitch
- int state; // ǰ״̬
- bool loop; // loop or not
- float volume; //
- } status;
-
- };
-
- ///
- /// Source manager.
- ///
- class SDLSourceManager
- {
- public:
- ///
- /// Get manager singleton.
- ///
- /// @return Singleton of SDL source manager.
- ///
- static SDLSourceManager* get();
-
- ///
- /// Process commands.
- ///
- void processCommands();
-
- ///
- /// Process sources.
- ///
- /// @param buffer Source data.
- /// @param size Size of source data.
- ///
- void processSources(void* buffer, size_t size);
-
- ///
- /// Clear source queue.
- ///
- /// This function will stop all sources.
- ///
- void removeAllSource();
-
- ///
- /// Remove specific source.
- ///
- /// @param source SDL audio source.
- ///
- void removeSource(SDLSource* source);
-
- ///
- /// Push specific source into queue.
- ///
- /// @param source SDL audio source.
- ///
- void pushSource(SDLSource* source);
-
- ///
- /// Get command from queue.
- ///
- /// @return Command at first place.
- ///
- SDLSourceCommand* getCommand();
-
- ///
- /// Push command.
- ///
- /// @param cmd Spcific command.
- ///
- void pushCommand(SDLSourceCommand* cmd);
-
- private:
- std::queue<SDLSourceCommand*> commands;
- std::stack<SDLSourceCommand*> commandsPool;
- std::vector<SDLSource*> sources; // processing sources
- static SDLSourceManager* manager;
-
- };
-
- class SourceException : public std::exception
- {
- const char* what() const throw ()
- {
- return "Load Source Exception";
- }
- };
-
- } // namespace SDL
- } // namespace Audio
-} // namespace JinEngine
-
-#endif // (jin_audio) && (jin_audio == jin_audio_sdl)
-
-#endif // __JE_SOURCE_SDL_H__ \ No newline at end of file
diff --git a/src/libjin/Audio/je_audio_manager.cpp b/src/libjin/Audio/je_audio_manager.cpp
deleted file mode 100644
index e451aa3..0000000
--- a/src/libjin/Audio/je_audio_manager.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "../core/je_configuration.h"
-#if jin_audio
-
-#include "SDL2/SDL.h"
-#include "je_audio_manager.h"
-
-namespace JinEngine
-{
- namespace Audio
- {
-
- } // namespace Audio
-} // namespace JinEngine
-
-#endif // jin_audio
diff --git a/src/libjin/Audio/je_audio_manager.h b/src/libjin/Audio/je_audio_manager.h
deleted file mode 100644
index 120d38e..0000000
--- a/src/libjin/Audio/je_audio_manager.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef __JE_AUDIO_H__
-#define __JE_AUDIO_H__
-
-#include "../core/je_configuration.h"
-#if defined(jin_audio)
-
-#include "../utils/je_macros.h"
-#include "../common/je_subsystem.hpp"
-
-#include "SDL2/SDL.h"
-
-namespace JinEngine
-{
- namespace Audio
- {
-
- class Source;
-
- ///
- /// Audio manager.
- ///
- template<class SubAudio>
- class AudioManager : public Subsystem<SubAudio>
- {
- public:
- ///
- /// Audio state.
- ///
- enum State
- {
- PLAY ,
- STOP ,
- PAUSE,
- };
-
- ///
- /// Play all sources whose state is playing.
- ///
- virtual void play() = 0;
-
- ///
- /// Stop and remove all sources from the queue.
- ///
- virtual void stop() = 0;
-
- ///
- /// Pause audio.
- ///
- virtual void pause() = 0;
-
- ///
- /// Resume audio.
- ///
- virtual void resume() = 0;
-
- ///
- /// Set global audio volume.
- ///
- virtual void setVolume(float volume) = 0;
-
- protected:
- singleton(AudioManager);
-
- ///
- /// AudioManager constructor.
- ///
- AudioManager()
- : volume(1)
- , state(State::PLAY)
- {};
-
- ///
- /// AudioManager destructor.
- ///
- virtual ~AudioManager() {};
-
- float volume;
- State state;
-
- };
-
- } // namespace Audio
-} // namespace JinEngine
-
-#endif // jin_audio
-
-#endif // __JE_AUDIO_H__ \ No newline at end of file
diff --git a/src/libjin/Audio/je_source.cpp b/src/libjin/Audio/je_source.cpp
deleted file mode 100644
index 6bc1f4f..0000000
--- a/src/libjin/Audio/je_source.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "../core/je_configuration.h"
-#if defined(jin_audio)
-
-#include <cstring>
-
-#include "je_source.h"
-
-namespace JinEngine
-{
- namespace Audio
- {
-
- static int check_header(const void *data, int size, const char *str, int offset) {
- int len = strlen(str);
- return (size >= offset + len) && !memcmp((char*)data + offset, str, len);
- }
-
- SourceType Source::getType(const void* mem, int size)
- {
- if(check_header(mem, size, "WAVE", 8))
- return SourceType::WAV;
- if(check_header(mem, size, "OggS", 0))
- return SourceType::OGG;
- return SourceType::INVALID;
- }
-
- } // namespace Audio
-} // namespace JinEngine
-
-#endif // jin_audio
diff --git a/src/libjin/Audio/je_source.h b/src/libjin/Audio/je_source.h
deleted file mode 100644
index f60daf9..0000000
--- a/src/libjin/Audio/je_source.h
+++ /dev/null
@@ -1,116 +0,0 @@
-#ifndef __JE_AUDIO_SOURCE_H__
-#define __JE_AUDIO_SOURCE_H__
-#include "../core/je_configuration.h"
-#if defined(jin_audio)
-
-#include "SDL2/SDL.h"
-
-namespace JinEngine
-{
- namespace Audio
- {
-
- ///
- /// Audio source encoding type.
- ///
- enum SourceType
- {
- INVALID = 0,
- WAV,
- OGG,
- };
-
- ///
- /// Audio source.
- ///
- class Source
- {
- public:
- ///
- /// Source constructor.
- ///
- Source() {};
-
- ///
- /// Source destructor.
- ///
- virtual ~Source() {};
-
- ///
- /// Start playing source.
- ///
- virtual void play() = 0;
-
- ///
- /// Stop playing source.
- ///
- virtual void stop() = 0;
-
- ///
- /// Pause source.
- ///
- virtual void pause() = 0;
-
- ///
- /// Resume source.
- ///
- virtual void resume() = 0;
-
- ///
- /// Rewind source.
- ///
- virtual void rewind() = 0;
-
- ///
- /// Whether the source is playing or not.
- ///
- virtual bool isStopped() const = 0;
-
- ///
- /// Whether the source is paused or not.
- ///
- virtual bool isPaused() const = 0;
-
- ///
- /// Set source pitch.
- ///
- /// @param pitch Pitch of source.
- ///
- virtual void setPitch(float pitch) = 0;
-
- ///
- /// Set volume of source.
- ///
- /// @param volume Volume of source.
- ///
- virtual void setVolume(float volume) = 0;
-
- ///
- /// Set source loop.
- ///
- /// @param loop Looping or not.
- ///
- virtual void setLoop(bool loop) = 0;
-
- ///
- /// Set source rate.
- ///
- /// @param rate Rate of source.
- ///
- virtual void setRate(float rate) = 0;
-
- protected:
-
- ///
- /// Get type of source data.
- ///
- static SourceType getType(const void* mem, int size);
-
- };
-
- } // namespace Audio
-} // namespace JinEngine
-
-#endif // jin_audio
-
-#endif // __JE_AUDIO_SOURCE_H__ \ No newline at end of file
diff --git a/src/libjin/Common/je_array.hpp b/src/libjin/Common/je_array.hpp
deleted file mode 100644
index 8a5cbf1..0000000
--- a/src/libjin/Common/je_array.hpp
+++ /dev/null
@@ -1,123 +0,0 @@
-#ifndef __JE_COMMON_ARRAY_H__
-#define __JE_COMMON_ARRAY_H__
-
-namespace JinEngine
-{
-
- ///
- /// A array created on heap.
- ///
- template<typename T>
- class Array
- {
- public:
- ///
- /// Array constructor.
- ///
- Array()
- : length(0)
- , data(nullptr)
- {
- }
-
- ///
- /// Array constructor.
- ///
- /// @param l Length of array.
- ///
- Array(int l)
- {
- length = l;
- data = new T[l];
- }
-
- ///
- /// Array destructor.
- ///
- ~Array()
- {
- delete[] data;
- length = 0;
- }
-
- ///
- /// Get address of data.
- ///
- /// @return Address of data.
- ///
- T* operator &()
- {
- return data;
- }
-
- ///
- /// Get specific element of array.
- ///
- /// @return Element of array.
- ///
- T& operator[](int index)
- {
- return data[index];
- }
-
- ///
- /// Bind data with given data.
- ///
- /// @param data Data pointer.
- /// @param length Length of data.
- ///
- void bind(T* data, int length)
- {
- if (data != nullptr)
- delete data;
- this->data = data;
- this->length = length;
- }
-
- ///
- /// Add an element.
- ///
- /// @param v Value of element.
- ///
- void add(T value)
- {
- int len = length + 1;
- T* d = new T[len];
- memcpy(d, data, size());
- d[length] = value;
- bind(d, len);
- }
-
- ///
- /// Get size of data in byte.
- ///
- /// @return Size of data in byte.
- ///
- int size()
- {
- return sizeof(T) * length;
- }
-
- ///
- /// Get length of data.
- ///
- /// @return Count of data.
- ///
- int count()
- {
- return length;
- }
-
- private:
- // Disable new and delete.
- void* operator new(size_t t);
- void operator delete(void* ptr);
-
- T * data;
- unsigned int length;
-
- };
-
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Common/je_common.h b/src/libjin/Common/je_common.h
deleted file mode 100644
index 31b67c6..0000000
--- a/src/libjin/Common/je_common.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __JE_COMMON_H__
-#define __JE_COMMON_H__
-
-#include "je_exception.h"
-#include "je_array.hpp"
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Common/je_exception.cpp b/src/libjin/Common/je_exception.cpp
deleted file mode 100644
index 5489a42..0000000
--- a/src/libjin/Common/je_exception.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <stdarg.h>
-
-#include "je_exception.h"
-
-namespace JinEngine
-{
-
- Exception::Exception(const char *fmt, ...)
- {
- va_list args;
- int size_buffer = 256, size_out;
- char *buffer;
- while (true)
- {
- buffer = new char[size_buffer];
- memset(buffer, 0, size_buffer);
-
- va_start(args, fmt);
- size_out = vsnprintf(buffer, size_buffer, fmt, args);
- va_end(args);
-
- // see http://perfec.to/vsnprintf/pasprintf.c
- // if size_out ...
- // == -1 --> output was truncated
- // == size_buffer --> output was truncated
- // == size_buffer-1 --> ambiguous, /may/ have been truncated
- // > size_buffer --> output was truncated, and size_out
- // bytes would have been written
- if (size_out == size_buffer || size_out == -1 || size_out == size_buffer - 1)
- size_buffer *= 2;
- else if (size_out > size_buffer)
- size_buffer = size_out + 2; // to avoid the ambiguous case
- else
- break;
-
- delete[] buffer;
- }
- mMessage = std::string(buffer);
- delete[] buffer;
- }
-
- Exception::~Exception() throw()
- {
- }
-
-} // namespace JinEngine \ No newline at end of file
diff --git a/src/libjin/Common/je_exception.h b/src/libjin/Common/je_exception.h
deleted file mode 100644
index c319ebd..0000000
--- a/src/libjin/Common/je_exception.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __JE_EXCEPTION_H__
-#define __JE_EXCEPTION_H__
-
-#include <exception>
-#include <string>
-
-namespace JinEngine
-{
-
- ///
- /// Jin Exception.
- ///
- class Exception : public std::exception
- {
- public:
-
- ///
- /// Creates a new Exception according to printf-rules.
- ///
- /// @param fmt The format string (see printf).
- ///
- Exception(const char *fmt, ...);
- virtual ~Exception() throw();
-
- ///
- /// Returns a string containing reason for the exception.
- ///
- /// @return A description of the exception.
- ///
- inline virtual const char *what() const throw()
- {
- return mMessage.c_str();
- }
-
- private:
- ///
- /// Exception message.
- ///
- std::string mMessage;
-
- };
-
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Common/je_noncopyable.h b/src/libjin/Common/je_noncopyable.h
deleted file mode 100644
index eff7121..0000000
--- a/src/libjin/Common/je_noncopyable.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef __JE_NONCOPYABLE_H__
-#define __JE_NONCOPYABLE_H__
-
-namespace JinEngine
-{
-
- ///
- /// Class inherites this could not be copied.
- ///
- class Noncopyable
- {
- public:
- Noncopyable(void) { }
- virtual ~Noncopyable(void) { }
-
- private:
- Noncopyable(const Noncopyable& other);
- Noncopyable& operator=(const Noncopyable& other);
-
- };
-
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Common/je_object.h b/src/libjin/Common/je_object.h
deleted file mode 100644
index fb8221f..0000000
--- a/src/libjin/Common/je_object.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __JE_OBJECT_H__
-#define __JE_OBJECT_H__
-
-namespace JinEngine
-{
-
- ///
- /// Base class of all objects in Jin.
- ///
- class Object
- {
- };
-
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Common/je_pool.hpp b/src/libjin/Common/je_pool.hpp
deleted file mode 100644
index cb96c5b..0000000
--- a/src/libjin/Common/je_pool.hpp
+++ /dev/null
@@ -1,177 +0,0 @@
-///
-/// An O(1) Object Pool. Original from https://www.codeproject.com/Articles/746630/O-Object-Pool-in-Cplusplus
-///
-#ifndef __JE_POOL_H__
-#define __JE_POOL_H__
-
-#include <stdlib.h>
-#include <iostream>
-
-#include "je_types.h"
-
-namespace JinEngine
-{
-
- class DefaultMemoryAllocator
- {
- public:
- static inline void *Allocate(size_t size)
- {
- return ::operator new(size, ::std::nothrow);
- }
- static inline void Deallocate(void *pointer, size_t size)
- {
- ::operator delete(pointer);
- }
- };
-
- template<typename T, class TMemoryAllocator = DefaultMemoryAllocator>
- class Pool
- {
- private:
- struct _Node
- {
- void *_memory;
- size_t _capacity;
- _Node *_nextNode;
-
- _Node(size_t capacity)
- {
- if (capacity < 1)
- throw std::invalid_argument("capacity must be at least 1.");
-
- _memory = TMemoryAllocator::Allocate(_itemSize * capacity);
- if (_memory == NULL)
- throw std::bad_alloc();
-
- _capacity = capacity;
- _nextNode = NULL;
- }
- ~_Node()
- {
- TMemoryAllocator::Deallocate(_memory, _itemSize * _capacity);
- }
- };
-
- void *_nodeMemory;
- T *_firstDeleted;
- size_t _countInNode;
- size_t _nodeCapacity;
- _Node _firstNode;
- _Node *_lastNode;
- size_t _maxBlockLength;
-
- static const size_t _itemSize;
-
- Pool(const Pool<T, TMemoryAllocator> &source);
- void operator = (const Pool<T, TMemoryAllocator> &source);
-
- void _AllocateNewNode()
- {
- size_t size = _countInNode;
- if (size >= _maxBlockLength)
- size = _maxBlockLength;
- else
- {
- size *= 2;
-
- if (size < _countInNode)
- throw std::overflow_error("size became too big.");
-
- if (size >= _maxBlockLength)
- size = _maxBlockLength;
- }
-
- _Node *newNode = new _Node(size);
- _lastNode->_nextNode = newNode;
- _lastNode = newNode;
- _nodeMemory = newNode->_memory;
- _countInNode = 0;
- _nodeCapacity = size;
- }
-
- public:
- explicit Pool(size_t initialCapacity = 32, size_t maxBlockLength = 1000000)
- : _firstDeleted(NULL)
- , _countInNode(0)
- , _nodeCapacity(initialCapacity)
- , _firstNode(initialCapacity)
- , _maxBlockLength(maxBlockLength)
- {
- if (maxBlockLength < 1)
- throw std::invalid_argument("maxBlockLength must be at least 1.");
-
- _nodeMemory = _firstNode._memory;
- _lastNode = &_firstNode;
- }
- ~Pool()
- {
- _Node *node = _firstNode._nextNode;
- while (node)
- {
- _Node *nextNode = node->_nextNode;
- delete node;
- node = nextNode;
- }
- }
-
- T *New()
- {
- if (_firstDeleted)
- {
- T *result = _firstDeleted;
- _firstDeleted = *((T **)_firstDeleted);
- new(result) T();
- return result;
- }
-
- if (_countInNode >= _nodeCapacity)
- _AllocateNewNode();
-
- char *address = (char *)_nodeMemory;
- address += _countInNode * _itemSize;
- T *result = new(address) T();
- _countInNode++;
- return result;
- }
-
- // This method is useful if you want to call a non-default constructor.
- // It should be used like this:
- // new (pool.GetNextWithoutInitializing()) ObjectType(... parameters ...);
- T *GetNextWithoutInitializing()
- {
- if (_firstDeleted)
- {
- T *result = (T *)_firstDeleted;
- _firstDeleted = *((T **)_firstDeleted);
- return result;
- }
-
- if (_countInNode >= _nodeCapacity)
- _AllocateNewNode();
-
- char *address = (char *)_nodeMemory;
- address += _countInNode * _itemSize;
- _countInNode++;
- return (T *)address;
- }
- void Delete(T *content)
- {
- content->~T();
-
- *((T **)content) = _firstDeleted;
- _firstDeleted = content;
- }
- void DeleteWithoutDestroying(T *content)
- {
- *((T **)content) = _firstDeleted;
- _firstDeleted = content;
- }
- };
-
- template<typename T, class TMemoryAllocator>
- const size_t Pool<T, TMemoryAllocator>::_itemSize = ((sizeof(T) + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
-
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Common/je_singleton.hpp b/src/libjin/Common/je_singleton.hpp
deleted file mode 100644
index d7f52c9..0000000
--- a/src/libjin/Common/je_singleton.hpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef __JE_SINGLETON_H__
-#define __JE_SINGLETON_H__
-
-namespace JinEngine
-{
-
- ///
- /// Singleton base class.
- ///
- template<class T>
- class Singleton
- {
- public:
- ///
- /// Get singleton.
- ///
- /// @param Singleton instance of class.
- ///
- static T* get()
- {
- if (_instance == nullptr)
- _instance = new T;
- return _instance;
- }
-
- ///
- /// Destroy instance of singleton.
- ///
- static void destroy()
- {
- delete _instance;
- _instance = nullptr;
- }
-
- protected:
- ///
- /// Singleton constructor.
- ///
- Singleton() {};
-
- ///
- /// Singleton destructor.
- ///
- virtual ~Singleton() {};
-
- ///
- /// Singleton instance.
- ///
- static T* _instance;
-
- private:
- ///
- /// Singleton copy constructor.
- ///
- /// @param singleton Singleton of class.
- ///
- Singleton(const Singleton& singleton);
-
- ///
- /// Singleton assignment.
- ///
- /// @param singleton Singleton of class.
- ///
- Singleton& operator = (const Singleton& singleton);
-
- };
-
- ///
- /// Singleton instance.
- ///
- template<class T> T* Singleton<T>::_instance = nullptr;
-
- ///
- /// Singleton notation.
- ///
- #define singleton(T) friend Singleton<T>
-
-} // namespace JinEngine
-
-#endif // __JE_SINGLETON_H__
diff --git a/src/libjin/Common/je_stringmap.hpp b/src/libjin/Common/je_stringmap.hpp
deleted file mode 100644
index 7a3bd80..0000000
--- a/src/libjin/Common/je_stringmap.hpp
+++ /dev/null
@@ -1,143 +0,0 @@
-#ifndef __JE_COMMON_SREINGMAP_H__
-#define __JE_COMMON_SREINGMAP_H__
-
-namespace JinEngine
-{
-
- template<typename T, unsigned SIZE>
- class StringMap
- {
- private:
-
- struct Record
- {
- const char * key;
- T value;
- bool set;
- Record() : set(false) {}
- };
-
- const static unsigned MAX = SIZE * 2;
-
- Record records[MAX];
- const char * reverse[SIZE];
-
- public:
-
- struct Entry
- {
- const char * key;
- T value;
- };
-
- StringMap(Entry * entries, unsigned num)
- {
-
- for (unsigned i = 0; i < SIZE; ++i)
- reverse[i] = 0;
-
- unsigned n = num / sizeof(Entry);
-
- for (unsigned i = 0; i < n; ++i)
- {
- add(entries[i].key, entries[i].value);
- }
- }
-
- bool streq(const char * a, const char * b)
- {
- while (*a != 0 && *b != 0)
- {
- if (*a != *b)
- return false;
- ++a;
- ++b;
- }
-
- return (*a == 0 && *b == 0);
- }
-
- bool find(const char * key, T & t)
- {
- //unsigned str_hash = djb2(key);
-
- for (unsigned i = 0; i < MAX; ++i)
- {
- //unsigned str_i = (str_hash + i) % MAX; //this isn't used, is this intentional?
-
- if (records[i].set && streq(records[i].key, key))
- {
- t = records[i].value;
- return true;
- }
- }
-
- return false;
- }
-
- bool find(T key, const char *& str)
- {
- unsigned index = (unsigned)key;
-
- if (index >= SIZE)
- return false;
-
- if (reverse[index] != 0)
- {
- str = reverse[index];
- return true;
- }
- else
- {
- return false;
- }
- }
-
- bool add(const char * key, T value)
- {
- unsigned str_hash = djb2(key);
- bool inserted = false;
-
- for (unsigned i = 0; i < MAX; ++i)
- {
- unsigned str_i = (str_hash + i) % MAX;
-
- if (!records[str_i].set)
- {
- inserted = true;
- records[str_i].set = true;
- records[str_i].key = key;
- records[str_i].value = value;
- break;
- }
- }
-
- unsigned index = (unsigned)value;
-
- if (index >= SIZE)
- {
- printf("\nConstant %s out of bounds with %i!\n", key, index);
- return false;
- }
-
- reverse[index] = key;
-
- return inserted;
- }
-
- unsigned djb2(const char * key)
- {
- unsigned hash = 5381;
- int c;
-
- while ((c = *key++))
- hash = ((hash << 5) + hash) + c;
-
- return hash;
- }
-
- }; // StringMap
-
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Common/je_subsystem.hpp b/src/libjin/Common/je_subsystem.hpp
deleted file mode 100644
index c015bef..0000000
--- a/src/libjin/Common/je_subsystem.hpp
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef __JE_COMMON_SUBSYSTEM_H__
-#define __JE_COMMON_SUBSYSTEM_H__
-
-#include "../utils/je_macros.h"
-
-#include "je_singleton.hpp"
-
-namespace JinEngine
-{
-
- ///
- /// Subsystem class.
- ///
- template<class System>
- class Subsystem : public Singleton<System>
- {
- public:
- ///
- /// Subsystem setting.
- ///
- struct Setting
- {
- };
-
- typedef Setting SettingBase;
-
- ///
- /// Initialize subsystem.
- ///
- /// @param setting Subsystem setting.
- /// @return True if initialize sucessful, otherwise return false.
- ///
- bool init(const SettingBase* setting = nullptr)
- {
- static bool success = initSystem(setting);
- return success;
- }
-
- ///
- /// Quit subsystem.
- ///
- void quit()
- {
- // Call only once.
- static char __dummy__ = (quitSystem(), 1);
- Singleton<System>::destroy();
- }
-
- protected:
- singleton(System);
-
- ///
- /// Subsystem constructor.
- ///
- Subsystem() {};
-
- ///
- /// Subsystem destructor.
- ///
- virtual ~Subsystem()
- {
- };
-
- ///
- /// Initializer callback.
- ///
- virtual bool initSystem(const Setting* setting) = 0;
-
- ///
- /// Quit subsystem callback.
- ///
- virtual void quitSystem() = 0;
-
- };
-
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Common/je_temporary.h b/src/libjin/Common/je_temporary.h
deleted file mode 100644
index 647bfba..0000000
--- a/src/libjin/Common/je_temporary.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __JE_TEMPORARY_H__
-#define __JE_TEMPORARY_H__
-
-namespace JinEngine
-{
-
- ///
- /// Class inherites this clound only be created on stack or static zone.
- ///
- class Temporary
- {
- public:
- Temporary() {};
- virtual ~Temporary() {};
-/*
- protected:
- void operator delete(void* t)
- {
- if(t != nullptr)
- free(t);
- }
-*/
- private:
- // Disable new operands.
- void* operator new(size_t);
-
- };
-
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Common/je_types.h b/src/libjin/Common/je_types.h
deleted file mode 100644
index e31ce5e..0000000
--- a/src/libjin/Common/je_types.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __JE_TYPES_H__
-#define __JE_TYPES_H__
-#include <stdint.h>
-#include <stdlib.h>
-#include <cstring>
-
-namespace JinEngine
-{
-
- typedef int8_t int8; ///< Signed integer with a size of 8 bits. Supports values from -128 to 127
- typedef uint8_t uint8; ///< Unsigned integer with a size of 8 bits. Supports values from 0 to 255.
- typedef uint8 byte; ///< Unsigned integer with 8 bits (1 byte). Supports 256 values from 0 to 255.
- typedef int16_t int16; ///< Signed integer with a size of 16 bits. Supports values from -32768 to 32767
- typedef uint16_t uint16; ///< Unsigned integer with a size of 16 bits. Supports values from 0 to 65535.
- typedef int32_t int32; ///< Signed integer with a size of 32 bits. Supports values from -2147483648 to 2147483647.
- typedef uint32_t uint32; ///< Unsigned integer with a size of 32 bits. Supports values from 0 to 4294967295, (2^32 - 1).
- typedef int64_t int64; ///< Signed integer with a size of 64 bits. Supports values from -(2^63) to (2^63 - 1).
- typedef uint64_t uint64; ///< Unsigned integer with a size of 64 bits, Supports values from 0 to (2^64 - 1).
-
- typedef uint32_t uint;
- typedef int32_t sint;
-
-#define Union(name, ...) \
-union _Ctor{ \
- _Ctor() { memset(this, 0, sizeof(*this)); } \
- __VA_ARGS__; \
-} name;
-
-#define Struct(name, ...) \
-struct {__VA_ARGS__;} name;
-
-}
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Common/je_utf8.cpp b/src/libjin/Common/je_utf8.cpp
deleted file mode 100644
index bd7ce94..0000000
--- a/src/libjin/Common/je_utf8.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "../core/je_configuration.h"
-#if jin_os == jin_os_windows
-
-#include "je_utf8.h"
-
-namespace JinEngine
-{
-
- std::string to_utf8(LPCWSTR wstr)
- {
- size_t wide_len = wcslen(wstr) + 1;
-
- // Get size in UTF-8.
- int utf8_size = WideCharToMultiByte(CP_UTF8, 0, wstr, wide_len, 0, 0, 0, 0);
-
- char * utf8_str = new char[utf8_size];
-
- // Convert to UTF-8.
- int ok = WideCharToMultiByte(CP_UTF8, 0, wstr, wide_len, utf8_str, utf8_size, 0, 0);
-
- if (!ok)
- {
- delete[] utf8_str;
- }
-
- return ok ? std::string(utf8_str) : std::string();
- }
-
- void replace_char(std::string & str, char find, char replace)
- {
- int length = str.length();
-
- for (int i = 0; i<length; i++)
- {
- if (str[i] == find)
- str[i] = replace;
- }
- }
-
-} // namespace JinEngine
-
-#endif // jin_os == jin_os_windows \ No newline at end of file
diff --git a/src/libjin/Common/je_utf8.h b/src/libjin/Common/je_utf8.h
deleted file mode 100644
index d840b75..0000000
--- a/src/libjin/Common/je_utf8.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __JE_COMMON_UTF8_H__
-#define __JE_COMMON_UTF8_H__
-
-#include "../core/je_configuration.h"
-#if jin_os == jin_os_windows
-
-#include <string>
-#include <windows.h>
-
-namespace JinEngine
-{
-
- ///
- /// Convert the wide string to a UTF-8 encoded string.
- ///
- /// @param wstr The wide-char string.
- /// @return A UTF-8 string.
- ///
- std::string to_utf8(LPCWSTR wstr);
-
- ///
- /// Replace all occurences of 'find' with 'replace' in a string.
- ///
- /// @param str The string to modify.
- /// @param find The character to match.
- /// @param replace The character to replace matches.
- ///
- void replace_char(std::string & str, char find, char replace);
-
-} // namespace JinEngine
-
-#endif // jin_os == jin_os_windows
-
-#endif // __JE_COMMON_UTF8_H__
diff --git a/src/libjin/Core/README.md b/src/libjin/Core/README.md
deleted file mode 100644
index b393007..0000000
--- a/src/libjin/Core/README.md
+++ /dev/null
@@ -1 +0,0 @@
-ļµļƱṩһЩ汾Ϣ \ No newline at end of file
diff --git a/src/libjin/Core/je_configuration.h b/src/libjin/Core/je_configuration.h
deleted file mode 100644
index 80e2748..0000000
--- a/src/libjin/Core/je_configuration.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef __JE_COMMON_MODULES_H__
-#define __JE_COMMON_MODULES_H__
-
-#define jin_undefined 0x00
-
-///
-/// Debug output
-///
-#define jin_debug
-
-#define jin_os_windows 0x01
-#define jin_os_mac 0x02
-#define jin_os_linux 0x03
-#define jin_os jin_os_windows
-
-#define jin_graphics_font 0x02
-#define jin_graphics_shader 0x04
-#define jin_graphics_particle 0x08
-#define jin_graphics_animation 0x10
-#define jin_graphics (jin_graphics_font|jin_graphics_shader)
-
-#define jin_audio_sdl 0x01
-#define jin_audio_openal 0x02
-#define jin_audio jin_audio_sdl
-
-#define jin_filesystem_smount 0x01
-#define jin_filesystem jin_filesystem_smount
-
-#define jin_game
-
-#define jin_core
-
-#define jin_input_sdl 0x01
-#define jin_input jin_input_sdl
-
-#define jin_math
-
-#define jin_net_tekcos 0x01
-#define jin_net jin_net_tekcos
-
-#define jin_physics_newton 0x01
-#define jin_physics_box2d 0x02
-//#define jin_physics jin_physics_newton
-
-#define jin_thread_sdl 0x01
-#define jin_thread_cpp 0x02
-#define jin_thread_pthread 0x03
-#define jin_thread jin_thread_sdl
-
-#define jin_time_sdl 0x01
-#define jin_time_cpp 0x02
-#define jin_time jin_time_sdl
-
-#define jin_ai
-
-#define JIN_EXPORT __declspec(dllexport)
-
-#endif // __JE_COMMON_MODULES_H__ \ No newline at end of file
diff --git a/src/libjin/Core/je_version.h b/src/libjin/Core/je_version.h
deleted file mode 100644
index b5fe379..0000000
--- a/src/libjin/Core/je_version.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef __JE_CORE_VERSION_H__
-#define __JE_CORE_VERSION_H__
-
-namespace JinEngine
-{
- namespace Core
- {
-
- ///
- /// Get version of Jin.
- ///
- /// @return Version of Jin.
- ///
- const char* getVersion()
- {
- return "Jin 0.1";
- }
-
- ///
- /// Get author of Jin.
- ///
- /// @return Author of Jin.
- ///
- const char* getAuthor()
- {
- return "Chai";
- }
-
- ///
- /// Get release of Jin.
- ///
- /// @return release string of Jin.
- ///
- const char* getRelease()
- {
- return "Jin 0.1.1";
- }
-
- ///
- /// Get release of Jin.
- ///
- /// @return Revision of Jin.
- ///
- int getRevision()
- {
- return 101;
- }
-
- } // namespace Core
-} // namespace JinEngine
-
-#endif // __JE_CORE_VERSION_H__
diff --git a/src/libjin/Filesystem/je_asset_database.cpp b/src/libjin/Filesystem/je_asset_database.cpp
deleted file mode 100644
index a8524c5..0000000
--- a/src/libjin/Filesystem/je_asset_database.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "../core/je_configuration.h"
-#if defined(jin_filesystem)
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h> /* defines FILENAME_MAX */
-
-#include "../common/je_exception.h"
-
-#include "je_asset_database.h"
-
-namespace JinEngine
-{
- namespace Filesystem
- {
-
- AssetDatabase* AssetDatabase::mAssetDatabase = 0;
-
- AssetDatabase::AssetDatabase()
- {
- mSmt = smtnewshared();
- }
-
- AssetDatabase* AssetDatabase::get()
- {
- return mAssetDatabase ? mAssetDatabase : (mAssetDatabase = new AssetDatabase());
- }
-
- void AssetDatabase::mount(const char * path)
- {
- int err = smtmount(mSmt, path);
- if (err)
- {
- printf("%s mounted path %s", smterrstr(err), path);
- exit(1);
- }
- }
-
- void AssetDatabase::read(const char* path, Buffer& buffer)
- {
- size_t size;
- byte* data = (byte*)smtread(mSmt, path, &size);
- if (data == nullptr)
- throw Exception("Could not read file %s.", path);
- buffer.bind(data, size);
- }
-
- Buffer* read(const char* path)
- {
- return nullptr;
- }
-
- void* AssetDatabase::read(const char* path, unsigned int* len)
- {
- return smtread(mSmt, path, len);
- }
-
- const char* AssetDatabase::getFull(const char* path)
- {
- return smtfullpath(mSmt, path);
- }
-
- bool AssetDatabase::isDir(const char* path)
- {
- return smtisdir(mSmt, path);
- }
-
- bool AssetDatabase::isFile(const char* path)
- {
- return smtisreg(mSmt, path);
- }
-
- bool AssetDatabase::exists(const char* path)
- {
- return smtexists(mSmt, path) == 0;
- }
-/*
- std::vector<std::string> AssetDatabase::getFiles(const char* path, bool recursive)
- {
- }
-*/
- } // namespace Filesystem
-} // namespace JinEngine
-
-#endif // jin_filesystem \ No newline at end of file
diff --git a/src/libjin/Filesystem/je_asset_database.h b/src/libjin/Filesystem/je_asset_database.h
deleted file mode 100644
index e8b1bd1..0000000
--- a/src/libjin/Filesystem/je_asset_database.h
+++ /dev/null
@@ -1,114 +0,0 @@
-#ifndef __JE_ASSET_DATABASE_H__
-#define __JE_ASSET_DATABASE_H__
-
-#include "../core/je_configuration.h"
-#if defined(jin_filesystem)
-
-#include <vector>
-
-#include "smount/smount.h"
-
-#include "je_buffer.h"
-
-namespace JinEngine
-{
- namespace Filesystem
- {
-
- ///
- /// Assets managment.
- ///
- class AssetDatabase
- {
- public:
- ///
- /// Get asset database singleton.
- ///
- /// @param Singleton of asset database.
- ///
- static AssetDatabase* get();
-
- ///
- /// Asset database constructor.
- ///
- AssetDatabase();
-
- ///
- /// Set asset root folder.
- ///
- /// @param root Root folder of assets.
- ///
- void mount(const char* root);
-
- ///
- /// Check if the path is directory.
- ///
- /// @param path Path under asset folder.
- /// @return True if the given path is directory, otherwise return false.
- ///
- bool isDir(const char* path);
-
- ///
- /// Check if the path is file.
- ///
- /// @param path Path under asset folder.
- /// @return True if the given path is file, otherwise return false.
- ///
- bool isFile(const char* path);
-
- ///
- /// Check if the path exists.
- /// @param path Given path.
- /// @return True if path exists, otherwise return false.
- ///
- bool exists(const char* path);
-
- ///
- /// Read file into a buffer.
- ///
- /// @param path Path of file.
- /// @param buffer Buffer to fill.
- /// @return True if read sucessful, otherwise return false.
- ///
- void read(const char* path, Buffer& buffer);
-
- ///
- /// Read file and return data content.
- ///
- /// @param path Path of file.
- /// @param length Length of data.
- /// @return Data if read sucessful, otherwise return null.
- ///
- void* read(const char* path, unsigned int* length);
-
- ///
- /// Get files under given directory.
- ///
- /// @param path Path of directory.
- /// @param recursive Recursivily search folder.
- /// @return File list under given directory.
- ///
- std::vector<std::string> getFiles(const char* directory, bool recursive = false);
-
- ///
- /// Get full path of asset.
- ///
- /// @param path Path of asset.
- /// @return Full path of asset.
- ///
- const char* getFull(const char* path);
-
- private:
- static AssetDatabase* mAssetDatabase;
-#if jin_filesystem == jin_filesystem_smount
- smtShared* mSmt;
-#endif
-
- };
-
- } // namespace Filesystem
-} // namespace JinEngine
-
-#endif // jin_filesystem
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Filesystem/je_buffer.h b/src/libjin/Filesystem/je_buffer.h
deleted file mode 100644
index 1111e49..0000000
--- a/src/libjin/Filesystem/je_buffer.h
+++ /dev/null
@@ -1,169 +0,0 @@
-#ifndef __JE_BUFFER_H__
-#define __JE_BUFFER_H__
-
-#include "../core/je_configuration.h"
-#if defined(jin_filesystem)
-
-#include <string.h>
-#include <stdlib.h>
-
-#include "../common/je_temporary.h"
-#include "../common/je_types.h"
-
-namespace JinEngine
-{
- namespace Filesystem
- {
-
- ///
- /// Data buffer allocated on heap.
- ///
- class Buffer : public Temporary
- {
- public:
- ///
- /// Buffer constructor.
- ///
- Buffer()
- : mData(0)
- , mSize(0)
- {
- }
-
- ///
- /// Copy constructor.
- ///
- /// @param src Buffer source.
- ///
- Buffer(const Buffer& src)
- {
- delete[] mData;
- mSize = src.mSize;
- mData = new byte[mSize];
- memcpy(mData, src.mData, mSize);
- }
-
- ///
- /// Buffer constructor.
- ///
- /// @param data Buffer data.
- /// @param size Size of buffer.
- ///
- Buffer(void* data, int size)
- {
- mSize = size;
- mData = new byte[mSize];
- memcpy(mData, data, mSize);
- }
-
- ///
- /// Buffer constructor.
- ///
- /// @param size Size of data.
- ///
- Buffer(size_t size)
- {
- mData = new byte[size];
- memset(mData, 0, size);
- mSize = size;
- }
-
- ///
- /// Buffer destructor.
- ///
- ~Buffer()
- {
- delete[] mData;
- mSize = 0;
- }
-
- ///
- /// Set buffer data.
- ///
- /// @param data Buffer data.
- /// @param size Size of data.
- ///
- void set(byte* data, size_t size)
- {
- if (data == nullptr)
- return;
- if (mSize != size)
- {
- delete mData;
- mData = new byte[size];
- }
- mSize = size;
- memcpy(mData, data, size);
- }
-
- ///
- /// Bind buffer data.
- ///
- /// @param data Buffer data.
- /// @param size Size of buffer.
- ///
- void bind(byte* data, size_t size)
- {
- if (mData != nullptr)
- delete mData;
- mSize = size;
- mData = data;
- }
-
- ///
- /// Buffer assignment.
- ///
- /// @param buffer Buffer to copy.
- ///
- void operator = (const Buffer& buffer)
- {
- delete[] mData;
- mSize = buffer.mSize;
- mData = new byte[mSize];
- memcpy(mData, buffer.mData, mSize);
- }
-
- ///
- /// Get data addresss.
- ///
- /// @return Data address.
- ///
- const byte* operator &()
- {
- return mData;
- }
-
- ///
- /// Get data size.
- ///
- /// @return Size of data.
- ///
- const inline size_t size()
- {
- return mSize;
- }
-
- ///
- /// Clear data.
- ///
- void clear()
- {
- if (mData == nullptr)
- return;
- delete mData;
- mData = nullptr;
- mSize = 0;
- }
-
- private:
- byte* mData;
- size_t mSize;
-
- };
-
- } // namespace Filesystem
-} // namespace JinEngine
-
-#endif // jin_filesystem
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Game/je_application.cpp b/src/libjin/Game/je_application.cpp
deleted file mode 100644
index 723a809..0000000
--- a/src/libjin/Game/je_application.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "../core/je_configuration.h"
-#if defined(jin_game)
-
-#include <iostream>
-
-#include "../time/je_timer.h"
-#include "../input/je_event.h"
-#include "../graphics/je_window.h"
-#include "../graphics/je_gl.h"
-#include "../math/je_math.h"
-
-#include "je_application.h"
-
-using namespace JinEngine::Graphics;
-using namespace JinEngine::Input;
-using namespace JinEngine::Time;
-using namespace JinEngine::Math;
-
-namespace JinEngine
-{
- namespace Game
- {
-
- Application::Application() :_running(true) {};
-
- /* default game loop */
- void Application::run()
- {
- if (_onLoad != nullptr)
- _onLoad();
- Window* wnd = Window::get();
- const int FPS = wnd ? wnd->getFPS() : 60;
- const int MS_PER_UPDATE = 1000.0f / FPS;
- _running = true;
- Event e;
- int current = getMilliSecond();
- int previous = current;
- int dt = 0;
- while (_running)
- {
- while (JinEngine::Input::pollEvent(&e))
- {
- if (_onEvent != nullptr)
- _onEvent(&e);
- if (!_running)
- goto quitloop;
- }
- previous = current;
- current = getMilliSecond();
- dt = current - previous;
- if (_onUpdate != nullptr)
- _onUpdate(dt);
- glClear(GL_COLOR_BUFFER_BIT);
- if (_onDraw != nullptr)
- _onDraw();
- wnd->swapBuffers();
- sleep(1);
- }
- quitloop:;
- }
-
- bool Application::initSystem(const SettingBase* setting)
- {
- if (setting == nullptr)
- return false;
- Application::Setting* s = (Application::Setting*) setting;
- _onEvent = s->eventHandler;
- _onUpdate = s->updater;
- _onDraw = s->drawer;
- _onLoad = s->loader;
- return true;
- }
-
- void Application::quitSystem()
- {
- }
-
- } // namespace Core
-} // namespace JinEngine
-
-#endif // jin_game \ No newline at end of file
diff --git a/src/libjin/Game/je_application.h b/src/libjin/Game/je_application.h
deleted file mode 100644
index 094de6a..0000000
--- a/src/libjin/Game/je_application.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef __JE_CORE_GAME_H__
-#define __JE_CORE_GAME_H__
-
-#include "../core/je_configuration.h"
-#if defined(jin_game)
-
-#include "../common/je_subsystem.hpp"
-#include "../utils/je_macros.h"
-#include "../input/je_Event.h"
-
-#include "SDL2/SDL.h"
-
-namespace JinEngine
-{
- namespace Game
- {
-
- ///
- /// Game class.
- ///
- class Application : public Subsystem<Application>
- {
- public:
-
- typedef void(*onLoad)();
- typedef void(*onEvent)(JinEngine::Input::Event* e);
- typedef void(*onUpdate)(int dt);
- typedef void(*onDraw)();
-
- ///
- /// Game setting.
- ///
- struct Setting : SettingBase
- {
- onEvent eventHandler;
- onUpdate updater;
- onDraw drawer;
- onLoad loader;
- };
-
- ///
- /// Main game loop.
- ///
- void run();
-
- ///
- /// Stop game.
- ///
- inline void stop()
- {
- _running = false;
- };
-
- ///
- /// Return if game is running.
- ///
- /// @return True if game is running, otherwise return false.
- ///
- inline bool running()
- {
- return _running;
- };
-
- private:
-
- Application();
- ~Application() {};
-
- singleton(Application);
-
- onEvent _onEvent;
- onUpdate _onUpdate;
- onDraw _onDraw;
- onLoad _onLoad;
-
- bool _running;
-
- bool initSystem(const SettingBase* setting);
- void quitSystem();
-
- };
-
- } // namespace Core
-} // namespace JinEngine
-
-#endif // jin_game
-
-#endif // __JE_CORE_GAME_H__ \ No newline at end of file
diff --git a/src/libjin/Game/je_entity.cpp b/src/libjin/Game/je_entity.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/Game/je_entity.cpp
+++ /dev/null
diff --git a/src/libjin/Game/je_entity.h b/src/libjin/Game/je_entity.h
deleted file mode 100644
index 80c6ff3..0000000
--- a/src/libjin/Game/je_entity.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __JE_ENTITY_H__
-#define __JE_ENTITY_H__
-
-#include "je_gameobject.h"
-
-namespace JinEngine
-{
- namespace Game
- {
-/*
- ///
- ///
- ///
- class Entity : public GameObject
- {
- public:
- Entity();
-
- private:
-
-
- };
-*/
- } // namespace Game
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Game/je_gameobject.cpp b/src/libjin/Game/je_gameobject.cpp
deleted file mode 100644
index 1396518..0000000
--- a/src/libjin/Game/je_gameobject.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "je_entity.h"
-
-namespace JinEngine
-{
- namespace Game
- {
-
-
-
- } // namespace Game
-} // namespace JinEngine \ No newline at end of file
diff --git a/src/libjin/Game/je_gameobject.h b/src/libjin/Game/je_gameobject.h
deleted file mode 100644
index 7c6ec2b..0000000
--- a/src/libjin/Game/je_gameobject.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef __JE_GAME_OBJECT_H__
-#define __JE_GAME_OBJECT_H__
-
-#include "../core/je_configuration.h"
-#if defined(jin_game)
-
-#include <list>
-#include <map>
-#include <set>
-
-#include "../common/je_object.h"
-#include "../common/je_types.h"
-#include "../graphics/je_sprite.h"
-
-namespace JinEngine
-{
- namespace Game
- {
- /*
- ///
- /// Game object base class.
- ///
- class GameObject : public Object
- {
- public:
-
- ///
- ///
- ///
- virtual ~GameObject();
-
- ///
- ///
- ///
- void lifecycle();
-
- ///
- ///
- ///
- void setVisible(bool isVisible);
-
- ///
- ///
- ///
- void setActive(bool isActive);
-
- ///
- ///
- ///
- void setOrder(uint32 order);
-
- protected:
- virtual void onAlive();
- virtual void onUpdate(float dt);
- virtual void onDraw();
- virtual void onDestroy();
-
- uint32 mLayer; // layer where entity belongs
- uint32 mOrder; // render index in layer
- uint32 mTag; // tag of entity, support 32 tags now
- bool mIsVisible; // if the entity is visible or not
- bool mIsActive; // if the entity is joined into the logic
-
- Math::Transform mTransform;
-
- };
-
- ///
- /// Entity list. For quickly adding and removing entities.
- ///
- typedef std::list<GameObject*> EntityList;
-
- ///
- /// Entity set. For searching and keeps entities unique and sorted.
- ///
- typedef std::set<GameObject*> EntitySet;
- */
- } // namespace Game
-} // namespace JinEngine
-
-#endif // jin_game
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Game/je_scene.cpp b/src/libjin/Game/je_scene.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/Game/je_scene.cpp
+++ /dev/null
diff --git a/src/libjin/Game/je_scene.h b/src/libjin/Game/je_scene.h
deleted file mode 100644
index 811d1a8..0000000
--- a/src/libjin/Game/je_scene.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef __JE_GAME_SCENE_H__
-#define __JE_GAME_SCENE_H__
-
-#include "../core/je_configuration.h"
-#if defined(jin_game)
-
-#include <map>
-#include <list>
-
-#include "je_entity.h"
-
-namespace JinEngine
-{
- namespace Game
- {
-
- ///
- /// Handle all entities.
- ///
- class Scene
- {
- public:
- ///
- ///
- ///
- void addEntity(Entity* entity);
-
- ///
- ///
- ///
- EntityList& getEntitiesByTag(uint32 tag);
-
- ///
- ///
- ///
- EntityList& getEntitiesByLayer(uint32 layer);
-
- ///
- ///
- ///
- void setEntitiesActiveByTag(uint32 tag);
-
- ///
- ///
- ///
- void setEntitiesActiveByLayer(uint32 layer);
-
- ///
- ///
- ///
- void removeEntitiesByLayer(uint32 layer);
-
- ///
- ///
- ///
- void removeEntitiesByTag(uint32 tag);
-
- protected:
- // all entities
- EntitySet entities;
- // all entities grouped by layer, render order
- std::map<uint32, EntityList> layers;
- // all entities grouped by tag
- std::map<uint32, EntityList> tags;
-
- };
-
- } // namespace Game
-} // namespace JinEngine
-
-#endif // jin_game
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Graphics/particles/je_particle.h b/src/libjin/Graphics/particles/je_particle.h
index 70a2653..6da05ac 100644
--- a/src/libjin/Graphics/particles/je_particle.h
+++ b/src/libjin/Graphics/particles/je_particle.h
@@ -82,7 +82,7 @@ namespace JinEngine
RadialAccelarationDef radialAccelarationDef; ///<
AngularSpeedDef angularSpeedDef; ///<
// Optional definitions.
- ScaleOverTimeDef sizeOverTimeDef; ///<
+ ScaleOverTimeDef sizeOverTimeDef; ///<
ColorOverTimeDef colorOverTimeDef; ///<
};
diff --git a/src/libjin/Input/je_event.cpp b/src/libjin/Input/je_event.cpp
deleted file mode 100644
index 318ce59..0000000
--- a/src/libjin/Input/je_event.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "SDL2\SDL.h"
-
-#include "je_event.h"
-
-namespace JinEngine
-{
-
-} // namespace JinEngine \ No newline at end of file
diff --git a/src/libjin/Input/je_event.h b/src/libjin/Input/je_event.h
deleted file mode 100644
index 9fe34ff..0000000
--- a/src/libjin/Input/je_event.h
+++ /dev/null
@@ -1,121 +0,0 @@
-#ifndef __JE_EVENT_H__
-#define __JE_EVENT_H__
-#include "../core/je_configuration.h"
-#if defined(jin_input)
-
-namespace JinEngine
-{
- namespace Input
- {
- #if jin_input == jin_input_sdl
- #include "SDL.h"
-
- typedef SDL_Event Event;
- typedef SDL_Keycode Key;
- typedef SDL_MouseWheelEvent Wheel;
-
- ///
- ///
- ///
- enum EventType {
- QUIT = SDL_QUIT,
- /* keyboard events */
- KEY_DOWN = SDL_KEYDOWN,
- KEY_UP = SDL_KEYUP,
- /* mouse events */
- MOUSE_MOTION = SDL_MOUSEMOTION,
- MOUSE_BUTTON_DOWN = SDL_MOUSEBUTTONDOWN,
- MOUSE_BUTTON_UP = SDL_MOUSEBUTTONUP,
- MOUSE_WHEEL = SDL_MOUSEWHEEL,
- /* joypad events */
- JOYBUTTONDOWN = SDL_JOYBUTTONDOWN,
- JOYBUTTONUP = SDL_JOYBUTTONUP,
- JOYAXISMOTION = SDL_JOYAXISMOTION,
- JOYBALLMOTION = SDL_JOYBALLMOTION,
- JOYHATMOTION = SDL_JOYHATMOTION,
- JOYDEVICEADDED = SDL_JOYDEVICEADDED,
- JOYDEVICEREMOVED = SDL_JOYDEVICEREMOVED,
- CONTROLLERBUTTONDOWN = SDL_CONTROLLERBUTTONDOWN,
- CONTROLLERBUTTONUP = SDL_CONTROLLERBUTTONUP,
- CONTROLLERAXISMOTION = SDL_CONTROLLERAXISMOTION,
- /* window evnets */
- WINDOW_EVENT = SDL_WINDOWEVENT,
- };
-
- ///
- ///
- ///
- enum WindowEvent {
- WINDOW_SHOWN = SDL_WINDOWEVENT_SHOWN ,
- WINDOW_HIDDEN = SDL_WINDOWEVENT_HIDDEN ,
- WINDOW_EXPOSED = SDL_WINDOWEVENT_EXPOSED ,
- WINDOW_MOVED = SDL_WINDOWEVENT_MOVED ,
- WINDOW_RESIZED = SDL_WINDOWEVENT_RESIZED ,
- WINDOW_SIZE_CAHNGE = SDL_WINDOWEVENT_SIZE_CHANGED ,
- WINDOW_MINIMIZED = SDL_WINDOWEVENT_MINIMIZED ,
- WINDOW_MAXIMIZED = SDL_WINDOWEVENT_MAXIMIZED ,
- WINDOW_RESTORED = SDL_WINDOWEVENT_RESTORED ,
- WINDOW_ENTER = SDL_WINDOWEVENT_ENTER ,
- WINDOW_LEAVE = SDL_WINDOWEVENT_LEAVE ,
- WINDOW_FOCUS_GAINED = SDL_WINDOWEVENT_FOCUS_GAINED,
- WINDOW_FOCUS_LOST = SDL_WINDOWEVENT_FOCUS_LOST ,
- WINDOW_CLOSE = SDL_WINDOWEVENT_CLOSE ,
- WINDOW_TAKE_FOCUS = SDL_WINDOWEVENT_TAKE_FOCUS ,
- WINDOW_HIT_TEST = SDL_WINDOWEVENT_HIT_TEST ,
- };
-
- ///
- ///
- ///
- inline int pollEvent(Event* e)
- {
- return SDL_PollEvent(e);
- }
-
- ///
- ///
- ///
- inline const char* getKeyName(Key key)
- {
- return SDL_GetKeyName(key);
- }
-
- ///
- ///
- ///
- inline const char* getButtonName(int button)
- {
- switch (button)
- {
- case 1: return "Left";
- case 2: return "Middle";
- case 3: return "Right";
- case 4: return "WheelUp";
- case 5: return "WheelDown";
- default: return "?";
- }
- }
-
- /*
- inline const char* getWheelName(Wheel wheel)
- {
- if (wheel.x == -1)
- return "left";
- else if (wheel.x == 1)
- return "right";
- else if (wheel.y == -1)
- return "near";
- else if (wheel.y == 1)
- return "far";
- else
- return "none";
- }
- */
-
- #endif // jin_input == jin_input_sdl
- } // namespace Input
-} // namespace JinEngine
-
-#endif // defined(jin_input)
-
-#endif // __JE_EVENT_H__
diff --git a/src/libjin/Input/je_input.h b/src/libjin/Input/je_input.h
deleted file mode 100644
index 2abee0a..0000000
--- a/src/libjin/Input/je_input.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __JE_INPUT_H__
-#define __JE_INPUT_H__
-
-#include "je_event.h"
-#include "je_keyboard.h"
-#include "je_mouse.h"
-#include "je_joypad.h"
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Input/je_joypad.cpp b/src/libjin/Input/je_joypad.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/Input/je_joypad.cpp
+++ /dev/null
diff --git a/src/libjin/Input/je_joypad.h b/src/libjin/Input/je_joypad.h
deleted file mode 100644
index fb5dc38..0000000
--- a/src/libjin/Input/je_joypad.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef __JE_JOYPAD_H__
-#define __JE_JOYPAD_H__
-
-#include <SDL2/SDL.h>
-
-namespace JinEngine
-{
- namespace Input
- {
-
- ///
- ///
- ///
- inline const char* getJoyButtonName(int button)
- {
- switch (button)
- {
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_A: return "A"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_B : return "B"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_X : return "X"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_Y: return "Y"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_BACK: return "Back"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_GUIDE: return "Guide"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_START: return "Start"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_LEFTSTICK: return "LeftStick"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_RIGHTSTICK: return "RightStick"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_LEFTSHOULDER: return "LeftShoulder"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: return "RightShoulder"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_DPAD_UP: return "DpadUp"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_DPAD_DOWN: return "DpadDown"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_DPAD_LEFT: return "DpadLeft"; break;
- case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_DPAD_RIGHT: return "DpadRight"; break;
- default: return NULL;
- }
- }
-
- ///
- ///
- ///
- inline const char* getJoyAxisName(int axis)
- {
- switch (axis)
- {
- case SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_LEFTX: return "LeftX"; break;
- case SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_LEFTY: return "LeftY"; break;
- case SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_RIGHTX: return "RightX"; break;
- case SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_RIGHTY: return "RightY"; break;
- case SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_TRIGGERLEFT: return "TriggerLeft"; break;
- case SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_TRIGGERRIGHT: return "TriggerRight"; break;
- }
- }
-
- } // namespace Input
-} // namespace JinEngine
-
-#endif // __JE_JOYPAD_H__
diff --git a/src/libjin/Input/je_keyboard.cpp b/src/libjin/Input/je_keyboard.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/Input/je_keyboard.cpp
+++ /dev/null
diff --git a/src/libjin/Input/je_keyboard.h b/src/libjin/Input/je_keyboard.h
deleted file mode 100644
index 25cfd5d..0000000
--- a/src/libjin/Input/je_keyboard.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __JE_KEYBOARD_H__
-#define __JE_KEYBOARD_H__
-
-namespace JinEngine
-{
- namespace Input
- {
-
- ///
- ///
- ///
- class Keyboard
- {
-
- };
-
- } // namespace Input
-} // namespace JinEngine
-
-#endif // __JE_KEYBOARD_H__
diff --git a/src/libjin/Input/je_mouse.cpp b/src/libjin/Input/je_mouse.cpp
deleted file mode 100644
index 476b1a2..0000000
--- a/src/libjin/Input/je_mouse.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "../core/je_configuration.h"
-#if defined(jin_input)
-
-#include "SDL.h"
-
-#include "je_mouse.h"
-
-namespace JinEngine
-{
- namespace Input
- {
-
- void Mouse::getState(int* x, int* y)
- {
- #ifdef jin_input == jin_input_sdl
- SDL_GetMouseState(x, y);
- #endif
- }
-
- void Mouse::setVisible(bool visible)
- {
- SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE);
- }
-
- } // namespace Input
-} // namespace JinEngine
-
-#endif // defined(jin_input) \ No newline at end of file
diff --git a/src/libjin/Input/je_mouse.h b/src/libjin/Input/je_mouse.h
deleted file mode 100644
index 3c4ad9b..0000000
--- a/src/libjin/Input/je_mouse.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef __JE_MOUSE_H__
-#define __JE_MOUSE_H__
-#include "../core/je_configuration.h"
-#if defined(jin_input)
-
-#include "../common/je_singleton.hpp"
-
-namespace JinEngine
-{
- namespace Input
- {
-
- ///
- ///
- ///
- class Mouse : public Singleton<Mouse>
- {
- public:
- ///
- ///
- ///
- void getState(int* x, int* y);
-
- ///
- ///
- ///
- void setVisible(bool visible);
-
- private:
- singleton(Mouse);
-
- ///
- ///
- ///
- Mouse() {};
-
- ///
- ///
- ///
- ~Mouse() {};
-
- };
-
- } // namespace Input
-} // namespace JinEngine
-
-#endif // defined(jin_input)
-
-#endif // __JE_MOUSE_H__
diff --git a/src/libjin/Math/README.md b/src/libjin/Math/README.md
deleted file mode 100644
index a096332..0000000
--- a/src/libjin/Math/README.md
+++ /dev/null
@@ -1 +0,0 @@
-ļռΪJinEngineڴģ乲õ \ No newline at end of file
diff --git a/src/libjin/Math/je_bezier_curve.cpp b/src/libjin/Math/je_bezier_curve.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/Math/je_bezier_curve.cpp
+++ /dev/null
diff --git a/src/libjin/Math/je_bezier_curve.h b/src/libjin/Math/je_bezier_curve.h
deleted file mode 100644
index 6925baf..0000000
--- a/src/libjin/Math/je_bezier_curve.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __JIN_BEZIER_CURVE_H__
-#define __JIN_BEZIER_CURVE_H__
-
-namespace JinEngine
-{
- namespace Math
- {
-
- class BezierCurve
- {
-
- };
-
- } // namespace Math
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Math/je_constant.h b/src/libjin/Math/je_constant.h
deleted file mode 100644
index 45577e7..0000000
--- a/src/libjin/Math/je_constant.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __JE_MATH_CONSTANT_H__
-#define __JE_MATH_CONSTANT_H__
-
-#define PI 3.1415926f
-
-// int16 Χ
-#define INT16_RANGE_LEFT -32768
-#define INT16_RANGE_RIGHT 32767
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Math/je_ellipse.cpp b/src/libjin/Math/je_ellipse.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/Math/je_ellipse.cpp
+++ /dev/null
diff --git a/src/libjin/Math/je_ellipse.h b/src/libjin/Math/je_ellipse.h
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/Math/je_ellipse.h
+++ /dev/null
diff --git a/src/libjin/Math/je_math.h b/src/libjin/Math/je_math.h
deleted file mode 100644
index de57e36..0000000
--- a/src/libjin/Math/je_math.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef __JE_UTILS_MATH_H__
-#define __JE_UTILS_MATH_H__
-
-#include "je_constant.h"
-#include "je_matrix.h"
-#include "je_quad.h"
-
-namespace JinEngine
-{
- namespace Math
- {
-
- #ifdef min
- #undef min
- #endif // min
- #ifdef max
- #undef max
- #endif // max
-
- template<typename T>
- inline T min(T a, T b)
- {
- return a < b ? a : b;
- }
-
- template<typename T>
- inline T max(T a, T b)
- {
- return a > b ? a : b;
- }
-
- template<typename T>
- inline T clamp(T a, T mi, T ma)
- {
- return min<T>(max<T>(a, mi), ma);
- }
-
- template<typename T>
- inline bool within(T a, T mi, T ma)
- {
- return a >= mi && a <= ma;
- }
-
- template<typename T>
- inline bool without(T a, T mi, T ma)
- {
- return a < mi || a > ma;
- }
-
- template<typename T>
- inline T abs(T a)
- {
- return a > 0 ? a : -a;
- }
-
- template<typename T>
- inline T lowerBound(T a, T lower)
- {
- return a < lower ? lower : a;
- }
-
- template<typename T>
- inline T upperBound(T a, T upper)
- {
- return a > upper ? upper : a;
- }
-
- template<typename T>
- inline T lerp(T a, T b, float t)
- {
- return a + t * (b - a);
- }
-
- inline float lerp(float a, float b, float f)
- {
- f = clamp<float>(f, 0, 1);
- return a + f * (b - a);
- }
-
- } // namespace Math
-} // namespace JinEngine
-
-#endif // __JE_UTILS_MATH_H__
diff --git a/src/libjin/Math/je_matrix.cpp b/src/libjin/Math/je_matrix.cpp
deleted file mode 100644
index bc1fcea..0000000
--- a/src/libjin/Math/je_matrix.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-#include "je_matrix.h"
-
-#include <cstring> // memcpy
-#include <cmath>
-
-namespace JinEngine
-{
- namespace Math
- {
-
- const Matrix Matrix::Identity;
-
- // | e0 e4 e8 e12 |
- // | e1 e5 e9 e13 |
- // | e2 e6 e10 e14 |
- // | e3 e7 e11 e15 |
-
- Matrix::Matrix()
- {
- setIdentity();
- }
-
- Matrix::~Matrix()
- {
- }
-
- void Matrix::setOrtho(float l, float r, float b, float t, float n, float f)
- {
- setIdentity();
- float w = r - l;
- float h = t - b;
- float z = f - n;
- e[0] = 2 / w;
- e[5] = 2 / h;
- e[10] = -2 / z;
- e[12] = -(r + l) / w;
- e[13] = -(t + b) / h;
- e[14] = -(f + n) / z;
- e[15] = 1;
- }
-
- // | e0 e4 e8 e12 |
- // | e1 e5 e9 e13 |
- // | e2 e6 e10 e14 |
- // | e3 e7 e11 e15 |
- // | e0 e4 e8 e12 |
- // | e1 e5 e9 e13 |
- // | e2 e6 e10 e14 |
- // | e3 e7 e11 e15 |
-
- Matrix Matrix::operator * (const Matrix & m) const
- {
- Matrix t;
-
- t.e[0] = (e[0] * m.e[0]) + (e[4] * m.e[1]) + (e[8] * m.e[2]) + (e[12] * m.e[3]);
- t.e[4] = (e[0] * m.e[4]) + (e[4] * m.e[5]) + (e[8] * m.e[6]) + (e[12] * m.e[7]);
- t.e[8] = (e[0] * m.e[8]) + (e[4] * m.e[9]) + (e[8] * m.e[10]) + (e[12] * m.e[11]);
- t.e[12] = (e[0] * m.e[12]) + (e[4] * m.e[13]) + (e[8] * m.e[14]) + (e[12] * m.e[15]);
-
- t.e[1] = (e[1] * m.e[0]) + (e[5] * m.e[1]) + (e[9] * m.e[2]) + (e[13] * m.e[3]);
- t.e[5] = (e[1] * m.e[4]) + (e[5] * m.e[5]) + (e[9] * m.e[6]) + (e[13] * m.e[7]);
- t.e[9] = (e[1] * m.e[8]) + (e[5] * m.e[9]) + (e[9] * m.e[10]) + (e[13] * m.e[11]);
- t.e[13] = (e[1] * m.e[12]) + (e[5] * m.e[13]) + (e[9] * m.e[14]) + (e[13] * m.e[15]);
-
- t.e[2] = (e[2] * m.e[0]) + (e[6] * m.e[1]) + (e[10] * m.e[2]) + (e[14] * m.e[3]);
- t.e[6] = (e[2] * m.e[4]) + (e[6] * m.e[5]) + (e[10] * m.e[6]) + (e[14] * m.e[7]);
- t.e[10] = (e[2] * m.e[8]) + (e[6] * m.e[9]) + (e[10] * m.e[10]) + (e[14] * m.e[11]);
- t.e[14] = (e[2] * m.e[12]) + (e[6] * m.e[13]) + (e[10] * m.e[14]) + (e[14] * m.e[15]);
-
- t.e[3] = (e[3] * m.e[0]) + (e[7] * m.e[1]) + (e[11] * m.e[2]) + (e[15] * m.e[3]);
- t.e[7] = (e[3] * m.e[4]) + (e[7] * m.e[5]) + (e[11] * m.e[6]) + (e[15] * m.e[7]);
- t.e[11] = (e[3] * m.e[8]) + (e[7] * m.e[9]) + (e[11] * m.e[10]) + (e[15] * m.e[11]);
- t.e[15] = (e[3] * m.e[12]) + (e[7] * m.e[13]) + (e[11] * m.e[14]) + (e[15] * m.e[15]);
-
- return t;
- }
-
- void Matrix::operator *= (const Matrix & m)
- {
- Matrix t = (*this) * m;
- memcpy((void*)this->e, (void*)t.e, sizeof(float) * 16);
- }
-
- const float * Matrix::getElements() const
- {
- return e;
- }
-
- void Matrix::setIdentity()
- {
- memset(e, 0, sizeof(float) * 16);
- e[0] = e[5] = e[10] = e[15] = 1;
- }
-
- void Matrix::setTranslation(float x, float y)
- {
- setIdentity();
- e[12] = x;
- e[13] = y;
- }
-
- void Matrix::setRotation(float rad)
- {
- setIdentity();
- float c = cos(rad), s = sin(rad);
- e[0] = c; e[4] = -s;
- e[1] = s; e[5] = c;
- }
-
- void Matrix::setScale(float sx, float sy)
- {
- setIdentity();
- e[0] = sx;
- e[5] = sy;
- }
-
- void Matrix::setShear(float kx, float ky)
- {
- setIdentity();
- e[1] = ky;
- e[4] = kx;
- }
-
- void Matrix::setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy)
- {
- memset(e, 0, sizeof(float) * 16); // zero out matrix
- float c = cos(angle), s = sin(angle);
- // matrix multiplication carried out on paper:
- // |1 x| |c -s | |sx | |1 -ox|
- // | 1 y| |s c | | sy | | 1 -oy|
- // | 1 | | 1 | | 1 | | 1 |
- // | 1| | 1| | 1| | 1 |
- // move rotate scale origin
- e[10] = e[15] = 1.0f;
- e[0] = c * sx ; // = a
- e[1] = s * sx ; // = b
- e[4] = - s * sy; // = c
- e[5] = c * sy; // = d
- e[12] = x - ox * e[0] - oy * e[4];
- e[13] = y - ox * e[1] - oy * e[5];
- }
-
- void Matrix::translate(float x, float y)
- {
- Matrix t;
- t.setTranslation(x, y);
- this->operator *=(t);
- }
-
- void Matrix::rotate(float rad)
- {
- Matrix t;
- t.setRotation(rad);
- this->operator *=(t);
- }
-
- void Matrix::scale(float sx, float sy)
- {
- Matrix t;
- t.setScale(sx, sy);
- this->operator *=(t);
- }
-
- void Matrix::shear(float kx, float ky)
- {
- Matrix t;
- t.setShear(kx, ky);
- this->operator *=(t);
- }
-
- // | x |
- // | y |
- // | 0 |
- // | 1 |
- // | e0 e4 e8 e12 |
- // | e1 e5 e9 e13 |
- // | e2 e6 e10 e14 |
- // | e3 e7 e11 e15 |
-
- void Matrix::transform(vertex * dst, const vertex * src, int size) const
- {
- for (int i = 0; i<size; ++i)
- {
- // Store in temp variables in case src = dst
- float x = (e[0] * src[i].x) + (e[4] * src[i].y) + (0) + (e[12]);
- float y = (e[1] * src[i].x) + (e[5] * src[i].y) + (0) + (e[13]);
-
- dst[i].x = x;
- dst[i].y = y;
- }
- }
-
- } // namespace Math
-} // namespace JinEngine \ No newline at end of file
diff --git a/src/libjin/Math/je_matrix.h b/src/libjin/Math/je_matrix.h
deleted file mode 100644
index bbc831d..0000000
--- a/src/libjin/Math/je_matrix.h
+++ /dev/null
@@ -1,159 +0,0 @@
-#ifndef __JE_MATRIX_H__
-#define __JE_MATRIX_H__
-
-namespace JinEngine
-{
- namespace Math
- {
-
- struct vertex
- {
- unsigned char r, g, b, a;
- float x, y;
- float s, t;
- };
- ///
- /// This class is the basis for all transformations in LOVE. Althought not
- /// really needed for 2D, it contains 4x4 elements to be compatible with
- /// OpenGL without conversions.
- /// Ҫתõľ
- /// https://blog.csdn.net/candycat1992/article/details/8830894
- ///
- class Matrix
- {
- private:
-
- ///
- /// | e0 e4 e8 e12 |
- /// | e1 e5 e9 e13 |
- /// | e2 e6 e10 e14 |
- /// | e3 e7 e11 e15 |
- ///
- float e[16];
-
- public:
-
- static const Matrix Identity;
-
- ///
- /// Creates a new identity matrix.
- ///
- Matrix();
-
- ///
- /// Destructor.
- ///
- ~Matrix();
-
- void setOrtho(float _left, float _right, float _bottom, float _top, float _near, float _far);
-
- ///
- /// Multiplies this Matrix with another Matrix, changing neither.
- /// @param m The Matrix to multiply with this Matrix.
- /// @return The combined matrix.
- ///
- Matrix operator * (const Matrix & m) const;
-
- ///
- /// Multiplies a Matrix into this Matrix.
- /// @param m The Matrix to combine into this Matrix.
- ///
- void operator *= (const Matrix & m);
-
- ///
- /// Gets a pointer to the 16 array elements.
- /// @return The array elements.
- ///
- const float* getElements() const;
-
- ///
- /// Resets this Matrix to the identity matrix.
- ///
- void setIdentity();
-
- ///
- /// Resets this Matrix to a translation.
- /// @param x Translation along x-axis.
- /// @param y Translation along y-axis.
- ///
- void setTranslation(float x, float y);
-
- ///
- /// Resets this Matrix to a rotation.
- /// @param r The angle in radians.
- ///
- void setRotation(float r);
-
- ///
- /// Resets this Matrix to a scale transformation.
- /// @param sx Scale factor along the x-axis.
- /// @param sy Scale factor along the y-axis.
- ///
- void setScale(float sx, float sy);
-
- ///
- /// Resets this Matrix to a shear transformation.
- /// @param kx Shear along x-axis.
- /// @param ky Shear along y-axis.
- ///
- void setShear(float kx, float ky);
-
- ///
- /// Creates a transformation with a certain position, orientation, scale
- /// and offset. Perfect for Drawables -- what a coincidence!
- ///
- /// @param x The translation along the x-axis.
- /// @param y The translation along the y-axis.
- /// @param angle The rotation (rad) around the center with offset (ox,oy).
- /// @param sx Scale along x-axis.
- /// @param sy Scale along y-axis.
- /// @param ox The offset for rotation along the x-axis.
- /// @param oy The offset for rotation along the y-axis.
- /// @param kx Shear along x-axis
- /// @param ky Shear along y-axis
- ///
- void setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy);
-
- ///
- /// Multiplies this Matrix with a translation.
- /// @param x Translation along x-axis.
- /// @param y Translation along y-axis.
- ///
- void translate(float x, float y);
-
- ///
- /// Multiplies this Matrix with a rotation.
- /// @param r Angle in radians.
- ///
- void rotate(float r);
-
- ///
- /// Multiplies this Matrix with a scale transformation.
- /// @param sx Scale factor along the x-axis.
- /// @param sy Scale factor along the y-axis.
- ///
- void scale(float sx, float sy);
-
- ///
- /// Multiplies this Matrix with a shear transformation.
- /// @param kx Shear along the x-axis.
- /// @param ky Shear along the y-axis.
- ///
- void shear(float kx, float ky);
-
- ///
- /// Transforms an array of vertices by this Matrix. The sources and
- /// destination arrays may be the same.
- ///
- /// @param dst Storage for the transformed vertices.
- /// @param src The source vertices.
- /// @param size The number of vertices.
- ///
- void transform(vertex * dst, const vertex * src, int size) const;
-
- };
-
- } // namespace Math
-} // namespace JinEngine
-
-#endif // __JE_MATRIX_H__
diff --git a/src/libjin/Math/je_quad.h b/src/libjin/Math/je_quad.h
deleted file mode 100644
index 8a7bd64..0000000
--- a/src/libjin/Math/je_quad.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __JE_QUAD_H__
-#define __JE_QUAD_H__
-
-namespace JinEngine
-{
- namespace Math
- {
-
- ///
- ///
- ///
- struct Quad
- {
- ///
- ///
- ///
- float x, y, w, h;
- };
-
- } // namespace Math
-} // namespace JinEngine
-
-#endif // __JE_QUAD_H__
diff --git a/src/libjin/Math/je_random.cpp b/src/libjin/Math/je_random.cpp
deleted file mode 100644
index 216fd79..0000000
--- a/src/libjin/Math/je_random.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <math.h>
-#include "je_random.h"
-
-namespace JinEngine
-{
- namespace Math
- {
-
- RandomGenerator::RandomGenerator(uint32 seed)
- : mSeed(seed)
- {
- }
-
- uint32 RandomGenerator::rand()
- {
- unsigned int next = mSeed;
- uint32 result;
-
- next *= 1103515245;
- next += 12345;
- result = (unsigned int)(next / 65536) % 2048;
-
- next *= 1103515245;
- next += 12345;
- result <<= 10;
- result ^= (unsigned int)(next / 65536) % 1024;
-
- next *= 1103515245;
- next += 12345;
- result <<= 10;
- result ^= (unsigned int)(next / 65536) % 1024;
-
- mSeed = next;
-
- return result;
- }
-
- uint32 RandomGenerator::rand(uint32 min, uint32 max)
- {
- uint32 n = rand();
- return n % (max - min + 1) + min;
- }
-
- float RandomGenerator::randf(float min, float max, int ac)
- {
- uint32 a = pow(10.f, ac);
- uint32 n = rand(min*a, max*a);
- return (float)n / a;
- }
-
- }
-} \ No newline at end of file
diff --git a/src/libjin/Math/je_random.h b/src/libjin/Math/je_random.h
deleted file mode 100644
index 0f53155..0000000
--- a/src/libjin/Math/je_random.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __JE_RANDOM_H__
-#define __JE_RANDOM_H__
-
-#include "../common/je_types.h"
-
-namespace JinEngine
-{
- namespace Math
- {
-
- ///
- /// A random number generator.
- ///
- class RandomGenerator
- {
- public:
- RandomGenerator(uint32 seed);
-
- uint32 rand();
-
- uint32 rand(uint32 min, uint32 max);
-
- float randf(float min, float max, int ac);
-
- private:
- uint32 mSeed;
-
- };
-
- } // namespace Math
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Math/je_transform.cpp b/src/libjin/Math/je_transform.cpp
deleted file mode 100644
index c0676cb..0000000
--- a/src/libjin/Math/je_transform.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-#include "je_transform.h"
-
-namespace JinEngine
-{
- namespace Math
- {
-
- Transform::Transform()
- : mScale(1, 1)
- , mPosition(0, 0)
- , mOrigin(0, 0)
- , mRotation(0)
- {
- }
-
- void Transform::set(float x, float y, float sx, float sy, float r, float ox, float oy)
- {
- setPosition(x, y);
- setScale(sx, sy);
- setRotation(r);
- setOrigin(ox, oy);
- }
-
- void Transform::setScale(float sx, float sy)
- {
- mScale.set(sx, sy);
- }
-
- Vector2<float> Transform::getScale() const
- {
- return mScale;
- }
-
- void Transform::scale(float sx, float sy)
- {
- mScale.x *= sx;
- mScale.y *= sy;
- }
-
- void Transform::setPosition(const Vector2<float>& p)
- {
- setPosition(p.x, p.y);
- }
-
- void Transform::setPosition(float x, float y)
- {
- mPosition.set(x, y);
- }
-
- Vector2<float> Transform::getPosition() const
- {
- return mPosition;
- }
-
- void Transform::move(float x, float y)
- {
- mPosition.x += x;
- mPosition.y += y;
- }
-
- void Transform::move(const Vector2<float>& v)
- {
- move(v.x, v.y);
- }
-
- void Transform::setOrigin(float x, float y)
- {
- mOrigin.set(x, y);
- }
-
- Vector2<float> Transform::getOrigin() const
- {
- return mOrigin;
- }
-
- void Transform::setRotation(float r)
- {
- mRotation = r;
- }
-
- float Transform::getRotation() const
- {
- return mRotation;
- }
-
- void Transform::rotate(float r)
- {
- mRotation += r;
- }
-
- Matrix Transform::getMatrix() const
- {
- Matrix m;
- m.setTransformation(mPosition.x, mPosition.y, mRotation, mScale.x, mScale.y, mOrigin.x, mOrigin.y);
- return m;
- }
-
- }
-} \ No newline at end of file
diff --git a/src/libjin/Math/je_transform.h b/src/libjin/Math/je_transform.h
deleted file mode 100644
index cb1f0ee..0000000
--- a/src/libjin/Math/je_transform.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef __JE_TRANSFORM_H__
-#define __JE_TRANSFORM_H__
-
-#include "je_matrix.h"
-#include "je_vector2.hpp"
-
-namespace JinEngine
-{
- namespace Math
- {
-
- class Transform
- {
- public:
- Transform();
-
- void set(float x, float y, float sx, float sy, float r, float ox, float oy);
-
- void setScale(float sx, float sy);
- Vector2<float> getScale() const;
- void scale(float sx, float sy);
-
- void setPosition(float x, float y);
- void setPosition(const Vector2<float>& p);
- Vector2<float> getPosition() const;
- void move(float x, float y);
- void move(const Vector2<float>& v);
-
- void setOrigin(float x, float y);
- Vector2<float> getOrigin() const;
-
- void setRotation(float r);
- float getRotation() const;
- void rotate(float r);
-
- Matrix getMatrix() const;
-
- private:
- Vector2<float> mScale;
- Vector2<float> mPosition;
- Vector2<float> mOrigin;
- float mRotation;
-
- };
-
- }
-}
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Math/je_vector2.hpp b/src/libjin/Math/je_vector2.hpp
deleted file mode 100644
index b4cab44..0000000
--- a/src/libjin/Math/je_vector2.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef __JE_VECTOR_H__
-#define __JE_VECTOR_H__
-
-namespace JinEngine
-{
- namespace Math
- {
-
- template<typename T>
- class Vector2
- {
- public:
- Vector2()
- {
- data[0] = data[1] = 0;
- }
- Vector2(T _x, T _y)
- {
- data[0] = _x;
- data[1] = _y;
- }
- Vector2(const Vector2<T>& v)
- {
- data[0] = v.data[0];
- data[1] = v.data[1];
- }
-
- void operator = (const Vector2<T>& v)
- {
- data[0] = v.data[0];
- data[1] = v.data[1];
- }
-
- Vector2<T> operator * (float n)
- {
- return Vector2<T>(data[0]*n, data[1]*n);
- }
-
- void operator +=(const Vector2<T> v)
- {
- data[0] += v.data[0];
- data[1] += v.data[1];
- }
-
- void set(T _x, T _y)
- {
- data[0] = _x;
- data[1] = _y;
- }
-
- T &x = data[0], &y = data[1]; // xy
- T &w = data[0], &h = data[1]; // wh
- T &colum = data[0], &row = data[1]; // colum row
-
- private:
- T data[2];
-
- };
-
- } // namespace Math
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Math/je_vector3.hpp b/src/libjin/Math/je_vector3.hpp
deleted file mode 100644
index fdab2d0..0000000
--- a/src/libjin/Math/je_vector3.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef __JE_VECTOR3_H__
-#define __JE_VECTOR3_H__
-
-namespace JinEngine
-{
- namespace Math
- {
-
- template<typename T>
- class Vector3
- {
- public:
- Vector3()
- {
- data[0] = data[1] = data[2] = 0;
- }
- Vector3(T _x, T _y, T _z)
- {
- data[0] = _x;
- data[1] = _y;
- data[2] = _z;
- }
- Vector3(const Vector3<T>& v)
- {
- data[0] = v.data[0];
- data[1] = v.data[1];
- data[2] = v.data[2];
- }
-
- T &x = data[0], &y = data[1], &z = data[2]; // xyz
- T &r = data[0], &g = data[1], &b = data[2]; // rgb
-
- private:
- T data[3];
-
- };
-
- } // namespace Math
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Math/je_vector4.hpp b/src/libjin/Math/je_vector4.hpp
deleted file mode 100644
index 5cd5b35..0000000
--- a/src/libjin/Math/je_vector4.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __JE_VECTOR4_H__
-#define __JE_VECTOR4_H__
-
-namespace JinEngine
-{
- namespace Math
- {
-
- template<typename T>
- class Vector4
- {
- public:
- Vector4()
- {
- data[0] = data[1] = data[2] = data[3] = 0;
- }
- Vector4(T _x, T _y, T _z, T _t)
- {
- data[0] = _x;
- data[1] = _y;
- data[2] = _z;
- data[3] = _t;
- }
- Vector4(const Vector4<T>& v)
- {
- data[0] = v.data[0];
- data[1] = v.data[1];
- data[2] = v.data[2];
- data[3] = v.data[3];
- }
-
- T &x = data[0], &y = data[1], &z = data[2], &t = data[3]; // xyzt
- T &w = data[2], &h = data[3]; // xywh
- T &r = data[0], &g = data[1], &b = data[2], &a = data[3]; // rgb
- T &left = data[0], &right = data[1], &top = data[2], &bottom = data[3]; // lrtb
-
- private:
- T data[4];
-
- };
-
- } // namespace Math
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Net/je_net_manager.cpp b/src/libjin/Net/je_net_manager.cpp
deleted file mode 100644
index c4f822e..0000000
--- a/src/libjin/Net/je_net_manager.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "je_net_manager.h"
-
-namespace JinEngine
-{
- namespace Net
- {
-
- bool NetManager::initSystem(const SettingBase* setting)
- {
- #ifdef _WIN32
- #if jin_net == jin_net_tekcos
- tk_init();
- #endif
- #endif
- return true;
- }
-
- void NetManager::quitSystem()
- {
-
- }
-
- } // namespace Net
-} // namespace JinEngine \ No newline at end of file
diff --git a/src/libjin/Net/je_net_manager.h b/src/libjin/Net/je_net_manager.h
deleted file mode 100644
index 62aa947..0000000
--- a/src/libjin/Net/je_net_manager.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef __JE_NET_H__
-#define __JE_NET_H__
-#include "../core/je_configuration.h"
-#if defined(jin_net)
-
-#include "../common/je_subsystem.hpp"
-
-#include "je_socket.h"
-
-namespace JinEngine
-{
- namespace Net
- {
-
- ///
- ///
- ///
- class NetManager : public Subsystem<NetManager>
- {
- protected:
- singleton(NetManager);
-
- ///
- ///
- ///
- NetManager() {};
-
- ///
- ///
- ///
- ~NetManager() {};
-
- ///
- ///
- ///
- bool initSystem(const SettingBase* setting) override;
-
- ///
- ///
- ///
- void quitSystem() override;
-
- };
-
- } // namespace Net
-} // namespace JinEngine
-
-#endif // defined(jin_net)
-
-#endif // __JE_NET_H__
diff --git a/src/libjin/Net/je_socket.cpp b/src/libjin/Net/je_socket.cpp
deleted file mode 100644
index 1810601..0000000
--- a/src/libjin/Net/je_socket.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-#include "je_socket.h"
-
-namespace JinEngine
-{
- namespace Net
- {
- Socket::Socket(const Socket& socket)
- : mHandle(socket.mHandle)
- , mType(socket.mType)
- {
- }
-
- Socket::Socket(const SocketInformation& info)
- : mType(info.type)
- {
- if (mType == SocketType::TCP)
- {
- tk_IPaddress ip;
- ip.host = info.address;
- ip.port = info.port;
- mHandle.tcpHandle = tk_tcp_open(ip);
- }
- else if (mType == SocketType::UDP)
- {
- mHandle.udpHandle = tk_udp_open(info.port);
- }
- }
-
- Socket::Socket(SocketType type, const char* address, unsigned short port)
- {
- mType = type;
- if (mType == SocketType::TCP)
- {
- tk_IPaddress ip;
- #if jin_net == jin_net_tekcos
- ip.host = tk_strtohl(address);
- ip.port = port;
- mHandle.tcpHandle = tk_tcp_open(ip);
- #endif
- }
- else if (mType == SocketType::UDP)
- {
- mHandle.udpHandle = tk_udp_open(port);
- }
- }
-
- Socket::Socket(SocketType type, unsigned int address, unsigned short port)
- {
- mType = type;
- if (mType == SocketType::TCP)
- {
- tk_IPaddress ip;
- ip.host = address;
- ip.port = port;
- mHandle.tcpHandle = tk_tcp_open(ip);
- }
- else if (mType == SocketType::UDP)
- {
- mHandle.udpHandle = tk_udp_open(port);
- }
- }
-
- Socket::Socket(SocketType type, unsigned short port)
- {
- mType = type;
- if (mType == SocketType::TCP)
- {
- tk_IPaddress ip;
- ip.host = 0;
- ip.port = port;
- mHandle.tcpHandle = tk_tcp_open(ip);
- }
- else if (mType == SocketType::UDP)
- {
- mHandle.udpHandle = tk_udp_open(port);
- }
- }
-
- #if jin_net == jin_net_tekcos
-
- Socket::Socket(const tk_TCPsocket& tcphandle)
- {
- mHandle.tcpHandle = tcphandle;
- }
-
- Socket::Socket(const tk_UDPsocket& udphandle)
- {
- mHandle.udpHandle = udphandle;
- }
-
- #endif // jin_net == jin_net_tekcos
-
- Socket::~Socket()
- {
- }
-
- void Socket::configureBlocking(bool blocking)
- {
- if (mType != SocketType::TCP)
- return;
- #if jin_net == jin_net_tekcos
- if (blocking)
- tk_tcp_blocking(&mHandle.tcpHandle);
- else
- tk_tcp_nonblocking(&mHandle.tcpHandle);
- #endif
- }
-
- Socket* Socket::accept()
- {
- if (mType != SocketType::TCP)
- return nullptr;
- Socket* client;
- #if jin_net == jin_net_tekcos
- tk_TCPsocket socket = tk_tcp_accept(&mHandle.tcpHandle);
- client = new Socket(socket);
- #endif
- return client;
- }
-
- int Socket::receive(char* buffer, int size)
- {
- if (mType != SocketType::TCP)
- return 0;
- #if jin_net == jin_net_tekcos
- int len;
- tk_tcp_recv(&mHandle.tcpHandle, buffer, size, &len);
- return len;
- #endif
- }
-
- int Socket::send(char* buffer, int size)
- {
- if (mType != SocketType::TCP)
- return 0;
- #if jin_net == jin_net_tekcos
- int len;
- tk_tcp_send(&mHandle.tcpHandle, buffer, size, &len);
- return len;
- #endif
- }
-
- void Socket::sendTo(char* buffer, int size, unsigned int address, unsigned int port)
- {
- if (mType != SocketType::UDP)
- return;
- #if jin_net == jin_net_tekcos
- tk_UDPpack pack;
- pack.data = buffer;
- pack.len = size;
- pack.ip.host = address;
- pack.ip.port = port;
- tk_udp_sendto(&mHandle.udpHandle, &pack);
- #endif
- }
-
- int Socket::receiveFrom(char* buffer, int size, unsigned int address, unsigned int port)
- {
- if (mType != SocketType::UDP)
- return 0;
- int len;
- #if jin_net == jin_net_tekcos
- tk_UDPpack pack;
- pack.data = buffer;
- pack.len = size;
- pack.ip.host = address;
- pack.ip.port = port;
- tk_udp_recvfrom(&mHandle.udpHandle, &pack);
- return pack.len;
- #endif
- }
-
- void Socket::close()
- {
- if (mType == SocketType::TCP)
- {
- #if jin_net == jin_net_tekcos
- tk_tcp_close(&mHandle.tcpHandle);
- #endif
- }
- else if (mType == SocketType::UDP)
- {
- #if jin_net == jin_net_tekcos
- tk_udp_close(&mHandle.udpHandle);
- #endif
- }
- }
-
- } // namespace Net
-} // namespace JinEngine \ No newline at end of file
diff --git a/src/libjin/Net/je_socket.h b/src/libjin/Net/je_socket.h
deleted file mode 100644
index eb01719..0000000
--- a/src/libjin/Net/je_socket.h
+++ /dev/null
@@ -1,144 +0,0 @@
-#ifndef __JE_NET_SOCKET_H__
-#define __JE_NET_SOCKET_H__
-#include "../core/je_configuration.h"
-#if defined(jin_net)
-
-#include "tekcos/tekcos.h"
-
-namespace JinEngine
-{
- namespace Net
- {
-
- ///
- ///
- ///
- enum SocketType
- {
- TCP,
- UDP
- };
-
- ///
- ///
- ///
- struct SocketInformation
- {
- unsigned int address;
- unsigned short port;
- SocketType type;
- };
-
- ///
- ///
- ///
- class Socket
- {
- public:
-
- ///
- ///
- ///
- Socket() {};
-
- ///
- ///
- ///
- Socket(const Socket& socket);
-
- ///
- ///
- ///
- Socket(const SocketInformation& socketInformation);
-
- ///
- ///
- ///
- Socket(SocketType type, unsigned short port);
-
- ///
- ///
- ///
- Socket(SocketType type, unsigned int address, unsigned short port);
-
- ///
- ///
- ///
- Socket(SocketType type, const char* address, unsigned short port);
-
- ///
- ///
- ///
- ~Socket();
-
- ///
- ///
- ///
- void configureBlocking(bool bocking);
-
- ///
- ///
- ///
- Socket* accept();
-
- ///
- ///
- ///
- int receive(char* buffer, int size);
-
- ///
- ///
- ///
- int send(char* buffer, int size);
-
- ///
- ///
- ///
- void sendTo(char* buffer, int size, unsigned int address, unsigned int port);
-
- ///
- ///
- ///
- int receiveFrom(char* buffer, int size, unsigned int address, unsigned int port);
-
- ///
- ///
- ///
- void close();
-
- protected:
- #if jin_net == jin_net_tekcos
-
- ///
- ///
- ///
- Socket(const tk_TCPsocket& tcpHandle);
-
- ///
- ///
- ///
- Socket(const tk_UDPsocket& udpHandle);
-
- ///
- ///
- ///
- union
- {
- tk_TCPsocket tcpHandle;
- tk_UDPsocket udpHandle;
- } mHandle;
- #endif
-
- ///
- ///
- ///
- SocketType mType;
-
- };
-
- } // namespace Net
-} // namespace JinEngine
-
-#endif // defined(jin_net)
-
-#endif // __JE_NET_SOCKET_H__ \ No newline at end of file
diff --git a/src/libjin/Time/je_timer.cpp b/src/libjin/Time/je_timer.cpp
deleted file mode 100644
index 8dc5e86..0000000
--- a/src/libjin/Time/je_timer.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "../core/je_configuration.h"
-#if defined(jin_time)
-
-#include "je_timer.h"
-
-namespace JinEngine
-{
- namespace Time
- {
-
-
- Timer::Timer()
- : mHandlers()
- {
- }
-
- Timer::~Timer()
- {
- for (int i = 0; i < mHandlers.size(); ++i)
- delete mHandlers[i];
- }
-
- void Timer::update(float dt)
- {
- // Process handler.
- std::vector<Handler*>::iterator it = mHandlers.begin();
- for (; it != mHandlers.end(); ++it)
- (*it)->process(dt);
- // Erase canceled handler.
- for (it = mHandlers.begin(); it != mHandlers.end();)
- {
- if ((*it)->canceled)
- {
- Handler* h = *it;
- it = mHandlers.erase(it);
- delete h;
- }
- else
- ++it;
- }
- }
-
- void Timer::cancel(Handler* handler)
- {
- if(handler != nullptr)
- handler->canceled = true;
- }
-
- void Timer::cancelAll()
- {
- for (auto h : mHandlers)
- cancel(h);
- }
-
- Timer::Handler* Timer::every(float dt, TimerCallback callback, void* p, FinishCallback finish)
- {
- Handler* t = new Handler(Handler::EVERY, dt, 0, callback, p, finish);
- mHandlers.push_back(t);
- return t;
- }
-
- Timer::Handler* Timer::after(float dt, TimerCallback callback, void* p, FinishCallback finish)
- {
- Handler* t = new Handler(Handler::AFTER, dt, 0, callback, p, finish);
- mHandlers.push_back(t);
- return t;
- }
-
- Timer::Handler* Timer::repeat(float dt, int count, TimerCallback callback, void* p, FinishCallback finish)
- {
- Handler* t = new Handler(Handler::REPEAT, dt, count, callback, p, finish);
- mHandlers.push_back(t);
- return t;
- }
-
- Timer::Handler::Handler(Type t, float d, int c, TimerCallback f, void* p, FinishCallback finishcallback)
- : type(t)
- , duration(d)
- , count(c)
- , tickdown(d)
- , countdown(c)
- , callback(f)
- , paramters(p)
- , canceled(false)
- , finishCallback(finishcallback)
- {
- }
-
- Timer::Handler::~Handler()
- {
- if (finishCallback != nullptr)
- finishCallback(paramters);
- }
-
- void Timer::Handler::process(float dt)
- {
- tickdown -= dt;
- if (tickdown <= 0)
- {
- tickdown += duration;
- if (!canceled && callback != nullptr)
- callback(paramters);
- if (type == EVERY)
- {
- }
- else if (type == AFTER)
- {
- canceled = true;
- }
- else if (type == REPEAT)
- {
- --countdown;
- if (countdown <= 0)
- canceled = true;
- }
- }
- }
-
- } // namespace Time
-} // namespace JinEngine
-
-#endif // defined(jin_time) \ No newline at end of file
diff --git a/src/libjin/Time/je_timer.h b/src/libjin/Time/je_timer.h
deleted file mode 100644
index 31cd322..0000000
--- a/src/libjin/Time/je_timer.h
+++ /dev/null
@@ -1,137 +0,0 @@
-#ifndef __JE_TIMER_H__
-#define __JE_TIMER_H__
-#include "../core/je_configuration.h"
-#if defined(jin_time)
-
-#include <vector>
-#include <functional>
-
-#include "SDL2/SDL.h"
-
-namespace JinEngine
-{
- namespace Time
- {
-
- ///
- ///
- ///
- class Timer
- {
- public:
-
- typedef std::function<void(void*)> TimerCallback;
-
- typedef std::function<void(void*)> FinishCallback;
-
- ///
- ///
- ///
- class Handler
- {
- public:
- friend class Timer;
- enum Type
- {
- EVERY,
- AFTER,
- REPEAT,
- };
- Handler(Type type, float duration, int count = 0, TimerCallback callback = nullptr, void* paramters = nullptr, FinishCallback finishcallback = nullptr);
- virtual ~Handler();
- void process(float dt);
-
- protected:
- int count;
- int countdown;
- float duration;
- float tickdown;
- Type type;
- TimerCallback callback;
- FinishCallback finishCallback;
- void* paramters;
- bool canceled;
- };
-
- ///
- ///
- ///
- Timer();
-
- ///
- ///
- ///
- ~Timer();
-
- ///
- ///
- ///
- void update(float dt);
-
- ///
- ///
- ///
- Handler* every(float dt, TimerCallback callback, void* paramters, FinishCallback finish);
-
- ///
- ///
- ///
- Handler* after(float dt, TimerCallback callback, void* paramters, FinishCallback finish);
-
- ///
- ///
- ///
- Handler* repeat(float dt, int count, TimerCallback callback, void* paramters, FinishCallback finish);
-
- ///
- ///
- ///
- void cancel(Handler* handler);
-
- ///
- ///
- ///
- void cancelAll();
-
- private:
-
- std::vector<Handler*> mHandlers;
-
- };
-
- ///
- ///
- ///
- inline void sleep(int ms)
- {
- #if jin_time == jin_time_sdl
- SDL_Delay(ms);
- #endif
- }
-
- ///
- ///
- ///
- inline double getSecond()
- {
- #if jin_time == jin_time_sdl
- return SDL_GetTicks() / 1000.f;
- #endif
- }
-
- ///
- ///
- ///
- inline double getMilliSecond()
- {
- #if jin_time == jin_time_sdl
- return SDL_GetTicks();
- #endif
- }
-
- } // namespace Time
-} // namespace JinEngine
-
-#endif // defined(jin_time)
-
-#endif // __JE_TIMER_H__ \ No newline at end of file
diff --git a/src/libjin/Utils/je_endian.h b/src/libjin/Utils/je_endian.h
deleted file mode 100644
index db8c8fd..0000000
--- a/src/libjin/Utils/je_endian.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef jin_endian_lil && jin_endian_big
-
-#define jin_endian_lil 2
-#define jin_endian_big 4
-
-#endif
-
-#ifndef jin_byte_order
-#ifdef __linux__
-#include <endian.h>
-#define jin_byte_order __BYTE_ORDER
-#else /* __linux__ */
-#if defined(__hppa__) || \
- defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
- (defined(__MIPS__) && defined(__MISPEB__)) || \
- defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
- defined(__sparc__)
-#define jin_byte_order jin_endian_big
-#else
-#define jin_byte_order jin_endian_lil
-#endif
-#endif /* __linux__ */
-#endif /* !SDL_BYTEORDER */ \ No newline at end of file
diff --git a/src/libjin/Utils/je_log.cpp b/src/libjin/Utils/je_log.cpp
deleted file mode 100644
index e369e14..0000000
--- a/src/libjin/Utils/je_log.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#define LOGHELPER_IMPLEMENT
-#include "je_log.h"
-
-#define hasbit(flag, bit) ((flag & bit) == bit)
-
-unsigned int Loghelper::dir = Loghelper::Direction::DIR_CERR;
-unsigned int Loghelper::levels = Loghelper::Level::LV_ALL;
-std::ofstream Loghelper::fs;
-
-void Loghelper::log(Level _level, const char* _fmt, ...)
-{
- if (!hasbit(levels, _level))
- return;
-#define FORMAT_MSG_BUFFER_SIZE (204800)
- const char* levelStr = nullptr;
- switch (_level)
- {
- case LV_ERROR:
- levelStr = "[Jin Error]: ";
- break;
- case LV_WARNING:
- levelStr = "[Jin Warning]: ";
- break;
- case LV_INFO:
- levelStr = "[Jin Info]: ";
- break;
- case LV_DEBUG:
- levelStr = "[Jin Debug]: ";
- break;
- default:
- levelStr = "[Jin Unknow]: ";
- break;
- }
- char buffer[FORMAT_MSG_BUFFER_SIZE + 1] = { 0 };
- strcpy(buffer, levelStr);
- va_list args;
- va_start(args, _fmt);
- vsnprintf(buffer + strlen(buffer), FORMAT_MSG_BUFFER_SIZE, _fmt, args);
- va_end(args);
- if (hasbit(dir, DIR_CERR))
- {
- std::cerr << buffer << std::endl;
- }
- if (hasbit(dir, DIR_FILE))
- {
- fs << buffer << std::endl;
- }
-#undef FORMAT_MSG_BUFFER_SIZE
-}
-
-// ض
-void Loghelper::redirect(unsigned int _dir, char* _path)
-{
- dir = _dir;
- if (hasbit(dir, DIR_FILE))
- {
- try
- {
- fs.open(_path, std::ios_base::app);
- }
- catch (std::ios_base::failure& e) {
- dir = DIR_CERR;
- log(Level::LV_WARNING, "ضlog· %s ʧ", _path);
- }
- }
-}
-
-// ɸѡȼ
-void Loghelper::restrict(unsigned int _levels)
-{
- levels = _levels;
-}
-
-void Loghelper::close()
-{
- if (!fs.fail())
- fs.close();
- fs.clear();
-}
-
-#undef hasbit
diff --git a/src/libjin/Utils/je_log.h b/src/libjin/Utils/je_log.h
deleted file mode 100644
index f81bbae..0000000
--- a/src/libjin/Utils/je_log.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef __LOG_H__ELPER_H__
-#define __LOG_H__ELPER_H__
-
-#include <string>
-#include <iostream>
-#include <fstream>
-#include <stdarg.h>
-
-#include "../core/je_configuration.h"
-
-class Loghelper
-{
-public:
- // logĿ
- enum Direction
- {
- DIR_CERR = 1 << 1, // ׼
- DIR_FILE = 1 << 2, // logļ
- };
-
- // ȼ
- enum Level
- {
- LV_NONE = 0, // none
- LV_ERROR = 1 << 1, // error
- LV_WARNING = 1 << 2, // warn
- LV_INFO = 1 << 3, // info
- LV_DEBUG = 1 << 4, // debug
- LV_ALL = 0xffffffff
- };
-
- static void log(Level _level, const char* _fmt, ...);
-
- // ض
- static void redirect(unsigned int _dir, char* _path = nullptr);
-
- // ɸѡȼ
- static void restrict(unsigned int levels);
-
- static void close();
-
-private:
- static unsigned int dir; // Ŀ
- static unsigned int levels; // ȼ
- static std::ofstream fs; // ļ
-};
-
-
-typedef Loghelper::Level Loglevel;
-
-#if defined(jin_debug)
- #define jin_log_error(f, ...) Loghelper::log(Loghelper::LV_ERROR, f, __VA_ARGS__)
- #define jin_log_info(f, ...) Loghelper::log(Loghelper::LV_INFO, f, __VA_ARGS__)
- #define jin_log_warning(f, ...) Loghelper::log(Loghelper::LV_WARNING, f, __VA_ARGS__)
- #define jin_log_debug(f, ...) Loghelper::log(Loghelper::LV_DEBUG, f, __VA_ARGS__)
-#else
- #define jin_log_error(f, ...)
- #define jin_log_info(f, ...)
- #define jin_log_warning(f, ...)
- #define jin_log_debug(f, ...)
-#endif
-
-#endif // __LOG_H__ELPER_H__ \ No newline at end of file
diff --git a/src/libjin/Utils/je_macros.h b/src/libjin/Utils/je_macros.h
deleted file mode 100644
index 6e4e7a9..0000000
--- a/src/libjin/Utils/je_macros.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __JE_MACROS_H__
-#define __JE_MACROS_H__
-#include <cstring>
-
-//#define implement // ʵֽӿ
-//
-//#define shared // ķ
-//
-//#define MASK // enum
-//
-//#define onlyonce // ֻһ
-//#define CALLONCE(call) static char __dummy__=(call, 1) // ֻһ
-//#define SAFECALL(func, params) if(func) func(params)
-//
-//#define zero(mem) memset(&mem, 0, sizeof(mem))
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Utils/je_unittest.cpp b/src/libjin/Utils/je_unittest.cpp
deleted file mode 100644
index 294351b..0000000
--- a/src/libjin/Utils/je_unittest.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "je_utils.h"
-#if UNITTEST
-
-#include <iostream>
-#include <stdio.h>
-#include <fstream>
-#include "../audio/sdl/source.h"
-#include "../audio/sdl/audio.h"
-
-using namespace JinEngine::audio;
-using namespace std;
-
-int main(int argc, char* argv[])
-{
- SDLAudio* audio = SDLAudio::get();
- audio->init(0);
- SDLSource* source = SDLSource::createSource("a.ogg");
- SDLSource* source2 = SDLSource::createSource("a.wav");
- //source->play();
- source2->play();
- source->setLoop(true);
- source2->setLoop(true);
- int i = 0;
- while (true)
- {
- SDL_Delay(1000);
- }
- audio->quit();
- return 0;
-}
-
-/*
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "SDL2/SDL.h"
-
-#include <3rdparty/cmixer/cmixer.h>
-
-static SDL_mutex* audio_mutex;
-
-static void lock_handler(cm_Event *e) {
- if (e->type == CM_EVENT_LOCK) {
- SDL_LockMutex(audio_mutex);
- }
- if (e->type == CM_EVENT_UNLOCK) {
- SDL_UnlockMutex(audio_mutex);
- }
-}
-
-
-static void audio_callback(void *udata, Uint8 *stream, int size) {
- cm_process((cm_Int16*)stream, size / 2);
-}
-
-
-int main(int argc, char **argv) {
- SDL_AudioDeviceID dev;
- SDL_AudioSpec fmt, got;
- cm_Source *src;
- cm_Source* src2;
-
-
- SDL_Init(SDL_INIT_AUDIO);
- audio_mutex = SDL_CreateMutex();
-
- memset(&fmt, 0, sizeof(fmt));
- fmt.freq = 44100;
- fmt.format = AUDIO_S16;
- fmt.channels = 2;
- fmt.samples = 1024;
- fmt.callback = audio_callback;
-
- dev = SDL_OpenAudioDevice(NULL, 0, &fmt, &got, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
- if (dev == 0) {
- fprintf(stderr, "Error: failed to open audio device '%s'\n", SDL_GetError());
- exit(EXIT_FAILURE);
- }
-
- cm_init(got.freq);
- cm_set_lock(lock_handler);
- cm_set_master_gain(0.5);
-
- SDL_PauseAudioDevice(dev, 0);
-
- src = cm_new_source_from_file("a.ogg");
- src2 = cm_new_source_from_file("loop.wav");
- if (!src) {
- fprintf(stderr, "Error: failed to create source '%s'\n", cm_get_error());
- exit(EXIT_FAILURE);
- }
- cm_set_loop(src2, 1);
-
- cm_play(src);
- cm_play(src2);
-
- printf("Press [return] to exit\n");
- getchar();
-
- cm_destroy_source(src);
- SDL_CloseAudioDevice(dev);
- SDL_Quit();
-
- return EXIT_SUCCESS;
-}
-*/
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Utils/je_utils.h b/src/libjin/Utils/je_utils.h
deleted file mode 100644
index a77c126..0000000
--- a/src/libjin/Utils/je_utils.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __JE_UTILS_H__
-#define __JE_UTILS_H__
-
-#include "je_macros.h"
-#include "je_endian.h"
-
-#define UNITTEST 0
-
-#endif \ No newline at end of file
diff --git a/src/libjin/graphics/particles/je_particle.h b/src/libjin/graphics/particles/je_particle.h
index 70a2653..6da05ac 100644
--- a/src/libjin/graphics/particles/je_particle.h
+++ b/src/libjin/graphics/particles/je_particle.h
@@ -82,7 +82,7 @@ namespace JinEngine
RadialAccelarationDef radialAccelarationDef; ///<
AngularSpeedDef angularSpeedDef; ///<
// Optional definitions.
- ScaleOverTimeDef sizeOverTimeDef; ///<
+ ScaleOverTimeDef sizeOverTimeDef; ///<
ColorOverTimeDef colorOverTimeDef; ///<
};