aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-07-28 09:58:37 +0800
committerchai <chaifix@163.com>2018-07-28 09:58:37 +0800
commit61301a96d309fe2deef0d0dc2e2bc2f3d4003bf9 (patch)
treed335e4312b28addf40f13e7f49900e9b5e3058a7 /src
parent92dab582ccac31be7fa410e7f4fb3789e88a0629 (diff)
*update
Diffstat (limited to 'src')
-rw-r--r--src/libjin/Audio/OpenAL/ALAudio.cpp (renamed from src/libjin/Audio/OpenAL/Audio.cpp)0
-rw-r--r--src/libjin/Audio/OpenAL/ALAudio.h (renamed from src/libjin/Audio/OpenAL/Audio.h)0
-rw-r--r--src/libjin/Audio/OpenAL/ALSource.cpp (renamed from src/libjin/Audio/OpenAL/Source.cpp)0
-rw-r--r--src/libjin/Audio/OpenAL/ALSource.h (renamed from src/libjin/Audio/OpenAL/Source.h)0
-rw-r--r--src/libjin/Common/Data.h4
-rw-r--r--src/libjin/Common/Singleton.h2
-rw-r--r--src/libjin/Common/Subsystem.h2
-rw-r--r--src/libjin/Filesystem/Buffer.h2
-rw-r--r--src/libjin/Filesystem/Filesystem.cpp2
-rw-r--r--src/libjin/Filesystem/Filesystem.h2
-rw-r--r--src/libjin/Input/Event.h60
-rw-r--r--src/libjin/Input/Mouse.cpp22
-rw-r--r--src/libjin/Input/Mouse.h20
-rw-r--r--src/libjin/Render/Canvas.cpp5
-rw-r--r--src/libjin/Render/Canvas.h6
-rw-r--r--src/libjin/Render/Color.h6
-rw-r--r--src/libjin/Render/Drawable.cpp4
-rw-r--r--src/libjin/Render/Drawable.h10
-rw-r--r--src/libjin/Render/Font.cpp9
-rw-r--r--src/libjin/Render/Font.h2
-rw-r--r--src/libjin/Render/Graphics.h3
-rw-r--r--src/libjin/Render/JSL.cpp3
-rw-r--r--src/libjin/Render/JSL.h2
-rw-r--r--src/libjin/Render/Render.h2
-rw-r--r--src/libjin/Render/Texture.cpp1
-rw-r--r--src/libjin/Render/Texture.h2
-rw-r--r--src/libjin/Render/Window.h7
-rw-r--r--src/libjin/Thread/Thread.cpp8
-rw-r--r--src/libjin/Thread/Thread.h21
-rw-r--r--src/libjin/audio/openal/audio.cpp0
-rw-r--r--src/libjin/audio/openal/audio.h0
-rw-r--r--src/libjin/audio/openal/source.cpp0
-rw-r--r--src/libjin/audio/openal/source.h0
-rw-r--r--src/libjin/common/data.h4
-rw-r--r--src/libjin/common/singleton.h2
-rw-r--r--src/libjin/common/subsystem.h2
-rw-r--r--src/libjin/input/event.h60
-rw-r--r--src/libjin/input/mouse.cpp22
-rw-r--r--src/libjin/input/mouse.h20
-rw-r--r--src/libjin/render/canvas.cpp5
-rw-r--r--src/libjin/render/canvas.h6
-rw-r--r--src/libjin/render/color.h6
-rw-r--r--src/libjin/render/drawable.cpp4
-rw-r--r--src/libjin/render/drawable.h10
-rw-r--r--src/libjin/render/font.cpp9
-rw-r--r--src/libjin/render/font.h2
-rw-r--r--src/libjin/render/graphics.h3
-rw-r--r--src/libjin/render/jsl.cpp3
-rw-r--r--src/libjin/render/jsl.h2
-rw-r--r--src/libjin/render/render.h2
-rw-r--r--src/libjin/render/texture.cpp1
-rw-r--r--src/libjin/render/texture.h2
-rw-r--r--src/libjin/render/window.h7
-rw-r--r--src/libjin/thread/thread.cpp8
-rw-r--r--src/libjin/thread/thread.h21
-rw-r--r--src/lua/event/luaopen_event.cpp27
-rw-r--r--src/lua/filesystem/luaopen_filesystem.cpp2
-rw-r--r--src/lua/graphics/luaopen_graphics.cpp4
-rw-r--r--src/lua/mouse/luaopen_mouse.cpp8
59 files changed, 329 insertions, 120 deletions
diff --git a/src/libjin/Audio/OpenAL/Audio.cpp b/src/libjin/Audio/OpenAL/ALAudio.cpp
index e69de29..e69de29 100644
--- a/src/libjin/Audio/OpenAL/Audio.cpp
+++ b/src/libjin/Audio/OpenAL/ALAudio.cpp
diff --git a/src/libjin/Audio/OpenAL/Audio.h b/src/libjin/Audio/OpenAL/ALAudio.h
index e69de29..e69de29 100644
--- a/src/libjin/Audio/OpenAL/Audio.h
+++ b/src/libjin/Audio/OpenAL/ALAudio.h
diff --git a/src/libjin/Audio/OpenAL/Source.cpp b/src/libjin/Audio/OpenAL/ALSource.cpp
index e69de29..e69de29 100644
--- a/src/libjin/Audio/OpenAL/Source.cpp
+++ b/src/libjin/Audio/OpenAL/ALSource.cpp
diff --git a/src/libjin/Audio/OpenAL/Source.h b/src/libjin/Audio/OpenAL/ALSource.h
index e69de29..e69de29 100644
--- a/src/libjin/Audio/OpenAL/Source.h
+++ b/src/libjin/Audio/OpenAL/ALSource.h
diff --git a/src/libjin/Common/Data.h b/src/libjin/Common/Data.h
index 6f1c504..38b8c7d 100644
--- a/src/libjin/Common/Data.h
+++ b/src/libjin/Common/Data.h
@@ -4,12 +4,12 @@
namespace jin
{
- struct Buffer
+ struct DataBuffer
{
unsigned int len;
char data[0];
};
-}
+} // jin
#endif \ No newline at end of file
diff --git a/src/libjin/Common/Singleton.h b/src/libjin/Common/Singleton.h
index a6c7d6d..ff8a9ce 100644
--- a/src/libjin/Common/Singleton.h
+++ b/src/libjin/Common/Singleton.h
@@ -33,6 +33,6 @@ namespace jin
#define SINGLETON(T) \
friend Singleton<T>
-}
+} // jin
#endif \ No newline at end of file
diff --git a/src/libjin/Common/Subsystem.h b/src/libjin/Common/Subsystem.h
index 1212abf..8a4ecf6 100644
--- a/src/libjin/Common/Subsystem.h
+++ b/src/libjin/Common/Subsystem.h
@@ -38,6 +38,6 @@ namespace jin
};
-}
+} // jin
#endif \ No newline at end of file
diff --git a/src/libjin/Filesystem/Buffer.h b/src/libjin/Filesystem/Buffer.h
index 7571c2d..1d72083 100644
--- a/src/libjin/Filesystem/Buffer.h
+++ b/src/libjin/Filesystem/Buffer.h
@@ -5,7 +5,7 @@
namespace jin
{
-namespace fs
+namespace filesystem
{
class Buffer
diff --git a/src/libjin/Filesystem/Filesystem.cpp b/src/libjin/Filesystem/Filesystem.cpp
index af94034..e9b05e3 100644
--- a/src/libjin/Filesystem/Filesystem.cpp
+++ b/src/libjin/Filesystem/Filesystem.cpp
@@ -5,7 +5,7 @@
namespace jin
{
-namespace fs
+namespace filesystem
{
Filesystem* Filesystem::fs = 0;
diff --git a/src/libjin/Filesystem/Filesystem.h b/src/libjin/Filesystem/Filesystem.h
index 15f0b9f..1df83ea 100644
--- a/src/libjin/Filesystem/Filesystem.h
+++ b/src/libjin/Filesystem/Filesystem.h
@@ -3,7 +3,7 @@
namespace jin
{
-namespace fs
+namespace filesystem
{
class Filesystem
diff --git a/src/libjin/Input/Event.h b/src/libjin/Input/Event.h
index 4d7230a..83db070 100644
--- a/src/libjin/Input/Event.h
+++ b/src/libjin/Input/Event.h
@@ -9,22 +9,62 @@ namespace input
{
#if JIN_INPUT_SDL
#include "SDL.h"
- typedef SDL_Event Event;
+ typedef SDL_Event Event;
+ typedef SDL_Keycode Key;
+ typedef SDL_MouseWheelEvent Wheel;
+
+ enum EventType {
+ QUIT = SDL_QUIT,
+ KEYDOWN = SDL_KEYDOWN,
+ KEYUP = SDL_KEYUP,
+ MOUSEMOTION = SDL_MOUSEMOTION,
+ MOUSEBUTTONDOWN = SDL_MOUSEBUTTONDOWN,
+ MOUSEBUTTONUP = SDL_MOUSEBUTTONUP,
+ MOUSEWHEEL = SDL_MOUSEWHEEL
+ };
+
inline int pollEvent(Event* e)
{
return SDL_PollEvent(e);
}
- enum EventType{
- QUIT = SDL_QUIT,
- KEYDOWN = SDL_KEYDOWN ,
- KEYUP = SDL_KEYUP,
- MOUSEMOTION = SDL_MOUSEMOTION,
- MOUSEBUTTONDOWN = SDL_MOUSEBUTTONDOWN,
- MOUSEBUTTONUP = SDL_MOUSEBUTTONUP,
- MOUSEWHEEL = SDL_MOUSEWHEEL
- };
+ 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_SDL
}
}
diff --git a/src/libjin/Input/Mouse.cpp b/src/libjin/Input/Mouse.cpp
index e69de29..98c4a39 100644
--- a/src/libjin/Input/Mouse.cpp
+++ b/src/libjin/Input/Mouse.cpp
@@ -0,0 +1,22 @@
+#include "../modules.h"
+#ifdef JIN_MODULES_INPUT
+
+#include "SDL.h"
+#include "Mouse.h"
+
+namespace jin
+{
+namespace input
+{
+
+ void Mouse::getState(int* x, int* y)
+ {
+#ifdef JIN_INPUT_SDL
+ SDL_GetMouseState(x, y);
+#endif // JIN_INPUT_SDL
+ }
+
+} // input
+} // jin
+
+#endif // JIN_MODULES_INPUT \ No newline at end of file
diff --git a/src/libjin/Input/Mouse.h b/src/libjin/Input/Mouse.h
index b926327..cb70407 100644
--- a/src/libjin/Input/Mouse.h
+++ b/src/libjin/Input/Mouse.h
@@ -1,15 +1,29 @@
#ifndef __JIN_MOUSE_H
#define __JIN_MOUSE_H
+#include "../modules.h"
+#ifdef JIN_MODULES_INPUT
+
+#include "../Common/Singleton.h"
+
namespace jin
{
namespace input
{
- class Mouse
+ class Mouse : public Singleton<Mouse>
{
public:
- };
+ //
+ void getState(int* x, int* y);
+ private:
+ Mouse() {};
+ ~Mouse() {};
+
+ SINGLETON(Mouse);
+ };
}
}
-#endif \ No newline at end of file
+
+#endif // JIN_MODULES_INPUT
+#endif // __JIN_MOUSE_H \ No newline at end of file
diff --git a/src/libjin/Render/Canvas.cpp b/src/libjin/Render/Canvas.cpp
index 8cb34ca..4f0f48d 100644
--- a/src/libjin/Render/Canvas.cpp
+++ b/src/libjin/Render/Canvas.cpp
@@ -129,6 +129,7 @@ namespace render
glLoadIdentity();
}
-}
-}
+} // render
+} // jin
+
#endif // JIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/Render/Canvas.h b/src/libjin/Render/Canvas.h
index 8cced23..9afa42d 100644
--- a/src/libjin/Render/Canvas.h
+++ b/src/libjin/Render/Canvas.h
@@ -33,8 +33,8 @@ namespace render
bool init();
};
-}
-}
+} // render
+} // jin
-#endif
#endif // JIN_MODULES_RENDER
+#endif // __JIN_CANVAS_H \ No newline at end of file
diff --git a/src/libjin/Render/Color.h b/src/libjin/Render/Color.h
index 7b88799..eb2875e 100644
--- a/src/libjin/Render/Color.h
+++ b/src/libjin/Render/Color.h
@@ -24,8 +24,8 @@ namespace render
int word;
};
-}
-}
+} // render
+} // jin
#endif // JIN_MODULES_RENDER
-#endif \ No newline at end of file
+#endif // __JIN_COLOR_H \ No newline at end of file
diff --git a/src/libjin/Render/Drawable.cpp b/src/libjin/Render/Drawable.cpp
index cbdf250..0a250cb 100644
--- a/src/libjin/Render/Drawable.cpp
+++ b/src/libjin/Render/Drawable.cpp
@@ -71,7 +71,7 @@ namespace render
glDisable(GL_TEXTURE_2D);
}
-}
-}
+} // render
+} // jin
#endif // JIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/Render/Drawable.h b/src/libjin/Render/Drawable.h
index f8e25a2..621f1a8 100644
--- a/src/libjin/Render/Drawable.h
+++ b/src/libjin/Render/Drawable.h
@@ -34,7 +34,9 @@ namespace render
};
protected:
-#define DRAWABLE_V_SIZE 8
+
+ const int DRAWABLE_V_SIZE = 8;
+
void setVertices(float* v, float* t);
GLuint texture;
@@ -49,8 +51,8 @@ namespace render
float* vertCoord;
};
-}
-}// jin
+} // render
+} // jin
#endif // JIN_MODULES_RENDER
-#endif
+#endif // __JIN_DRAWABLE \ No newline at end of file
diff --git a/src/libjin/Render/Font.cpp b/src/libjin/Render/Font.cpp
index e8e71b2..741b992 100644
--- a/src/libjin/Render/Font.cpp
+++ b/src/libjin/Render/Font.cpp
@@ -13,10 +13,10 @@ namespace render
{
using namespace jin::math;
-
-#define BITMAP_WIDTH 512
-#define BITMAP_HEIGHT 512
-#define PIXEL_HEIGHT 32
+
+ const int BITMAP_WIDTH = 512;
+ const int BITMAP_HEIGHT = 512;
+ const int PIXEL_HEIGHT = 32;
Font::Font():Drawable()
{
@@ -190,4 +190,5 @@ namespace render
}
}
+
#endif // JIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/Render/Font.h b/src/libjin/Render/Font.h
index f2a57ed..cde64b5 100644
--- a/src/libjin/Render/Font.h
+++ b/src/libjin/Render/Font.h
@@ -58,4 +58,4 @@ namespace render
}
#endif // JIN_MODULES_RENDER
-#endif \ No newline at end of file
+#endif // __JIN_FONT_H \ No newline at end of file
diff --git a/src/libjin/Render/Graphics.h b/src/libjin/Render/Graphics.h
index 13dd4d1..84cd6ff 100644
--- a/src/libjin/Render/Graphics.h
+++ b/src/libjin/Render/Graphics.h
@@ -36,5 +36,6 @@ namespace render
extern void polygon(RENDER_MODE mode, float* p, int count);
}
}
+
#endif // JIN_MODULES_RENDER
-#endif // __JIN_GRAPHICS_H
+#endif // __JIN_GRAPHICS_H \ No newline at end of file
diff --git a/src/libjin/Render/JSL.cpp b/src/libjin/Render/JSL.cpp
index 4ce660b..b49c9b7 100644
--- a/src/libjin/Render/JSL.cpp
+++ b/src/libjin/Render/JSL.cpp
@@ -155,4 +155,5 @@ namespace render
}
}
-#endif // JIN_MODULES_RENDER
+
+#endif // JIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/Render/JSL.h b/src/libjin/Render/JSL.h
index 741983a..068d5e0 100644
--- a/src/libjin/Render/JSL.h
+++ b/src/libjin/Render/JSL.h
@@ -71,4 +71,4 @@ namespace render
}
#endif // JIN_MODULES_RENDER
-#endif
+#endif // __JIN_JSL_H \ No newline at end of file
diff --git a/src/libjin/Render/Render.h b/src/libjin/Render/Render.h
index e51051e..640c148 100644
--- a/src/libjin/Render/Render.h
+++ b/src/libjin/Render/Render.h
@@ -12,4 +12,4 @@
#include "window.h"
#endif // JIN_MODULES_RENDER
-#endif \ No newline at end of file
+#endif // __JIN_RENDER_H \ No newline at end of file
diff --git a/src/libjin/Render/Texture.cpp b/src/libjin/Render/Texture.cpp
index cee3552..d9abe40 100644
--- a/src/libjin/Render/Texture.cpp
+++ b/src/libjin/Render/Texture.cpp
@@ -96,4 +96,5 @@ namespace render
}
}
}
+
#endif // JIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/Render/Texture.h b/src/libjin/Render/Texture.h
index d2e4bd0..c42e533 100644
--- a/src/libjin/Render/Texture.h
+++ b/src/libjin/Render/Texture.h
@@ -35,4 +35,4 @@ namespace render
}
#endif // JIN_MODULES_RENDER
-#endif \ No newline at end of file
+#endif // __JIN_IMAGE_H \ No newline at end of file
diff --git a/src/libjin/Render/Window.h b/src/libjin/Render/Window.h
index 77b1963..f600e35 100644
--- a/src/libjin/Render/Window.h
+++ b/src/libjin/Render/Window.h
@@ -53,7 +53,8 @@ namespace render
typedef WindowSystem::Setting WindowSetting;
-}
-}
+} // render
+} // jin
+
#endif // JIN_MODULES_RENDER
-#endif \ No newline at end of file
+#endif // __JIN_RENDER_WINDOW \ No newline at end of file
diff --git a/src/libjin/Thread/Thread.cpp b/src/libjin/Thread/Thread.cpp
index e69de29..a874b0d 100644
--- a/src/libjin/Thread/Thread.cpp
+++ b/src/libjin/Thread/Thread.cpp
@@ -0,0 +1,8 @@
+#include "../modules.h"
+#if JIN_MODULES_THREAD
+
+#include "Thread.h"
+
+
+
+#endif // JIN_MODULES_THREAD \ No newline at end of file
diff --git a/src/libjin/Thread/Thread.h b/src/libjin/Thread/Thread.h
index 6f70f09..f736407 100644
--- a/src/libjin/Thread/Thread.h
+++ b/src/libjin/Thread/Thread.h
@@ -1 +1,20 @@
-#pragma once
+#ifndef __JIN_THREAD_H
+#define __JIN_THREAD_H
+#include "../modules.h"
+#if JIN_MODULES_THREAD
+
+namespace jin
+{
+namespace thread
+{
+
+ class Thread
+ {
+
+ };
+
+}
+}
+
+#endif // JIN_MODULES_THREAD
+#endif // __JIN_THREAD_H \ No newline at end of file
diff --git a/src/libjin/audio/openal/audio.cpp b/src/libjin/audio/openal/audio.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/audio/openal/audio.cpp
+++ /dev/null
diff --git a/src/libjin/audio/openal/audio.h b/src/libjin/audio/openal/audio.h
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/audio/openal/audio.h
+++ /dev/null
diff --git a/src/libjin/audio/openal/source.cpp b/src/libjin/audio/openal/source.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/audio/openal/source.cpp
+++ /dev/null
diff --git a/src/libjin/audio/openal/source.h b/src/libjin/audio/openal/source.h
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/audio/openal/source.h
+++ /dev/null
diff --git a/src/libjin/common/data.h b/src/libjin/common/data.h
index 6f1c504..38b8c7d 100644
--- a/src/libjin/common/data.h
+++ b/src/libjin/common/data.h
@@ -4,12 +4,12 @@
namespace jin
{
- struct Buffer
+ struct DataBuffer
{
unsigned int len;
char data[0];
};
-}
+} // jin
#endif \ No newline at end of file
diff --git a/src/libjin/common/singleton.h b/src/libjin/common/singleton.h
index a6c7d6d..ff8a9ce 100644
--- a/src/libjin/common/singleton.h
+++ b/src/libjin/common/singleton.h
@@ -33,6 +33,6 @@ namespace jin
#define SINGLETON(T) \
friend Singleton<T>
-}
+} // jin
#endif \ No newline at end of file
diff --git a/src/libjin/common/subsystem.h b/src/libjin/common/subsystem.h
index 1212abf..8a4ecf6 100644
--- a/src/libjin/common/subsystem.h
+++ b/src/libjin/common/subsystem.h
@@ -38,6 +38,6 @@ namespace jin
};
-}
+} // jin
#endif \ No newline at end of file
diff --git a/src/libjin/input/event.h b/src/libjin/input/event.h
index 4d7230a..83db070 100644
--- a/src/libjin/input/event.h
+++ b/src/libjin/input/event.h
@@ -9,22 +9,62 @@ namespace input
{
#if JIN_INPUT_SDL
#include "SDL.h"
- typedef SDL_Event Event;
+ typedef SDL_Event Event;
+ typedef SDL_Keycode Key;
+ typedef SDL_MouseWheelEvent Wheel;
+
+ enum EventType {
+ QUIT = SDL_QUIT,
+ KEYDOWN = SDL_KEYDOWN,
+ KEYUP = SDL_KEYUP,
+ MOUSEMOTION = SDL_MOUSEMOTION,
+ MOUSEBUTTONDOWN = SDL_MOUSEBUTTONDOWN,
+ MOUSEBUTTONUP = SDL_MOUSEBUTTONUP,
+ MOUSEWHEEL = SDL_MOUSEWHEEL
+ };
+
inline int pollEvent(Event* e)
{
return SDL_PollEvent(e);
}
- enum EventType{
- QUIT = SDL_QUIT,
- KEYDOWN = SDL_KEYDOWN ,
- KEYUP = SDL_KEYUP,
- MOUSEMOTION = SDL_MOUSEMOTION,
- MOUSEBUTTONDOWN = SDL_MOUSEBUTTONDOWN,
- MOUSEBUTTONUP = SDL_MOUSEBUTTONUP,
- MOUSEWHEEL = SDL_MOUSEWHEEL
- };
+ 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_SDL
}
}
diff --git a/src/libjin/input/mouse.cpp b/src/libjin/input/mouse.cpp
index e69de29..98c4a39 100644
--- a/src/libjin/input/mouse.cpp
+++ b/src/libjin/input/mouse.cpp
@@ -0,0 +1,22 @@
+#include "../modules.h"
+#ifdef JIN_MODULES_INPUT
+
+#include "SDL.h"
+#include "Mouse.h"
+
+namespace jin
+{
+namespace input
+{
+
+ void Mouse::getState(int* x, int* y)
+ {
+#ifdef JIN_INPUT_SDL
+ SDL_GetMouseState(x, y);
+#endif // JIN_INPUT_SDL
+ }
+
+} // input
+} // jin
+
+#endif // JIN_MODULES_INPUT \ No newline at end of file
diff --git a/src/libjin/input/mouse.h b/src/libjin/input/mouse.h
index b926327..cb70407 100644
--- a/src/libjin/input/mouse.h
+++ b/src/libjin/input/mouse.h
@@ -1,15 +1,29 @@
#ifndef __JIN_MOUSE_H
#define __JIN_MOUSE_H
+#include "../modules.h"
+#ifdef JIN_MODULES_INPUT
+
+#include "../Common/Singleton.h"
+
namespace jin
{
namespace input
{
- class Mouse
+ class Mouse : public Singleton<Mouse>
{
public:
- };
+ //
+ void getState(int* x, int* y);
+ private:
+ Mouse() {};
+ ~Mouse() {};
+
+ SINGLETON(Mouse);
+ };
}
}
-#endif \ No newline at end of file
+
+#endif // JIN_MODULES_INPUT
+#endif // __JIN_MOUSE_H \ No newline at end of file
diff --git a/src/libjin/render/canvas.cpp b/src/libjin/render/canvas.cpp
index 8cb34ca..4f0f48d 100644
--- a/src/libjin/render/canvas.cpp
+++ b/src/libjin/render/canvas.cpp
@@ -129,6 +129,7 @@ namespace render
glLoadIdentity();
}
-}
-}
+} // render
+} // jin
+
#endif // JIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/render/canvas.h b/src/libjin/render/canvas.h
index 8cced23..9afa42d 100644
--- a/src/libjin/render/canvas.h
+++ b/src/libjin/render/canvas.h
@@ -33,8 +33,8 @@ namespace render
bool init();
};
-}
-}
+} // render
+} // jin
-#endif
#endif // JIN_MODULES_RENDER
+#endif // __JIN_CANVAS_H \ No newline at end of file
diff --git a/src/libjin/render/color.h b/src/libjin/render/color.h
index 7b88799..eb2875e 100644
--- a/src/libjin/render/color.h
+++ b/src/libjin/render/color.h
@@ -24,8 +24,8 @@ namespace render
int word;
};
-}
-}
+} // render
+} // jin
#endif // JIN_MODULES_RENDER
-#endif \ No newline at end of file
+#endif // __JIN_COLOR_H \ No newline at end of file
diff --git a/src/libjin/render/drawable.cpp b/src/libjin/render/drawable.cpp
index cbdf250..0a250cb 100644
--- a/src/libjin/render/drawable.cpp
+++ b/src/libjin/render/drawable.cpp
@@ -71,7 +71,7 @@ namespace render
glDisable(GL_TEXTURE_2D);
}
-}
-}
+} // render
+} // jin
#endif // JIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/render/drawable.h b/src/libjin/render/drawable.h
index f8e25a2..621f1a8 100644
--- a/src/libjin/render/drawable.h
+++ b/src/libjin/render/drawable.h
@@ -34,7 +34,9 @@ namespace render
};
protected:
-#define DRAWABLE_V_SIZE 8
+
+ const int DRAWABLE_V_SIZE = 8;
+
void setVertices(float* v, float* t);
GLuint texture;
@@ -49,8 +51,8 @@ namespace render
float* vertCoord;
};
-}
-}// jin
+} // render
+} // jin
#endif // JIN_MODULES_RENDER
-#endif
+#endif // __JIN_DRAWABLE \ No newline at end of file
diff --git a/src/libjin/render/font.cpp b/src/libjin/render/font.cpp
index e8e71b2..741b992 100644
--- a/src/libjin/render/font.cpp
+++ b/src/libjin/render/font.cpp
@@ -13,10 +13,10 @@ namespace render
{
using namespace jin::math;
-
-#define BITMAP_WIDTH 512
-#define BITMAP_HEIGHT 512
-#define PIXEL_HEIGHT 32
+
+ const int BITMAP_WIDTH = 512;
+ const int BITMAP_HEIGHT = 512;
+ const int PIXEL_HEIGHT = 32;
Font::Font():Drawable()
{
@@ -190,4 +190,5 @@ namespace render
}
}
+
#endif // JIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/render/font.h b/src/libjin/render/font.h
index f2a57ed..cde64b5 100644
--- a/src/libjin/render/font.h
+++ b/src/libjin/render/font.h
@@ -58,4 +58,4 @@ namespace render
}
#endif // JIN_MODULES_RENDER
-#endif \ No newline at end of file
+#endif // __JIN_FONT_H \ No newline at end of file
diff --git a/src/libjin/render/graphics.h b/src/libjin/render/graphics.h
index 13dd4d1..84cd6ff 100644
--- a/src/libjin/render/graphics.h
+++ b/src/libjin/render/graphics.h
@@ -36,5 +36,6 @@ namespace render
extern void polygon(RENDER_MODE mode, float* p, int count);
}
}
+
#endif // JIN_MODULES_RENDER
-#endif // __JIN_GRAPHICS_H
+#endif // __JIN_GRAPHICS_H \ No newline at end of file
diff --git a/src/libjin/render/jsl.cpp b/src/libjin/render/jsl.cpp
index 4ce660b..b49c9b7 100644
--- a/src/libjin/render/jsl.cpp
+++ b/src/libjin/render/jsl.cpp
@@ -155,4 +155,5 @@ namespace render
}
}
-#endif // JIN_MODULES_RENDER
+
+#endif // JIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/render/jsl.h b/src/libjin/render/jsl.h
index 741983a..068d5e0 100644
--- a/src/libjin/render/jsl.h
+++ b/src/libjin/render/jsl.h
@@ -71,4 +71,4 @@ namespace render
}
#endif // JIN_MODULES_RENDER
-#endif
+#endif // __JIN_JSL_H \ No newline at end of file
diff --git a/src/libjin/render/render.h b/src/libjin/render/render.h
index e51051e..640c148 100644
--- a/src/libjin/render/render.h
+++ b/src/libjin/render/render.h
@@ -12,4 +12,4 @@
#include "window.h"
#endif // JIN_MODULES_RENDER
-#endif \ No newline at end of file
+#endif // __JIN_RENDER_H \ No newline at end of file
diff --git a/src/libjin/render/texture.cpp b/src/libjin/render/texture.cpp
index cee3552..d9abe40 100644
--- a/src/libjin/render/texture.cpp
+++ b/src/libjin/render/texture.cpp
@@ -96,4 +96,5 @@ namespace render
}
}
}
+
#endif // JIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/render/texture.h b/src/libjin/render/texture.h
index d2e4bd0..c42e533 100644
--- a/src/libjin/render/texture.h
+++ b/src/libjin/render/texture.h
@@ -35,4 +35,4 @@ namespace render
}
#endif // JIN_MODULES_RENDER
-#endif \ No newline at end of file
+#endif // __JIN_IMAGE_H \ No newline at end of file
diff --git a/src/libjin/render/window.h b/src/libjin/render/window.h
index 77b1963..f600e35 100644
--- a/src/libjin/render/window.h
+++ b/src/libjin/render/window.h
@@ -53,7 +53,8 @@ namespace render
typedef WindowSystem::Setting WindowSetting;
-}
-}
+} // render
+} // jin
+
#endif // JIN_MODULES_RENDER
-#endif \ No newline at end of file
+#endif // __JIN_RENDER_WINDOW \ No newline at end of file
diff --git a/src/libjin/thread/thread.cpp b/src/libjin/thread/thread.cpp
index e69de29..a874b0d 100644
--- a/src/libjin/thread/thread.cpp
+++ b/src/libjin/thread/thread.cpp
@@ -0,0 +1,8 @@
+#include "../modules.h"
+#if JIN_MODULES_THREAD
+
+#include "Thread.h"
+
+
+
+#endif // JIN_MODULES_THREAD \ No newline at end of file
diff --git a/src/libjin/thread/thread.h b/src/libjin/thread/thread.h
index 6f70f09..f736407 100644
--- a/src/libjin/thread/thread.h
+++ b/src/libjin/thread/thread.h
@@ -1 +1,20 @@
-#pragma once
+#ifndef __JIN_THREAD_H
+#define __JIN_THREAD_H
+#include "../modules.h"
+#if JIN_MODULES_THREAD
+
+namespace jin
+{
+namespace thread
+{
+
+ class Thread
+ {
+
+ };
+
+}
+}
+
+#endif // JIN_MODULES_THREAD
+#endif // __JIN_THREAD_H \ No newline at end of file
diff --git a/src/lua/event/luaopen_event.cpp b/src/lua/event/luaopen_event.cpp
index 2d1e52f..a53863d 100644
--- a/src/lua/event/luaopen_event.cpp
+++ b/src/lua/event/luaopen_event.cpp
@@ -4,28 +4,12 @@
#include "lua/luax.h"
#include "libjin/jin.h"
-using namespace jin::input;
-
namespace jin
{
namespace lua
{
- static inline const char* buttonstr(int id) {
- switch (id) {
- case 1: return "left";
- case 2: return "middle";
- case 3: return "right";
- case 4: return "wheelup";
- case 5: return "wheeldown";
- default: return "?";
- }
- }
-
- static inline const char* wheelstr(int dir)
- {
-
- }
+ using namespace jin::input;
/**
* Load event poll, return a iterator(a table).
@@ -49,12 +33,12 @@ namespace lua
case EventType::KEYDOWN:
luax_setfield_string(L, "type", "keydown");
- luax_setfield_string(L, "key", SDL_GetKeyName(e.key.keysym.sym));
+ luax_setfield_string(L, "key", getKeyName(e.key.keysym.sym));
break;
case EventType::KEYUP:
luax_setfield_string(L, "type", "keyup");
- luax_setfield_string(L, "key", SDL_GetKeyName(e.key.keysym.sym));
+ luax_setfield_string(L, "key", getKeyName(e.key.keysym.sym));
break;
case EventType::MOUSEMOTION:
@@ -65,14 +49,14 @@ namespace lua
case EventType::MOUSEBUTTONDOWN:
luax_setfield_string(L, "type", "mousebuttondown");
- luax_setfield_string(L, "button", buttonstr(e.button.button));
+ luax_setfield_string(L, "button", getButtonName(e.button.button));
luax_setfield_number(L, "x", e.button.x);
luax_setfield_number(L, "y", e.button.y);
break;
case EventType::MOUSEBUTTONUP:
luax_setfield_string(L, "type", "mousebuttonup");
- luax_setfield_string(L, "button", buttonstr(e.button.button));
+ luax_setfield_string(L, "button", getButtonName(e.button.button));
luax_setfield_number(L, "x", e.button.x);
luax_setfield_number(L, "y", e.button.y);
break;
@@ -85,7 +69,6 @@ namespace lua
luax_setfield_string(L, "x", "right");
else
luax_setfield_string(L, "x", "none");
-
if (e.wheel.y == -1)
luax_setfield_string(L, "y", "near");
else if (e.wheel.y == 1)
diff --git a/src/lua/filesystem/luaopen_filesystem.cpp b/src/lua/filesystem/luaopen_filesystem.cpp
index db0216b..3a19f12 100644
--- a/src/lua/filesystem/luaopen_filesystem.cpp
+++ b/src/lua/filesystem/luaopen_filesystem.cpp
@@ -2,7 +2,7 @@
#include "libjin/jin.h"
#include <string>
-using namespace jin::fs;
+using namespace jin::filesystem;
namespace jin
{
diff --git a/src/lua/graphics/luaopen_graphics.cpp b/src/lua/graphics/luaopen_graphics.cpp
index f0bae67..5cd0c8d 100644
--- a/src/lua/graphics/luaopen_graphics.cpp
+++ b/src/lua/graphics/luaopen_graphics.cpp
@@ -7,8 +7,8 @@ namespace jin
{
namespace lua
{
- using namespace render;
- using namespace fs;
+ using namespace jin::render;
+ using namespace jin::filesystem;
/**
* jin.graphics context, storge some module
diff --git a/src/lua/mouse/luaopen_mouse.cpp b/src/lua/mouse/luaopen_mouse.cpp
index a013f3d..eb6a779 100644
--- a/src/lua/mouse/luaopen_mouse.cpp
+++ b/src/lua/mouse/luaopen_mouse.cpp
@@ -1,13 +1,17 @@
#include "lua/luax.h"
-#include "SDL2/SDL.h"
+#include "libjin/jin.h"
+
namespace jin
{
namespace lua
{
+ using namespace jin::input;
+
static int l_pos(lua_State* L)
{
+ static Mouse* mouse = Mouse::get();
int x, y;
- SDL_GetMouseState(&x, &y);
+ mouse->getState(&x, &y);
luax_pushnumber(L, x);
luax_pushnumber(L, y);
return 2;