From 1480c9445100075c9e1a894eb07c0ef727b509a1 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 27 Aug 2018 07:55:00 +0800 Subject: *update --- bin/jin.exe | Bin 548352 -> 549888 bytes build/vs2015/jin.rc | Bin 3262 -> 3340 bytes build/vs2015/jin.vcxproj | 6 +- build/vs2015/jin.vcxproj.filters | 6 + build/vs2015/libjin/libjin.vcxproj | 105 +++++++++- build/vs2015/libjin/libjin.vcxproj.filters | 306 ++++++++++++++++++++++++++++- src/libjin/Audio/source.cpp | 28 +++ src/libjin/Graphics/Shapes.cpp | 122 ++++++++++++ src/libjin/Graphics/Shapes.h | 43 ++++ src/libjin/Graphics/Texture.h | 2 + src/libjin/Physics/Physics.h | 2 +- src/libjin/Physics/Rigid.h | 0 src/libjin/jin.h | 1 + src/libjin/physics/physics.h | 2 +- src/libjin/physics/rigid.h | 0 src/lua/modules/physics/physics.cpp | 16 ++ 16 files changed, 626 insertions(+), 13 deletions(-) create mode 100644 src/libjin/Audio/source.cpp create mode 100644 src/libjin/Graphics/Shapes.cpp create mode 100644 src/libjin/Graphics/Shapes.h delete mode 100644 src/libjin/Physics/Rigid.h delete mode 100644 src/libjin/physics/rigid.h create mode 100644 src/lua/modules/physics/physics.cpp diff --git a/bin/jin.exe b/bin/jin.exe index 874ca50..33337d0 100644 Binary files a/bin/jin.exe and b/bin/jin.exe differ diff --git a/build/vs2015/jin.rc b/build/vs2015/jin.rc index 4b2f6af..85b96bd 100644 Binary files a/build/vs2015/jin.rc and b/build/vs2015/jin.rc differ diff --git a/build/vs2015/jin.vcxproj b/build/vs2015/jin.vcxproj index ff5846a..a9f1618 100644 --- a/build/vs2015/jin.vcxproj +++ b/build/vs2015/jin.vcxproj @@ -22,6 +22,7 @@ {A3E35ECA-62EB-45CE-8152-674FBC7F7A3B} jin 8.1 + jin(full version) @@ -82,7 +83,7 @@ Custom true _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(SolutionDir)..\..\src\;$(SolutionDir)libs\SDL2-2.0.5\include;$(SolutionDir)libs\LuaJIT-2.0.5\include;%(AdditionalIncludeDirectories) + $(SolutionDir)..\..\src\;$(SolutionDir)libs\SDL2-2.0.5\include;$(SolutionDir)libs\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\libjin\3rdparty;%(AdditionalIncludeDirectories) CompileAsCpp $(IntDir)/%(RelativeDir)/ Neither @@ -110,7 +111,7 @@ true true _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(SolutionDir)..\..\src\;$(SolutionDir)libs\SDL2-2.0.5\include;$(SolutionDir)libs\LuaJIT-2.0.5\include;%(AdditionalIncludeDirectories) + $(SolutionDir)..\..\src\;$(SolutionDir)libs\SDL2-2.0.5\include;$(SolutionDir)libs\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\libjin\3rdparty;%(AdditionalIncludeDirectories) CompileAsCpp $(IntDir)/%(RelativeDir)/ Size @@ -159,6 +160,7 @@ + diff --git a/build/vs2015/jin.vcxproj.filters b/build/vs2015/jin.vcxproj.filters index a8f6db7..5218536 100644 --- a/build/vs2015/jin.vcxproj.filters +++ b/build/vs2015/jin.vcxproj.filters @@ -67,6 +67,9 @@ {0340fbad-0c07-4923-afd2-183424c70967} + + {9670ec46-9794-4e7e-8f5a-0dc3ae1eaf06} + @@ -138,6 +141,9 @@ src\lua\modules + + src\lua\modules\physics + diff --git a/build/vs2015/libjin/libjin.vcxproj b/build/vs2015/libjin/libjin.vcxproj index 48bdb6f..d255f03 100644 --- a/build/vs2015/libjin/libjin.vcxproj +++ b/build/vs2015/libjin/libjin.vcxproj @@ -22,7 +22,8 @@ 15.0 {9EE02090-C15E-4520-9C05-C435E45EF2FC} libjin - 10.0.17134.0 + 8.1 + libjin(full version) @@ -82,10 +83,10 @@ true true true - true + false CompileAsCpp _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(SolutionDir)libs\SDL2-2.0.5\include;%(AdditionalIncludeDirectories) + $(SolutionDir)libs\SDL2-2.0.5\include;$(SolutionDir)..\..\src\libjin\3rdparty;%(AdditionalIncludeDirectories) $(IntDir)/%(RelativeDir)/ Size @@ -99,9 +100,9 @@ Level3 Disabled true - true + false _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(SolutionDir)libs\SDL2-2.0.5\include;%(AdditionalIncludeDirectories) + $(SolutionDir)libs\SDL2-2.0.5\include;$(SolutionDir)..\..\src\libjin\3rdparty;%(AdditionalIncludeDirectories) CompileAsCpp $(IntDir)/%(RelativeDir)/ @@ -129,6 +130,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -177,7 +225,6 @@ - @@ -192,6 +239,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/vs2015/libjin/libjin.vcxproj.filters b/build/vs2015/libjin/libjin.vcxproj.filters index 7452651..8485947 100644 --- a/build/vs2015/libjin/libjin.vcxproj.filters +++ b/build/vs2015/libjin/libjin.vcxproj.filters @@ -79,6 +79,30 @@ {e11ee8ea-9e7d-4906-a6fd-8df56cb6a3e9} + + {57ceb31d-2bc0-488a-8965-0d29111f9ecf} + + + {b8807b96-b968-4502-8034-b5d016189ab2} + + + {648bd259-b5c0-4b9e-a561-1ff83ac0c34b} + + + {95228e09-6999-4472-8ac4-540fc8c9a692} + + + {09d35646-0b60-405a-8288-9e3a4a1f9667} + + + {ae410ff7-378a-4dc3-b6ca-52b685d4fcd2} + + + {e2930534-acb0-4705-96e1-725de73c17af} + + + {bf260b45-984e-498b-8128-b32332aab23d} + @@ -177,9 +201,6 @@ Source\Physics - - Source\Physics - Source\Thread @@ -255,6 +276,147 @@ Source\Graphics + + Source\3rdparty\Box2D + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Collision\Shapes + + + Source\3rdparty\Box2D\Collision\Shapes + + + Source\3rdparty\Box2D\Collision\Shapes + + + Source\3rdparty\Box2D\Collision\Shapes + + + Source\3rdparty\Box2D\Collision\Shapes + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Rope + @@ -364,5 +526,143 @@ Source\Graphics + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Common + + + Source\3rdparty\Box2D\Collision\Shapes + + + Source\3rdparty\Box2D\Collision\Shapes + + + Source\3rdparty\Box2D\Collision\Shapes + + + Source\3rdparty\Box2D\Collision\Shapes + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Collision + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics\Joints + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Dynamics\Contacts + + + Source\3rdparty\Box2D\Rope + \ No newline at end of file diff --git a/src/libjin/Audio/source.cpp b/src/libjin/Audio/source.cpp new file mode 100644 index 0000000..61f4055 --- /dev/null +++ b/src/libjin/Audio/source.cpp @@ -0,0 +1,28 @@ +#include "../modules.h" +#if JIN_MODULES_AUDIO + +#include +#include "source.h" + +namespace jin +{ +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; + } + +} +} +#endif // JIN_MODULES_AUDIO \ No newline at end of file diff --git a/src/libjin/Graphics/Shapes.cpp b/src/libjin/Graphics/Shapes.cpp new file mode 100644 index 0000000..4b136a1 --- /dev/null +++ b/src/libjin/Graphics/Shapes.cpp @@ -0,0 +1,122 @@ +#include "../modules.h" +#if JIN_MODULES_RENDER + +#include "Shapes.h" +#include "../math/matrix.h" +#include "../math/constant.h" +#include + +namespace jin +{ +namespace graphics +{ + + void point(int x, int y) + { + float vers[] = { x + 0.5f , y + 0.5f }; + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, (GLvoid*)vers); + glDrawArrays(GL_POINTS, 0, 1); + glDisableClientState(GL_VERTEX_ARRAY); + } + + void points(int n, GLshort* p) + { + glEnableClientState(GL_VERTEX_ARRAY); + + glVertexPointer(2, GL_SHORT, 0, (GLvoid*)p); + glDrawArrays(GL_POINTS, 0, n); + + glDisableClientState(GL_VERTEX_ARRAY); + } + + void line(int x1, int y1, int x2, int y2) + { + glDisable(GL_TEXTURE_2D); + float verts[] = { + x1, y1, + x2, y2 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, (GLvoid*)verts); + glDrawArrays(GL_LINES, 0, 2); + glDisableClientState(GL_VERTEX_ARRAY); + } + + void circle(RENDER_MODE mode, int x, int y, int r) + { + r = r < 0 ? 0 : r; + + int points = 40; + float two_pi = static_cast(PI * 2); + if (points <= 0) points = 1; + float angle_shift = (two_pi / points); + float phi = .0f; + + float *coords = new float[2 * (points + 1)]; + for (int i = 0; i < points; ++i, phi += angle_shift) + { + coords[2 * i] = x + r * cos(phi); + coords[2 * i + 1] = y + r * sin(phi); + } + + coords[2 * points] = coords[0]; + coords[2 * points + 1] = coords[1]; + + polygon(mode, coords, points); + + delete[] coords; + } + + void rect(RENDER_MODE mode, int x, int y, int w, int h) + { + float coords[] = { x, y, x + w, y, x + w, y + h, x, y + h }; + polygon(mode, coords, 4); + } + + void triangle(RENDER_MODE mode, int x1, int y1, int x2, int y2, int x3, int y3) + { + float coords[] = { x1, y1, x2, y2, x3, y3 }; + polygon(mode, coords, 3); + } + + void polygon_line(float* p, int count) + { + float* verts = new float[count * 4]; + for (int i = 0; i < count; ++i) + { + // each line has two point n,n+1 + verts[i * 4] = p[i * 2]; + verts[i * 4 + 1] = p[i * 2 + 1]; + verts[i * 4 + 2] = p[(i + 1) % count * 2]; + verts[i * 4 + 3] = p[(i + 1) % count * 2 + 1]; + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, (GLvoid*)verts); + glDrawArrays(GL_LINES, 0, count * 2); + glDisableClientState(GL_VERTEX_ARRAY); + + delete[] verts; + } + + void polygon(RENDER_MODE mode, float* p, int count) + { + if (mode == LINE) + { + polygon_line(p, count); + } + else if (mode == FILL) + { + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, (const GLvoid*)p); + glDrawArrays(GL_POLYGON, 0, count); + glDisableClientState(GL_VERTEX_ARRAY); + } + } + +} +} + +#endif // JIN_MODULES_RENDER \ No newline at end of file diff --git a/src/libjin/Graphics/Shapes.h b/src/libjin/Graphics/Shapes.h new file mode 100644 index 0000000..742345e --- /dev/null +++ b/src/libjin/Graphics/Shapes.h @@ -0,0 +1,43 @@ +#ifndef __JIN_GRAPHICS_SHAPES_H +#define __JIN_GRAPHICS_SHAPES_H +#include "../modules.h" +#if JIN_MODULES_RENDER + +#include "color.h" +#include "canvas.h" +#include "texture.h" + +namespace jin +{ +namespace graphics +{ + + typedef enum { + NONE = 0, + FILL , + LINE + }RENDER_MODE; + + /** + * TODO: + * drawPixels(int n, points) + */ + extern void line(int x1, int y1, int x2, int y2); + + extern void rect(RENDER_MODE mode, int x, int y, int w, int h); + + extern void triangle(RENDER_MODE mode, int x1, int y1, int x2, int y2, int x3, int y3); + + extern void circle(RENDER_MODE mode, int x, int y, int r); + + extern void point(int x, int y); + + extern void points(int n, GLshort* p, GLubyte* c); + + extern void polygon(RENDER_MODE mode, float* p, int count); + +} +} + +#endif // JIN_MODULES_RENDER +#endif // __JIN_GEOMETRY_H \ No newline at end of file diff --git a/src/libjin/Graphics/Texture.h b/src/libjin/Graphics/Texture.h index 47f8d53..1fdb50d 100644 --- a/src/libjin/Graphics/Texture.h +++ b/src/libjin/Graphics/Texture.h @@ -19,6 +19,8 @@ namespace graphics static Texture* createTexture(const char* file); static Texture* createTexture(const void* mem, size_t size); + static void destroyTexture(Texture* tex); + ~Texture(); color getPixel(int x, int y); diff --git a/src/libjin/Physics/Physics.h b/src/libjin/Physics/Physics.h index 9927301..126911e 100644 --- a/src/libjin/Physics/Physics.h +++ b/src/libjin/Physics/Physics.h @@ -5,7 +5,7 @@ namespace jin { namespace physics { - + #include "../3rdparty/Box2D/Box2D.h" } } diff --git a/src/libjin/Physics/Rigid.h b/src/libjin/Physics/Rigid.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/libjin/jin.h b/src/libjin/jin.h index 239fddd..c8d1193 100644 --- a/src/libjin/jin.h +++ b/src/libjin/jin.h @@ -7,6 +7,7 @@ #ifdef JIN_MODULES_AUDIO && JIN_AUDIO_SDLAUDIO #include "Audio/SDL/SDLAudio.h" #endif // JIN_MODULES_AUDIO && JIN_AUDIO_SDLAUDIO +#include "Physics/Physics.h" #include "Core/Core.h" #include "Filesystem/Filesystem.h" #include "Input/Input.h" diff --git a/src/libjin/physics/physics.h b/src/libjin/physics/physics.h index 9927301..126911e 100644 --- a/src/libjin/physics/physics.h +++ b/src/libjin/physics/physics.h @@ -5,7 +5,7 @@ namespace jin { namespace physics { - + #include "../3rdparty/Box2D/Box2D.h" } } diff --git a/src/libjin/physics/rigid.h b/src/libjin/physics/rigid.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/lua/modules/physics/physics.cpp b/src/lua/modules/physics/physics.cpp new file mode 100644 index 0000000..a5b9162 --- /dev/null +++ b/src/lua/modules/physics/physics.cpp @@ -0,0 +1,16 @@ +#include "../luax.h" +#include "libjin/Physics/Physics.h" + +namespace jin +{ +namespace lua +{ + + using namespace jin::physics; + + int luaopen_physics(lua_State* L) + { + } + +} // physics +} // jin \ No newline at end of file -- cgit v1.1-26-g67d0