From dce7b78db8a7071217b1439c4b7f6a341ce37cf1 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 17 Oct 2018 07:50:46 +0800 Subject: =?UTF-8?q?*=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/Audio/Audio.cpp | 4 +- src/libjin/Audio/Audio.h | 4 +- src/libjin/Audio/SDL/SDLAudio.cpp | 4 +- src/libjin/Audio/SDL/SDLAudio.h | 4 +- src/libjin/Audio/SDL/SDLSource.cpp | 4 +- src/libjin/Audio/SDL/SDLSource.h | 4 +- src/libjin/Audio/Source.cpp | 4 +- src/libjin/Audio/Source.h | 4 +- src/libjin/Common/Object.h | 2 +- src/libjin/Common/Singleton.hpp | 2 +- src/libjin/Common/StringMap.hpp | 2 +- src/libjin/Common/Subsystem.hpp | 2 +- src/libjin/Common/utf8.cpp | 2 +- src/libjin/Common/utf8.h | 2 +- src/libjin/Filesystem/Buffer.h | 4 +- src/libjin/Filesystem/Filesystem.cpp | 4 +- src/libjin/Filesystem/Filesystem.h | 4 +- src/libjin/Game/Game.cpp | 4 +- src/libjin/Game/Game.h | 4 +- src/libjin/Graphics/Bitmap.h | 4 +- src/libjin/Graphics/Canvas.cpp | 8 +- src/libjin/Graphics/Canvas.h | 4 +- src/libjin/Graphics/Color.h | 4 +- src/libjin/Graphics/Drawable.cpp | 6 +- src/libjin/Graphics/Font/Decoder.cpp | 4 +- src/libjin/Graphics/Font/Decoder.h | 4 +- src/libjin/Graphics/Font/Font.h | 4 +- src/libjin/Graphics/Font/TTF.cpp | 8 +- src/libjin/Graphics/Font/TTF.h | 24 +-- src/libjin/Graphics/Font/Text.cpp | 4 +- src/libjin/Graphics/Font/Text.h | 4 +- src/libjin/Graphics/Font/TextureFont.cpp | 2 +- src/libjin/Graphics/Graphics.h | 3 +- src/libjin/Graphics/Shader.cpp | 282 --------------------------- src/libjin/Graphics/Shader.h | 59 ------ src/libjin/Graphics/Shader/Shader.cpp | 282 +++++++++++++++++++++++++++ src/libjin/Graphics/Shader/Shader.h | 123 ++++++++++++ src/libjin/Graphics/Shader/base.shader.h | 88 +++++++++ src/libjin/Graphics/Shader/default.shader.h | 21 ++ src/libjin/Graphics/Shader/font.shader.h | 21 ++ src/libjin/Graphics/Shader/texture.shader.h | 21 ++ src/libjin/Graphics/Shaders/base.shader.h | 88 --------- src/libjin/Graphics/Shaders/default.shader.h | 21 -- src/libjin/Graphics/Shaders/font.shader.h | 21 -- src/libjin/Graphics/Shaders/texture.shader.h | 21 -- src/libjin/Graphics/Shapes.cpp | 6 +- src/libjin/Graphics/Shapes.h | 4 +- src/libjin/Graphics/Texture.cpp | 4 +- src/libjin/Graphics/Texture.h | 4 +- src/libjin/Graphics/Window.cpp | 6 +- src/libjin/Graphics/Window.h | 4 +- src/libjin/Input/Event.cpp | 2 +- src/libjin/Input/Event.h | 6 +- src/libjin/Input/Joypad.h | 4 +- src/libjin/Input/Keyboard.h | 4 +- src/libjin/Input/Mouse.cpp | 4 +- src/libjin/Input/Mouse.h | 4 +- src/libjin/Math/Math.h | 4 +- src/libjin/Math/Matrix.cpp | 4 +- src/libjin/Math/Matrix.h | 4 +- src/libjin/Math/Quad.h | 4 +- src/libjin/Math/Vector2.hpp | 4 +- src/libjin/Math/Vector3.hpp | 4 +- src/libjin/Math/Vector4.hpp | 4 +- src/libjin/Net/Net.cpp | 4 +- src/libjin/Net/Net.h | 4 +- src/libjin/Net/Socket.cpp | 4 +- src/libjin/Net/Socket.h | 4 +- src/libjin/Net/net.cpp | 4 +- src/libjin/Net/net.h | 4 +- src/libjin/Thread/Thread.cpp | 4 +- src/libjin/Thread/Thread.h | 4 +- src/libjin/Thread/thread.cpp | 4 +- src/libjin/Thread/thread.h | 4 +- src/libjin/Time/Timer.cpp | 4 +- src/libjin/Time/Timer.h | 4 +- src/libjin/audio/audio.cpp | 4 +- src/libjin/audio/audio.h | 4 +- src/libjin/audio/source.cpp | 4 +- src/libjin/audio/source.h | 4 +- src/libjin/input/event.cpp | 2 +- src/libjin/input/event.h | 6 +- src/libjin/input/joypad.h | 4 +- src/libjin/input/keyboard.h | 4 +- src/libjin/input/mouse.cpp | 4 +- src/libjin/input/mouse.h | 4 +- src/libjin/math/math.h | 4 +- src/libjin/math/matrix.cpp | 4 +- src/libjin/math/matrix.h | 4 +- src/libjin/math/quad.h | 4 +- src/libjin/net/net.cpp | 4 +- src/libjin/net/net.h | 4 +- src/libjin/thread/thread.cpp | 4 +- src/libjin/thread/thread.h | 4 +- 94 files changed, 730 insertions(+), 665 deletions(-) delete mode 100644 src/libjin/Graphics/Shader.cpp delete mode 100644 src/libjin/Graphics/Shader.h create mode 100644 src/libjin/Graphics/Shader/Shader.cpp create mode 100644 src/libjin/Graphics/Shader/Shader.h create mode 100644 src/libjin/Graphics/Shader/base.shader.h create mode 100644 src/libjin/Graphics/Shader/default.shader.h create mode 100644 src/libjin/Graphics/Shader/font.shader.h create mode 100644 src/libjin/Graphics/Shader/texture.shader.h delete mode 100644 src/libjin/Graphics/Shaders/base.shader.h delete mode 100644 src/libjin/Graphics/Shaders/default.shader.h delete mode 100644 src/libjin/Graphics/Shaders/font.shader.h delete mode 100644 src/libjin/Graphics/Shaders/texture.shader.h (limited to 'src') diff --git a/src/libjin/Audio/Audio.cpp b/src/libjin/Audio/Audio.cpp index d148467..6c68b35 100644 --- a/src/libjin/Audio/Audio.cpp +++ b/src/libjin/Audio/Audio.cpp @@ -9,7 +9,7 @@ namespace jin namespace audio { - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO diff --git a/src/libjin/Audio/Audio.h b/src/libjin/Audio/Audio.h index 48cbfe4..5ba0844 100644 --- a/src/libjin/Audio/Audio.h +++ b/src/libjin/Audio/Audio.h @@ -45,8 +45,8 @@ namespace jin }; - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO #endif // __LIBJIN_AUDIO_H diff --git a/src/libjin/Audio/SDL/SDLAudio.cpp b/src/libjin/Audio/SDL/SDLAudio.cpp index e06979c..6c341c0 100644 --- a/src/libjin/Audio/SDL/SDLAudio.cpp +++ b/src/libjin/Audio/SDL/SDLAudio.cpp @@ -135,7 +135,7 @@ namespace jin this->volume = clamp(volume, 0.0f, 1.0f); } - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO diff --git a/src/libjin/Audio/SDL/SDLAudio.h b/src/libjin/Audio/SDL/SDLAudio.h index 32519d2..31022c6 100644 --- a/src/libjin/Audio/SDL/SDLAudio.h +++ b/src/libjin/Audio/SDL/SDLAudio.h @@ -53,8 +53,8 @@ namespace jin }; - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO #endif // __LIBJIN_AUDIO_SDL_H diff --git a/src/libjin/Audio/SDL/SDLSource.cpp b/src/libjin/Audio/SDL/SDLSource.cpp index 12ffb9b..fc22bbf 100644 --- a/src/libjin/Audio/SDL/SDLSource.cpp +++ b/src/libjin/Audio/SDL/SDLSource.cpp @@ -393,7 +393,7 @@ namespace jin } - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO diff --git a/src/libjin/Audio/SDL/SDLSource.h b/src/libjin/Audio/SDL/SDLSource.h index d9059cb..df005a0 100644 --- a/src/libjin/Audio/SDL/SDLSource.h +++ b/src/libjin/Audio/SDL/SDLSource.h @@ -100,8 +100,8 @@ namespace jin } }; - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO #endif // __LIBJIN_SOURCE_SDL_H diff --git a/src/libjin/Audio/Source.cpp b/src/libjin/Audio/Source.cpp index 306d93f..8da4cde 100644 --- a/src/libjin/Audio/Source.cpp +++ b/src/libjin/Audio/Source.cpp @@ -23,7 +23,7 @@ namespace jin return SourceType::INVALID; } - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO diff --git a/src/libjin/Audio/Source.h b/src/libjin/Audio/Source.h index 40707de..07a9a4e 100644 --- a/src/libjin/Audio/Source.h +++ b/src/libjin/Audio/Source.h @@ -40,8 +40,8 @@ namespace jin }; - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO #endif // __LIBJIN_AUDIO_SOURCE_H diff --git a/src/libjin/Common/Object.h b/src/libjin/Common/Object.h index f7f3b43..c4bf225 100644 --- a/src/libjin/Common/Object.h +++ b/src/libjin/Common/Object.h @@ -44,6 +44,6 @@ namespace jin }; // Object -} // jin +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Common/Singleton.hpp b/src/libjin/Common/Singleton.hpp index 600813a..cdb395f 100644 --- a/src/libjin/Common/Singleton.hpp +++ b/src/libjin/Common/Singleton.hpp @@ -32,6 +32,6 @@ namespace jin #define SINGLETON(T) friend Singleton -} // jin +} // namespace jin #endif // __LIBJIN_SINGLETON_H \ No newline at end of file diff --git a/src/libjin/Common/StringMap.hpp b/src/libjin/Common/StringMap.hpp index 9e4b0f5..641e32d 100644 --- a/src/libjin/Common/StringMap.hpp +++ b/src/libjin/Common/StringMap.hpp @@ -138,6 +138,6 @@ namespace jin }; // StringMap -} // jin +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Common/Subsystem.hpp b/src/libjin/Common/Subsystem.hpp index 78f4e01..b9ca88b 100644 --- a/src/libjin/Common/Subsystem.hpp +++ b/src/libjin/Common/Subsystem.hpp @@ -38,6 +38,6 @@ namespace jin }; -} // jin +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Common/utf8.cpp b/src/libjin/Common/utf8.cpp index f00d03c..33ee128 100644 --- a/src/libjin/Common/utf8.cpp +++ b/src/libjin/Common/utf8.cpp @@ -37,6 +37,6 @@ namespace jin } } -} // jin +} // namespace jin #endif // LIBJIN_OS == LIBJIN_WINDOWS diff --git a/src/libjin/Common/utf8.h b/src/libjin/Common/utf8.h index fd6ce1f..ae41728 100644 --- a/src/libjin/Common/utf8.h +++ b/src/libjin/Common/utf8.h @@ -25,7 +25,7 @@ namespace jin **/ void replace_char(std::string & str, char find, char replace); -} // jin +} // namespace jin #endif // LIBJIN_OS == LIBJIN_WINDOWS #endif // __LIBJIN_COMMON_UTF8_H diff --git a/src/libjin/Filesystem/Buffer.h b/src/libjin/Filesystem/Buffer.h index a47b0ef..f0d987a 100644 --- a/src/libjin/Filesystem/Buffer.h +++ b/src/libjin/Filesystem/Buffer.h @@ -61,7 +61,7 @@ namespace jin }; - } // filesystem -} // jin + } // namespace filesystem +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Filesystem/Filesystem.cpp b/src/libjin/Filesystem/Filesystem.cpp index b8faed7..8dce5a3 100644 --- a/src/libjin/Filesystem/Filesystem.cpp +++ b/src/libjin/Filesystem/Filesystem.cpp @@ -63,5 +63,5 @@ namespace jin return smtexists(S, path) == 0; } - } // filesystem -} // jin \ No newline at end of file + } // namespace filesystem +} // namespace jin \ No newline at end of file diff --git a/src/libjin/Filesystem/Filesystem.h b/src/libjin/Filesystem/Filesystem.h index b43d260..b13e207 100644 --- a/src/libjin/Filesystem/Filesystem.h +++ b/src/libjin/Filesystem/Filesystem.h @@ -27,5 +27,5 @@ namespace jin }; - } // filesystem -} // jin \ No newline at end of file + } // namespace filesystem +} // namespace jin \ No newline at end of file diff --git a/src/libjin/Game/Game.cpp b/src/libjin/Game/Game.cpp index 82597b7..b04661f 100644 --- a/src/libjin/Game/Game.cpp +++ b/src/libjin/Game/Game.cpp @@ -68,5 +68,5 @@ namespace jin { } - } // core -} // jin \ No newline at end of file + } // namespace core +} // namespace jin \ No newline at end of file diff --git a/src/libjin/Game/Game.h b/src/libjin/Game/Game.h index ede2418..c4a341f 100644 --- a/src/libjin/Game/Game.h +++ b/src/libjin/Game/Game.h @@ -52,7 +52,7 @@ namespace jin }; - } // core -} // jin + } // namespace core +} // namespace jin #endif // __LIBJIN_CORE_GAME_H diff --git a/src/libjin/Graphics/Bitmap.h b/src/libjin/Graphics/Bitmap.h index 5599521..9277cc8 100644 --- a/src/libjin/Graphics/Bitmap.h +++ b/src/libjin/Graphics/Bitmap.h @@ -45,8 +45,8 @@ namespace jin }; - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif #endif \ No newline at end of file diff --git a/src/libjin/Graphics/Canvas.cpp b/src/libjin/Graphics/Canvas.cpp index 6db06c6..11b2d77 100644 --- a/src/libjin/Graphics/Canvas.cpp +++ b/src/libjin/Graphics/Canvas.cpp @@ -29,11 +29,11 @@ namespace jin GLint current_fbo; glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); - /* generate a new render buffer object */ + // generate a new render buffer object fbo = gl.genFrameBuffer(); gl.bindFrameBuffer(fbo); - /* generate texture save target */ + // generate texture save target texture = gl.genTexture(); gl.bindTexture(texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -96,7 +96,7 @@ namespace jin } - } // render -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER \ No newline at end of file diff --git a/src/libjin/Graphics/Canvas.h b/src/libjin/Graphics/Canvas.h index 4851c83..935a65e 100644 --- a/src/libjin/Graphics/Canvas.h +++ b/src/libjin/Graphics/Canvas.h @@ -32,8 +32,8 @@ namespace jin }; - } // render -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER #endif // __LIBJIN_CANVAS_H \ No newline at end of file diff --git a/src/libjin/Graphics/Color.h b/src/libjin/Graphics/Color.h index b235a66..6c49691 100644 --- a/src/libjin/Graphics/Color.h +++ b/src/libjin/Graphics/Color.h @@ -78,8 +78,8 @@ namespace jin }; - } // render -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER #endif // __LIBJIN_COLOR_H \ No newline at end of file diff --git a/src/libjin/Graphics/Drawable.cpp b/src/libjin/Graphics/Drawable.cpp index b9a0b36..aa17f1a 100644 --- a/src/libjin/Graphics/Drawable.cpp +++ b/src/libjin/Graphics/Drawable.cpp @@ -1,7 +1,7 @@ #include "../jin_configuration.h" #if LIBJIN_MODULES_RENDER -#include "Shader.h" +#include "./Shader/Shader.h" #include "drawable.h" #include "../math/matrix.h" #include @@ -112,7 +112,7 @@ namespace jin gl.bindTexture(0); } - } // render -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER \ No newline at end of file diff --git a/src/libjin/Graphics/Font/Decoder.cpp b/src/libjin/Graphics/Font/Decoder.cpp index 856627b..362fd2a 100644 --- a/src/libjin/Graphics/Font/Decoder.cpp +++ b/src/libjin/Graphics/Font/Decoder.cpp @@ -89,5 +89,5 @@ namespace jin return p + 1; } - } // graphics -} // jin \ No newline at end of file + } // namespace graphics +} // namespace jin \ No newline at end of file diff --git a/src/libjin/Graphics/Font/Decoder.h b/src/libjin/Graphics/Font/Decoder.h index e5940a2..533f60b 100644 --- a/src/libjin/Graphics/Font/Decoder.h +++ b/src/libjin/Graphics/Font/Decoder.h @@ -38,7 +38,7 @@ namespace jin const void* next(const void* data) const override; }; - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Graphics/Font/Font.h b/src/libjin/Graphics/Font/Font.h index 9ccef54..14211e1 100644 --- a/src/libjin/Graphics/Font/Font.h +++ b/src/libjin/Graphics/Font/Font.h @@ -33,7 +33,7 @@ namespace jin }; - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Graphics/Font/TTF.cpp b/src/libjin/Graphics/Font/TTF.cpp index 7e62485..4c3648a 100644 --- a/src/libjin/Graphics/Font/TTF.cpp +++ b/src/libjin/Graphics/Font/TTF.cpp @@ -6,7 +6,7 @@ #include "../../Common/Array.hpp" #include "../OpenGL.h" #include "../Color.h" -#include "../Shader.h" +#include "../Shader/Shader.h" #include "TTF.h" #include "Page.h" @@ -142,7 +142,7 @@ namespace jin // TTF ///////////////////////////////////////////////////////////////////////////// - #include "../Shaders/font.shader.h" + #include "../Shader/font.shader.h" using namespace std; using namespace jin::math; @@ -448,7 +448,7 @@ namespace jin return bakeGlyph(character); } - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER \ No newline at end of file diff --git a/src/libjin/Graphics/Font/TTF.h b/src/libjin/Graphics/Font/TTF.h index fc2eca3..8e9ed73 100644 --- a/src/libjin/Graphics/Font/TTF.h +++ b/src/libjin/Graphics/Font/TTF.h @@ -22,14 +22,14 @@ namespace jin class TTF; - /** - * TTFData - * |- TTF(14px) - * |- TTF(15px) - * . - * . - * . - */ + // + // TTFData + // |- TTF(14px) + // |- TTF(15px) + // . + // . + // . + // class TTFData { public: @@ -83,13 +83,13 @@ namespace jin struct TTFGlyph { GLuint atlas; - /* normalized coordinates */ + // normalized coordinates struct Bbox { float x, y; float w, h; } bbox; - /* glyph size in pixel */ + // glyph size in pixel unsigned int width, height; }; @@ -125,8 +125,8 @@ namespace jin }; - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER #endif // __LIBJIN_FONT_H \ No newline at end of file diff --git a/src/libjin/Graphics/Font/Text.cpp b/src/libjin/Graphics/Font/Text.cpp index ac0242e..f2231f8 100644 --- a/src/libjin/Graphics/Font/Text.cpp +++ b/src/libjin/Graphics/Font/Text.cpp @@ -152,5 +152,5 @@ namespace jin return content; } - } // graphics -} // jin \ No newline at end of file + } // namespace graphics +} // namespace jin \ No newline at end of file diff --git a/src/libjin/Graphics/Font/Text.h b/src/libjin/Graphics/Font/Text.h index a4cbcbf..7256a52 100644 --- a/src/libjin/Graphics/Font/Text.h +++ b/src/libjin/Graphics/Font/Text.h @@ -68,7 +68,7 @@ namespace jin }; - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Graphics/Font/TextureFont.cpp b/src/libjin/Graphics/Font/TextureFont.cpp index 8c9c4ac..4f6f5d6 100644 --- a/src/libjin/Graphics/Font/TextureFont.cpp +++ b/src/libjin/Graphics/Font/TextureFont.cpp @@ -1,7 +1,7 @@ #include #include "../../Math/Vector2.hpp" -#include "../Shader.h" +#include "../Shader/Shader.h" #include "TextureFont.h" namespace jin diff --git a/src/libjin/Graphics/Graphics.h b/src/libjin/Graphics/Graphics.h index 199d2aa..a173599 100644 --- a/src/libjin/Graphics/Graphics.h +++ b/src/libjin/Graphics/Graphics.h @@ -7,11 +7,12 @@ #include "color.h" #include "Shapes.h" #include "texture.h" -#include "Shader.h" #include "window.h" #include "Bitmap.h" #include "Image.h" +#include "./Shader/Shader.h" + #include "./Font/TTF.h" #include "./Font/Text.h" #include "./Font/TextureFont.h" diff --git a/src/libjin/Graphics/Shader.cpp b/src/libjin/Graphics/Shader.cpp deleted file mode 100644 index 8788900..0000000 --- a/src/libjin/Graphics/Shader.cpp +++ /dev/null @@ -1,282 +0,0 @@ -#include -#include "../jin_configuration.h" -#if LIBJIN_MODULES_RENDER - -#include - -#include "../utils/macros.h" -#include "Shader.h" -#include "../Filesystem/Buffer.h" -namespace jin -{ - namespace graphics - { - - using namespace jin::filesystem; - using namespace std; - - /** - * default_texture - * base_shader - * SHADER_FORMAT_SIZE - * formatShader - */ - #include "Shaders/default.shader.h" - - /** - * https://stackoverflow.com/questions/27941496/use-sampler-without-passing-through-value - * The default value of a sampler variable is 0. From the GLSL 3.30 spec, - * section "4.3.5 Uniforms": - * - * The link time initial value is either the value of the variable's - * initializer, if present, or 0 if no initializer is present.Sampler - * types cannot have initializers. - * - * Since a value of 0 means that it's sampling from texture unit 0, it will - * work without ever setting the value as long as you bind your textures to - * unit 0. This is well defined behavior. - * - * Since texture unit 0 is also the default until you call glActiveTexture() - * with a value other than GL_TEXTURE0, it's very common to always use unit - * 0 as long as shaders do not need more than one texture.Which means that - * often times, setting the sampler uniforms is redundant for simple - * applications. - * - * I would still prefer to always set the values.If nothing else, it makes - * it clear to anybody reading your code that you really mean to sample from - * texture unit 0, and did not just forget to set the value. - */ - const int DEFAULT_TEXTURE_UNIT = 0; - - /*static*/ Shader* Shader::currentShader = nullptr; - - Shader* Shader::createShader(const string& program) - { - Shader* shader = nullptr; - try - { - shader = new Shader(program); - } - catch(...) - { - return nullptr; - } - return shader; - } - - Shader::Shader(const string& program) - : currentTextureUnit(DEFAULT_TEXTURE_UNIT) - { - if (!compile(program)) - throw 0; - } - - Shader::~Shader() - { - if (currentShader == this) - unuse(); - } - - bool Shader::compile(const string& program) - { - /* parse shader source, need some optimizations */ - int loc_VERTEX_SHADER = program.find("#VERTEX_SHADER"); - int loc_END_VERTEX_SHADER = program.find("#END_VERTEX_SHADER"); - int loc_FRAGMENT_SHADER = program.find("#FRAGMENT_SHADER"); - int loc_END_FRAGMENT_SHADER = program.find("#END_FRAGMENT_SHADER"); - if (loc_VERTEX_SHADER == string::npos - || loc_END_VERTEX_SHADER == string::npos - || loc_FRAGMENT_SHADER == string::npos - || loc_END_FRAGMENT_SHADER == string::npos - ) - return false; - /* load vertex and fragment shader source into buffers */ - int start = loc_VERTEX_SHADER + strlen("#VERTEX_SHADER"); - string vertex_shader = program.substr(start, loc_END_VERTEX_SHADER - start); - Buffer vbuffer = Buffer(vertex_shader.length() + BASE_VERTEX_SHADER_SIZE); - formatVertexShader((char*)vbuffer.data, vertex_shader.c_str()); - start = loc_FRAGMENT_SHADER + strlen("#FRAGMENT_SHADER"); - string fragment_shader = program.substr(start, loc_END_FRAGMENT_SHADER - start); - Buffer fbuffer = Buffer(fragment_shader.length() + BASE_FRAGMENT_SHADER_SIZE); - formatFragmentShader((char*)fbuffer.data, fragment_shader.c_str()); - /* compile */ - GLint success; - GLuint vshader = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(vshader, 1, (const GLchar**)&vbuffer.data, NULL); - glCompileShader(vshader); - glGetShaderiv(vshader, GL_COMPILE_STATUS, &success); - if (success == GL_FALSE) - return false; - GLuint fshader = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(fshader, 1, (const GLchar**)&fbuffer.data, NULL); - glCompileShader(fshader); - glGetShaderiv(fshader, GL_COMPILE_STATUS, &success); - if (success == GL_FALSE) - return false; - pid = glCreateProgram(); - glAttachShader(pid, vshader); - glAttachShader(pid, fshader); - glLinkProgram(pid); - glGetProgramiv(pid, GL_LINK_STATUS, &success); - if (success == GL_FALSE) - throw false; - } - - static inline GLint getMaxTextureUnits() - { - GLint maxTextureUnits = 0; - glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits); - return maxTextureUnits; - } - - void Shader::use() - { - glUseProgram(pid); - currentShader = this; - sendInt(SHADER_MAIN_TEXTURE, DEFAULT_TEXTURE_UNIT); - } - - /*static*/ void Shader::unuse() - { - glUseProgram(0); - currentShader = nullptr; - } - - GLint Shader::claimTextureUnit(const std::string& name) - { - std::map::iterator unit = textureUnits.find(name); - if (unit != textureUnits.end()) - return unit->second; - static GLint MAX_TEXTURE_UNITS = getMaxTextureUnits(); - if (++currentTextureUnit >= MAX_TEXTURE_UNITS) - return 0; - textureUnits[name] = currentTextureUnit; - return currentTextureUnit; - } - - #define checkJSL() \ - if (currentShader != this) \ - return - - void Shader::sendInt(const char* name, int value) - { - checkJSL(); - int loc = glGetUniformLocation(pid, name); - glUniform1i(loc, value); - } - - void Shader::sendFloat(const char* variable, float number) - { - checkJSL(); - int loc = glGetUniformLocation(pid, variable); - glUniform1f(loc, number); - } - - /** - * https://www.douban.com/note/627332677/ - * struct TextureUnit - * { - * GLuint targetTexture1D; - * GLuint targetTexture2D; - * GLuint targetTexture3D; - * GLuint targetTextureCube; - * ... - * }; - * - * TextureUnit textureUnits[GL_MAX_TEXTURE_IMAGE_UNITS] - * GLuint currentTextureUnit = 0; - */ - void Shader::sendTexture(const char* variable, const Texture* tex) - { - checkJSL(); - GLint location = glGetUniformLocation(pid, variable); - if (location == -1) - return; - GLint unit = claimTextureUnit(variable); - if (unit == 0) - { - // TODO: Òì³£´¦Àí£¬°ó¶¨µÄÎÆÀí³¬¹ý×î´óÏÞÖÆ - return; - } - gl.activeTexUnit(unit); - glUniform1i(location, unit); - gl.bindTexture(tex->getTexture()); - gl.activeTexUnit(0); - } - - void Shader::sendCanvas(const char* variable, const Canvas* canvas) - { - checkJSL(); - GLint location = glGetUniformLocation(pid, variable); - if (location == -1) - return; - GLint unit = claimTextureUnit(variable); - if (unit == 0) - { - // TODO: Òì³£´¦Àí£¬°ó¶¨µÄÎÆÀí³¬¹ý×î´óÏÞÖÆ - return; - } - glUniform1i(location, unit); - glActiveTexture(GL_TEXTURE0 + unit); - gl.bindTexture(canvas->getTexture()); - - glActiveTexture(GL_TEXTURE0); - } - - void Shader::sendVec2(const char* name, float x, float y) - { - checkJSL(); - int loc = glGetUniformLocation(pid, name); - glUniform2f(loc, x, y); - } - - void Shader::sendVec3(const char* name, float x, float y, float z) - { - checkJSL(); - int loc = glGetUniformLocation(pid, name); - glUniform3f(loc, x, y, z); - } - - void Shader::sendVec4(const char* name, float x, float y, float z, float w) - { - checkJSL(); - int loc = glGetUniformLocation(pid, name); - glUniform4f(loc, x, y, z, w); - } - - void Shader::sendColor(const char* name, const Color* col) - { - checkJSL(); - int loc = glGetUniformLocation(pid, name); - glUniform4f(loc, - col->r / 255.f, - col->g / 255.f, - col->b / 255.f, - col->a / 255.f - ); - } - - void Shader::sendMatrix4(const char* name, const math::Matrix* mat4) - { - int loc = glGetUniformLocation(pid, name); - glUniformMatrix4fv(loc, 1, GL_FALSE, mat4->getElements()); - } - - void Shader::bindVertexPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers) - { - GLint loc = glGetAttribLocation(pid, SHADER_VERTEX_COORDS); - glEnableVertexAttribArray(0); - glVertexAttribPointer(loc, n, type, GL_FALSE, stride, pointers); - } - - void Shader::bindUVPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers) - { - GLint loc = glGetAttribLocation(pid, SHADER_TEXTURE_COORDS); - glEnableVertexAttribArray(1); - glVertexAttribPointer(loc, n, type, GL_FALSE, stride, pointers); - } - - } // graphics -} // jin - -#endif // LIBJIN_MODULES_RENDER \ No newline at end of file diff --git a/src/libjin/Graphics/Shader.h b/src/libjin/Graphics/Shader.h deleted file mode 100644 index 6339883..0000000 --- a/src/libjin/Graphics/Shader.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __LIBJIN_JSL_H -#define __LIBJIN_JSL_H -#include "../jin_configuration.h" -#if LIBJIN_MODULES_RENDER - -#include -#include -#include "color.h" -#include "texture.h" -#include "canvas.h" -#include "../3rdparty/GLee/GLee.h" -#include "Shaders/base.shader.h" - -namespace jin -{ - namespace graphics - { - - class Shader - { - public: - static Shader* createShader(const std::string& program); - static inline Shader* getCurrentShader() { return currentShader; } - static void unuse(); - - virtual ~Shader(); - - void use(); - void sendFloat(const char* name, float number); - void sendTexture(const char* name, const Texture* image); - void sendInt(const char* name, int value); - void sendVec2(const char* name, float x, float y); - void sendVec3(const char* name, float x, float y, float z); - void sendVec4(const char* name, float x, float y, float z, float w); - void sendCanvas(const char* name, const Canvas* canvas); - void sendColor(const char* name, const Color* col); - void sendMatrix4(const char* name, const math::Matrix* mat4); - - void bindVertexPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers); - void bindUVPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers); - - protected: - static Shader* currentShader; - - GLint claimTextureUnit(const std::string& name); - Shader(const std::string& program); - bool compile(const std::string& program); - - GLuint pid; - GLint currentTextureUnit; - std::map textureUnits; - - }; - - } // graphics -} // jin - -#endif // LIBJIN_MODULES_RENDER -#endif // __LIBJIN_JSL_H \ No newline at end of file diff --git a/src/libjin/Graphics/Shader/Shader.cpp b/src/libjin/Graphics/Shader/Shader.cpp new file mode 100644 index 0000000..163ba92 --- /dev/null +++ b/src/libjin/Graphics/Shader/Shader.cpp @@ -0,0 +1,282 @@ +#include +#include "../../jin_configuration.h" +#if LIBJIN_MODULES_RENDER + +#include + +#include "../../Filesystem/Buffer.h" +#include "../../utils/macros.h" +#include "Shader.h" +namespace jin +{ + namespace graphics + { + + using namespace jin::filesystem; + using namespace std; + + /** + * default_texture + * base_shader + * SHADER_FORMAT_SIZE + * formatShader + */ + #include "default.shader.h" + + /** + * https://stackoverflow.com/questions/27941496/use-sampler-without-passing-through-value + * The default value of a sampler variable is 0. From the GLSL 3.30 spec, + * section "4.3.5 Uniforms": + * + * The link time initial value is either the value of the variable's + * initializer, if present, or 0 if no initializer is present.Sampler + * types cannot have initializers. + * + * Since a value of 0 means that it's sampling from texture unit 0, it will + * work without ever setting the value as long as you bind your textures to + * unit 0. This is well defined behavior. + * + * Since texture unit 0 is also the default until you call glActiveTexture() + * with a value other than GL_TEXTURE0, it's very common to always use unit + * 0 as long as shaders do not need more than one texture.Which means that + * often times, setting the sampler uniforms is redundant for simple + * applications. + * + * I would still prefer to always set the values.If nothing else, it makes + * it clear to anybody reading your code that you really mean to sample from + * texture unit 0, and did not just forget to set the value. + */ + const int DEFAULT_TEXTURE_UNIT = 0; + + /*static*/ Shader* Shader::CurrentShader = nullptr; + + Shader* Shader::createShader(const string& program) + { + Shader* shader = nullptr; + try + { + shader = new Shader(program); + } + catch(...) + { + return nullptr; + } + return shader; + } + + Shader::Shader(const string& program) + : mCurrentTextureUnit(DEFAULT_TEXTURE_UNIT) + { + if (!compile(program)) + throw 0; + } + + Shader::~Shader() + { + if (CurrentShader == this) + unuse(); + } + + bool Shader::compile(const string& program) + { + /* parse shader source, need some optimizations */ + int loc_VERTEX_SHADER = program.find("#VERTEX_SHADER"); + int loc_END_VERTEX_SHADER = program.find("#END_VERTEX_SHADER"); + int loc_FRAGMENT_SHADER = program.find("#FRAGMENT_SHADER"); + int loc_END_FRAGMENT_SHADER = program.find("#END_FRAGMENT_SHADER"); + if (loc_VERTEX_SHADER == string::npos + || loc_END_VERTEX_SHADER == string::npos + || loc_FRAGMENT_SHADER == string::npos + || loc_END_FRAGMENT_SHADER == string::npos + ) + return false; + /* load vertex and fragment shader source into buffers */ + int start = loc_VERTEX_SHADER + strlen("#VERTEX_SHADER"); + string vertex_shader = program.substr(start, loc_END_VERTEX_SHADER - start); + Buffer vbuffer = Buffer(vertex_shader.length() + BASE_VERTEX_SHADER_SIZE); + formatVertexShader((char*)vbuffer.data, vertex_shader.c_str()); + start = loc_FRAGMENT_SHADER + strlen("#FRAGMENT_SHADER"); + string fragment_shader = program.substr(start, loc_END_FRAGMENT_SHADER - start); + Buffer fbuffer = Buffer(fragment_shader.length() + BASE_FRAGMENT_SHADER_SIZE); + formatFragmentShader((char*)fbuffer.data, fragment_shader.c_str()); + /* compile */ + GLint success; + GLuint vshader = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vshader, 1, (const GLchar**)&vbuffer.data, NULL); + glCompileShader(vshader); + glGetShaderiv(vshader, GL_COMPILE_STATUS, &success); + if (success == GL_FALSE) + return false; + GLuint fshader = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fshader, 1, (const GLchar**)&fbuffer.data, NULL); + glCompileShader(fshader); + glGetShaderiv(fshader, GL_COMPILE_STATUS, &success); + if (success == GL_FALSE) + return false; + mPID = glCreateProgram(); + glAttachShader(mPID, vshader); + glAttachShader(mPID, fshader); + glLinkProgram(mPID); + glGetProgramiv(mPID, GL_LINK_STATUS, &success); + if (success == GL_FALSE) + throw false; + } + + static inline GLint getMaxTextureUnits() + { + GLint maxTextureUnits = 0; + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits); + return maxTextureUnits; + } + + void Shader::use() + { + glUseProgram(mPID); + CurrentShader = this; + sendInt(SHADER_MAIN_TEXTURE, DEFAULT_TEXTURE_UNIT); + } + + /*static*/ void Shader::unuse() + { + glUseProgram(0); + CurrentShader = nullptr; + } + + GLint Shader::claimTextureUnit(const std::string& name) + { + std::map::iterator unit = mTextureUnits.find(name); + if (unit != mTextureUnits.end()) + return unit->second; + static GLint MAX_TEXTURE_UNITS = getMaxTextureUnits(); + if (++mCurrentTextureUnit >= MAX_TEXTURE_UNITS) + return 0; + mTextureUnits[name] = mCurrentTextureUnit; + return mCurrentTextureUnit; + } + + #define checkJSL() \ + if (CurrentShader != this) \ + return + + void Shader::sendInt(const char* name, int value) + { + checkJSL(); + int loc = glGetUniformLocation(mPID, name); + glUniform1i(loc, value); + } + + void Shader::sendFloat(const char* variable, float number) + { + checkJSL(); + int loc = glGetUniformLocation(mPID, variable); + glUniform1f(loc, number); + } + + /** + * https://www.douban.com/note/627332677/ + * struct TextureUnit + * { + * GLuint targetTexture1D; + * GLuint targetTexture2D; + * GLuint targetTexture3D; + * GLuint targetTextureCube; + * ... + * }; + * + * TextureUnit mTextureUnits[GL_MAX_TEXTURE_IMAGE_UNITS] + * GLuint mCurrentTextureUnit = 0; + */ + void Shader::sendTexture(const char* variable, const Texture* tex) + { + checkJSL(); + GLint location = glGetUniformLocation(mPID, variable); + if (location == -1) + return; + GLint unit = claimTextureUnit(variable); + if (unit == 0) + { + // TODO: Òì³£´¦Àí£¬°ó¶¨µÄÎÆÀí³¬¹ý×î´óÏÞÖÆ + return; + } + gl.activeTexUnit(unit); + glUniform1i(location, unit); + gl.bindTexture(tex->getTexture()); + gl.activeTexUnit(0); + } + + void Shader::sendCanvas(const char* variable, const Canvas* canvas) + { + checkJSL(); + GLint location = glGetUniformLocation(mPID, variable); + if (location == -1) + return; + GLint unit = claimTextureUnit(variable); + if (unit == 0) + { + // TODO: Òì³£´¦Àí£¬°ó¶¨µÄÎÆÀí³¬¹ý×î´óÏÞÖÆ + return; + } + glUniform1i(location, unit); + glActiveTexture(GL_TEXTURE0 + unit); + gl.bindTexture(canvas->getTexture()); + + glActiveTexture(GL_TEXTURE0); + } + + void Shader::sendVec2(const char* name, float x, float y) + { + checkJSL(); + int loc = glGetUniformLocation(mPID, name); + glUniform2f(loc, x, y); + } + + void Shader::sendVec3(const char* name, float x, float y, float z) + { + checkJSL(); + int loc = glGetUniformLocation(mPID, name); + glUniform3f(loc, x, y, z); + } + + void Shader::sendVec4(const char* name, float x, float y, float z, float w) + { + checkJSL(); + int loc = glGetUniformLocation(mPID, name); + glUniform4f(loc, x, y, z, w); + } + + void Shader::sendColor(const char* name, const Color* col) + { + checkJSL(); + int loc = glGetUniformLocation(mPID, name); + glUniform4f(loc, + col->r / 255.f, + col->g / 255.f, + col->b / 255.f, + col->a / 255.f + ); + } + + void Shader::sendMatrix4(const char* name, const math::Matrix* mat4) + { + int loc = glGetUniformLocation(mPID, name); + glUniformMatrix4fv(loc, 1, GL_FALSE, mat4->getElements()); + } + + void Shader::bindVertexPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers) + { + GLint loc = glGetAttribLocation(mPID, SHADER_VERTEX_COORDS); + glEnableVertexAttribArray(0); + glVertexAttribPointer(loc, n, type, GL_FALSE, stride, pointers); + } + + void Shader::bindUVPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers) + { + GLint loc = glGetAttribLocation(mPID, SHADER_TEXTURE_COORDS); + glEnableVertexAttribArray(1); + glVertexAttribPointer(loc, n, type, GL_FALSE, stride, pointers); + } + + } // namespace graphics +} // namespace jin + +#endif // LIBJIN_MODULES_RENDER \ No newline at end of file diff --git a/src/libjin/Graphics/Shader/Shader.h b/src/libjin/Graphics/Shader/Shader.h new file mode 100644 index 0000000..b9f83e7 --- /dev/null +++ b/src/libjin/Graphics/Shader/Shader.h @@ -0,0 +1,123 @@ +#ifndef __LIBJIN_SHADER_H +#define __LIBJIN_SHADER_H +#include "../../jin_configuration.h" +#if LIBJIN_MODULES_RENDER + +#include +#include +#include "../../3rdparty/GLee/GLee.h" +#include "../color.h" +#include "../texture.h" +#include "../canvas.h" +#include "base.shader.h" + +namespace jin +{ + namespace graphics + { + /// + /// @details Built in shader program. + /// + class Shader + { + public: + /// + /// @brief Create shader program from source code. + /// + /// @param source The shader source code. + /// + static Shader* createShader(const std::string& source); + + /// + /// @brief Get current shader. + /// + static inline Shader* getCurrentShader() { return CurrentShader; } + + /// + /// @brief Unuse current shader + /// + static void unuse(); + + /// + /// + /// + virtual ~Shader(); + + /// + /// + /// + void use(); + + /// + /// + /// + void sendFloat(const char* name, float number); + + /// + /// + /// + void sendTexture(const char* name, const Texture* image); + + /// + /// + /// + void sendInt(const char* name, int value); + + /// + /// + /// + void sendVec2(const char* name, float x, float y); + + /// + /// + /// + void sendVec3(const char* name, float x, float y, float z); + + /// + /// + /// + void sendVec4(const char* name, float x, float y, float z, float w); + + /// + /// + /// + void sendCanvas(const char* name, const Canvas* canvas); + + /// + /// + /// + void sendColor(const char* name, const Color* col); + + /// + /// + /// + void sendMatrix4(const char* name, const math::Matrix* mat4); + + /// + /// + /// + void bindVertexPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers); + + /// + /// + /// + void bindUVPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers); + + protected: + static Shader* CurrentShader; + + GLint claimTextureUnit(const std::string& name); + Shader(const std::string& program); + bool compile(const std::string& program); + + GLuint mPID; + GLint mCurrentTextureUnit; + std::map mTextureUnits; + + }; + + } // namespace graphics +} // namespace jin + +#endif // LIBJIN_MODULES_RENDER +#endif // __LIBJIN_SHADER_H \ No newline at end of file diff --git a/src/libjin/Graphics/Shader/base.shader.h b/src/libjin/Graphics/Shader/base.shader.h new file mode 100644 index 0000000..45b63cd --- /dev/null +++ b/src/libjin/Graphics/Shader/base.shader.h @@ -0,0 +1,88 @@ +#ifndef __LIBJIN_BASE_SHADER_H +#define __LIBJIN_BASE_SHADER_H + +static const char* base_shared = R"( +#define Number float +#define Texture sampler2D +#define Canvas sampler2D +#define Color vec4 +#define Vec2 vec2 +#define Vec3 vec3 +#define Vec4 vec4 + +#define texel texture2D + +struct Vertex +{ + vec2 xy; + vec2 uv; +}; + +)"; + +static const int BASE_SHARED_SIZE = strlen(base_shared); + +static const char* base_vertex = R"( +#version 130 core + +%s + +uniform mat4 jin_ProjectionMatrix; +uniform mat4 jin_ModelMatrix; + +in vec2 jin_VertexCoords; +in vec2 jin_TextureCoords; + +out vec4 jin_Color; +out vec2 jin_XY; +out vec2 jin_UV; + +%s + +void main() +{ + vec4 v = jin_ModelMatrix * vec4(jin_VertexCoords, 0, 1.0); + Vertex _v = vert(Vertex(v.xy, jin_TextureCoords)); + gl_Position = jin_ProjectionMatrix * vec4(_v.xy, 0, 1.0f); + jin_Color = gl_Color; + jin_XY = _v.xy; + jin_UV = _v.uv; +} +)"; + +static const int BASE_VERTEX_SHADER_SIZE = strlen(base_vertex) + BASE_SHARED_SIZE; + +#define formatVertexShader(buf, program) sprintf(buf,base_vertex, base_shared, program) + +static const char* base_fragment = R"( +#version 130 core + +%s + +uniform Texture jin_MainTexture; + +in vec4 jin_Color; +in vec2 jin_XY; +in vec2 jin_UV; + +out vec4 jin_OutColor; + +%s + +void main() +{ + jin_OutColor = frag(jin_Color, jin_MainTexture, Vertex(jin_XY, jin_UV)); +} +)"; + +static const int BASE_FRAGMENT_SHADER_SIZE = strlen(base_fragment) + BASE_SHARED_SIZE; + +#define formatFragmentShader(buf, program) sprintf(buf, base_fragment, base_shared, program) + +static const char* SHADER_PROJECTION_MATRIX = "jin_ProjectionMatrix"; +static const char* SHADER_MODEL_MATRIX = "jin_ModelMatrix"; +static const char* SHADER_MAIN_TEXTURE = "jin_MainTexture"; +static const char* SHADER_VERTEX_COORDS = "jin_VertexCoords"; +static const char* SHADER_TEXTURE_COORDS = "jin_TextureCoords"; + +#endif \ No newline at end of file diff --git a/src/libjin/Graphics/Shader/default.shader.h b/src/libjin/Graphics/Shader/default.shader.h new file mode 100644 index 0000000..f0175d7 --- /dev/null +++ b/src/libjin/Graphics/Shader/default.shader.h @@ -0,0 +1,21 @@ +// ĬÈÏshader +static const char* default_shader = R"( + +#VERTEX_SHADER + +Vertex vert(Vertex v) +{ + return v; +} + +#END_VERTEX_SHADER + +#FRAGMENT_SHADER + +Color frag(Color col, Texture tex, Vertex v) +{ + return col; +} + +#END_FRAGMENT_SHADER +)"; \ No newline at end of file diff --git a/src/libjin/Graphics/Shader/font.shader.h b/src/libjin/Graphics/Shader/font.shader.h new file mode 100644 index 0000000..e04c225 --- /dev/null +++ b/src/libjin/Graphics/Shader/font.shader.h @@ -0,0 +1,21 @@ +// ×ÖÌåshader +static const char* font_shader = R"( + +#VERTEX_SHADER + +Vertex vert(Vertex v) +{ + return v; +} + +#END_VERTEX_SHADER + +#FRAGMENT_SHADER + +Color frag(Color col, Texture tex, Vertex v) +{ + return Color(col.rgb, texel(tex, v.uv).a); +} + +#END_FRAGMENT_SHADER +)"; \ No newline at end of file diff --git a/src/libjin/Graphics/Shader/texture.shader.h b/src/libjin/Graphics/Shader/texture.shader.h new file mode 100644 index 0000000..d1fc86f --- /dev/null +++ b/src/libjin/Graphics/Shader/texture.shader.h @@ -0,0 +1,21 @@ +// Ìùͼshader +static const char* texture_shader = R"( + +#VERTEX_SHADER + +Vertex vert(Vertex v) +{ + return v; +} + +#END_VERTEX_SHADER + +#FRAGMENT_SHADER + +Color frag(Color col, Texture tex, Vertex v) +{ + return col * texel(tex, v.uv); +} + +#END_FRAGMENT_SHADER +)"; \ No newline at end of file diff --git a/src/libjin/Graphics/Shaders/base.shader.h b/src/libjin/Graphics/Shaders/base.shader.h deleted file mode 100644 index 45b63cd..0000000 --- a/src/libjin/Graphics/Shaders/base.shader.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef __LIBJIN_BASE_SHADER_H -#define __LIBJIN_BASE_SHADER_H - -static const char* base_shared = R"( -#define Number float -#define Texture sampler2D -#define Canvas sampler2D -#define Color vec4 -#define Vec2 vec2 -#define Vec3 vec3 -#define Vec4 vec4 - -#define texel texture2D - -struct Vertex -{ - vec2 xy; - vec2 uv; -}; - -)"; - -static const int BASE_SHARED_SIZE = strlen(base_shared); - -static const char* base_vertex = R"( -#version 130 core - -%s - -uniform mat4 jin_ProjectionMatrix; -uniform mat4 jin_ModelMatrix; - -in vec2 jin_VertexCoords; -in vec2 jin_TextureCoords; - -out vec4 jin_Color; -out vec2 jin_XY; -out vec2 jin_UV; - -%s - -void main() -{ - vec4 v = jin_ModelMatrix * vec4(jin_VertexCoords, 0, 1.0); - Vertex _v = vert(Vertex(v.xy, jin_TextureCoords)); - gl_Position = jin_ProjectionMatrix * vec4(_v.xy, 0, 1.0f); - jin_Color = gl_Color; - jin_XY = _v.xy; - jin_UV = _v.uv; -} -)"; - -static const int BASE_VERTEX_SHADER_SIZE = strlen(base_vertex) + BASE_SHARED_SIZE; - -#define formatVertexShader(buf, program) sprintf(buf,base_vertex, base_shared, program) - -static const char* base_fragment = R"( -#version 130 core - -%s - -uniform Texture jin_MainTexture; - -in vec4 jin_Color; -in vec2 jin_XY; -in vec2 jin_UV; - -out vec4 jin_OutColor; - -%s - -void main() -{ - jin_OutColor = frag(jin_Color, jin_MainTexture, Vertex(jin_XY, jin_UV)); -} -)"; - -static const int BASE_FRAGMENT_SHADER_SIZE = strlen(base_fragment) + BASE_SHARED_SIZE; - -#define formatFragmentShader(buf, program) sprintf(buf, base_fragment, base_shared, program) - -static const char* SHADER_PROJECTION_MATRIX = "jin_ProjectionMatrix"; -static const char* SHADER_MODEL_MATRIX = "jin_ModelMatrix"; -static const char* SHADER_MAIN_TEXTURE = "jin_MainTexture"; -static const char* SHADER_VERTEX_COORDS = "jin_VertexCoords"; -static const char* SHADER_TEXTURE_COORDS = "jin_TextureCoords"; - -#endif \ No newline at end of file diff --git a/src/libjin/Graphics/Shaders/default.shader.h b/src/libjin/Graphics/Shaders/default.shader.h deleted file mode 100644 index f0175d7..0000000 --- a/src/libjin/Graphics/Shaders/default.shader.h +++ /dev/null @@ -1,21 +0,0 @@ -// ĬÈÏshader -static const char* default_shader = R"( - -#VERTEX_SHADER - -Vertex vert(Vertex v) -{ - return v; -} - -#END_VERTEX_SHADER - -#FRAGMENT_SHADER - -Color frag(Color col, Texture tex, Vertex v) -{ - return col; -} - -#END_FRAGMENT_SHADER -)"; \ No newline at end of file diff --git a/src/libjin/Graphics/Shaders/font.shader.h b/src/libjin/Graphics/Shaders/font.shader.h deleted file mode 100644 index e04c225..0000000 --- a/src/libjin/Graphics/Shaders/font.shader.h +++ /dev/null @@ -1,21 +0,0 @@ -// ×ÖÌåshader -static const char* font_shader = R"( - -#VERTEX_SHADER - -Vertex vert(Vertex v) -{ - return v; -} - -#END_VERTEX_SHADER - -#FRAGMENT_SHADER - -Color frag(Color col, Texture tex, Vertex v) -{ - return Color(col.rgb, texel(tex, v.uv).a); -} - -#END_FRAGMENT_SHADER -)"; \ No newline at end of file diff --git a/src/libjin/Graphics/Shaders/texture.shader.h b/src/libjin/Graphics/Shaders/texture.shader.h deleted file mode 100644 index d1fc86f..0000000 --- a/src/libjin/Graphics/Shaders/texture.shader.h +++ /dev/null @@ -1,21 +0,0 @@ -// Ìùͼshader -static const char* texture_shader = R"( - -#VERTEX_SHADER - -Vertex vert(Vertex v) -{ - return v; -} - -#END_VERTEX_SHADER - -#FRAGMENT_SHADER - -Color frag(Color col, Texture tex, Vertex v) -{ - return col * texel(tex, v.uv); -} - -#END_FRAGMENT_SHADER -)"; \ No newline at end of file diff --git a/src/libjin/Graphics/Shapes.cpp b/src/libjin/Graphics/Shapes.cpp index 5e87473..b99c569 100644 --- a/src/libjin/Graphics/Shapes.cpp +++ b/src/libjin/Graphics/Shapes.cpp @@ -1,7 +1,7 @@ #include "../jin_configuration.h" #if LIBJIN_MODULES_RENDER -#include "Shader.h" +#include "./Shader/Shader.h" #include "Shapes.h" #include "../math/matrix.h" #include "../math/constant.h" @@ -120,7 +120,7 @@ namespace jin } } - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER \ No newline at end of file diff --git a/src/libjin/Graphics/Shapes.h b/src/libjin/Graphics/Shapes.h index 93cde6d..61efcfe 100644 --- a/src/libjin/Graphics/Shapes.h +++ b/src/libjin/Graphics/Shapes.h @@ -30,8 +30,8 @@ namespace jin extern void points(int n, GLshort* p, GLubyte* c); extern void polygon(RenderMode mode, float* p, int count); - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER #endif // __LIBJIN_GEOMETRY_H \ No newline at end of file diff --git a/src/libjin/Graphics/Texture.cpp b/src/libjin/Graphics/Texture.cpp index 915fe54..4af29a7 100644 --- a/src/libjin/Graphics/Texture.cpp +++ b/src/libjin/Graphics/Texture.cpp @@ -28,7 +28,7 @@ namespace jin { } - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER \ No newline at end of file diff --git a/src/libjin/Graphics/Texture.h b/src/libjin/Graphics/Texture.h index eb16519..15fd78e 100644 --- a/src/libjin/Graphics/Texture.h +++ b/src/libjin/Graphics/Texture.h @@ -24,8 +24,8 @@ namespace jin }; - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER #endif // __LIBJIN_TEXTURE_H \ No newline at end of file diff --git a/src/libjin/Graphics/Window.cpp b/src/libjin/Graphics/Window.cpp index 140ef36..7f8f02d 100644 --- a/src/libjin/Graphics/Window.cpp +++ b/src/libjin/Graphics/Window.cpp @@ -5,7 +5,7 @@ #include "window.h" #include "OpenGL.h" #include "canvas.h" -#include "Shader.h" +#include "./Shader/Shader.h" #include "../utils/utils.h" #include "../audio/sdl/SDLAudio.h" #include "../utils/log.h" @@ -103,7 +103,7 @@ namespace jin SDL_SetWindowTitle(wnd, title); }; - } // graphics -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER \ No newline at end of file diff --git a/src/libjin/Graphics/Window.h b/src/libjin/Graphics/Window.h index 3734ee3..5871562 100644 --- a/src/libjin/Graphics/Window.h +++ b/src/libjin/Graphics/Window.h @@ -48,8 +48,8 @@ namespace jin }; - } // render -} // jin + } // namespace graphics +} // namespace jin #endif // LIBJIN_MODULES_RENDER #endif // __LIBJIN_RENDER_WINDOW \ No newline at end of file diff --git a/src/libjin/Input/Event.cpp b/src/libjin/Input/Event.cpp index 3edff01..c8eb78c 100644 --- a/src/libjin/Input/Event.cpp +++ b/src/libjin/Input/Event.cpp @@ -4,4 +4,4 @@ namespace jin { -} // jin \ No newline at end of file +} // namespace jin \ No newline at end of file diff --git a/src/libjin/Input/Event.h b/src/libjin/Input/Event.h index 9a31c06..af2ced2 100644 --- a/src/libjin/Input/Event.h +++ b/src/libjin/Input/Event.h @@ -98,8 +98,8 @@ namespace jin */ #endif // LIBJIN_INPUT_SDL - } // input - } // jin + } // namespace input +} // namespace jin - #endif // LIBJIN_MODULES_INPUT +#endif // LIBJIN_MODULES_INPUT #endif \ No newline at end of file diff --git a/src/libjin/Input/Joypad.h b/src/libjin/Input/Joypad.h index 50cbe01..570699e 100644 --- a/src/libjin/Input/Joypad.h +++ b/src/libjin/Input/Joypad.h @@ -44,7 +44,7 @@ namespace jin } } - } // input -} // jin + } // namespace input +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Input/Keyboard.h b/src/libjin/Input/Keyboard.h index b50302c..60f1169 100644 --- a/src/libjin/Input/Keyboard.h +++ b/src/libjin/Input/Keyboard.h @@ -11,7 +11,7 @@ namespace jin }; - } // input -} // jin + } // namespace input +} // namespace jin #endif // __LIBJIN_KEYBOARD_H \ No newline at end of file diff --git a/src/libjin/Input/Mouse.cpp b/src/libjin/Input/Mouse.cpp index 3869337..9fcb4ee 100644 --- a/src/libjin/Input/Mouse.cpp +++ b/src/libjin/Input/Mouse.cpp @@ -21,7 +21,7 @@ namespace jin SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE); } - } // input -} // jin + } // namespace input +} // namespace jin #endif // LIBJIN_MODULES_INPUT \ No newline at end of file diff --git a/src/libjin/Input/Mouse.h b/src/libjin/Input/Mouse.h index 29d730b..5f77f0d 100644 --- a/src/libjin/Input/Mouse.h +++ b/src/libjin/Input/Mouse.h @@ -24,8 +24,8 @@ namespace jin }; - } // input -} // jin + } // namespace input +} // namespace jin #endif // LIBJIN_MODULES_INPUT #endif // __LIBJIN_MOUSE_H \ No newline at end of file diff --git a/src/libjin/Math/Math.h b/src/libjin/Math/Math.h index 98f9cd8..c1b5084 100644 --- a/src/libjin/Math/Math.h +++ b/src/libjin/Math/Math.h @@ -71,7 +71,7 @@ namespace jin return a + t * (b - a); } - } // math -} // jin + } // namespace math +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Math/Matrix.cpp b/src/libjin/Math/Matrix.cpp index 74d3a58..9f933f8 100644 --- a/src/libjin/Math/Matrix.cpp +++ b/src/libjin/Math/Matrix.cpp @@ -190,5 +190,5 @@ namespace jin } } - } // math -} // jin \ No newline at end of file + } // namespace math +} // namespace jin \ No newline at end of file diff --git a/src/libjin/Math/Matrix.h b/src/libjin/Math/Matrix.h index c1f903a..1fe6ab1 100644 --- a/src/libjin/Math/Matrix.h +++ b/src/libjin/Math/Matrix.h @@ -153,7 +153,7 @@ namespace jin }; - } // math -} // jin + } // namespace math +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Math/Quad.h b/src/libjin/Math/Quad.h index c649cf7..6eb4f45 100644 --- a/src/libjin/Math/Quad.h +++ b/src/libjin/Math/Quad.h @@ -11,7 +11,7 @@ namespace jin float x, y, w, h; }; - } // math -} // jin + } // namespace math +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Math/Vector2.hpp b/src/libjin/Math/Vector2.hpp index f0bbfc7..51ac4a7 100644 --- a/src/libjin/Math/Vector2.hpp +++ b/src/libjin/Math/Vector2.hpp @@ -34,7 +34,7 @@ namespace jin }; - } // math -} // jin + } // namespace math +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Math/Vector3.hpp b/src/libjin/Math/Vector3.hpp index 9b38cad..96d4e9a 100644 --- a/src/libjin/Math/Vector3.hpp +++ b/src/libjin/Math/Vector3.hpp @@ -35,7 +35,7 @@ namespace jin }; - } // math -} // jin + } // namespace math +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Math/Vector4.hpp b/src/libjin/Math/Vector4.hpp index e2978d4..35be056 100644 --- a/src/libjin/Math/Vector4.hpp +++ b/src/libjin/Math/Vector4.hpp @@ -39,7 +39,7 @@ namespace jin }; - } // math -} // jin + } // namespace math +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/Net/Net.cpp b/src/libjin/Net/Net.cpp index 8fd4256..940b239 100644 --- a/src/libjin/Net/Net.cpp +++ b/src/libjin/Net/Net.cpp @@ -20,5 +20,5 @@ namespace jin } - } // net -} // jin \ No newline at end of file + } // namespace net +} // namespace jin \ No newline at end of file diff --git a/src/libjin/Net/Net.h b/src/libjin/Net/Net.h index b5f999f..4cf6e93 100644 --- a/src/libjin/Net/Net.h +++ b/src/libjin/Net/Net.h @@ -24,8 +24,8 @@ namespace jin }; - } // net -} // jin + } // namespace net +} // namespace jin #endif // LIBJIN_MODULES_NET #endif // __LIBJIN_NET_H diff --git a/src/libjin/Net/Socket.cpp b/src/libjin/Net/Socket.cpp index 2a1454b..770b47d 100644 --- a/src/libjin/Net/Socket.cpp +++ b/src/libjin/Net/Socket.cpp @@ -186,5 +186,5 @@ namespace jin } } - } // net -} // jin \ No newline at end of file + } // namespace net +} // namespace jin \ No newline at end of file diff --git a/src/libjin/Net/Socket.h b/src/libjin/Net/Socket.h index ad2ce60..dfc1e41 100644 --- a/src/libjin/Net/Socket.h +++ b/src/libjin/Net/Socket.h @@ -55,8 +55,8 @@ namespace jin }; - } // net -} // jin + } // namespace net +} // namespace jin #endif // LIBJIN_MODULES_NET #endif // __LIBJIN_NET_SOCKET_H diff --git a/src/libjin/Net/net.cpp b/src/libjin/Net/net.cpp index 8fd4256..940b239 100644 --- a/src/libjin/Net/net.cpp +++ b/src/libjin/Net/net.cpp @@ -20,5 +20,5 @@ namespace jin } - } // net -} // jin \ No newline at end of file + } // namespace net +} // namespace jin \ No newline at end of file diff --git a/src/libjin/Net/net.h b/src/libjin/Net/net.h index b5f999f..4cf6e93 100644 --- a/src/libjin/Net/net.h +++ b/src/libjin/Net/net.h @@ -24,8 +24,8 @@ namespace jin }; - } // net -} // jin + } // namespace net +} // namespace jin #endif // LIBJIN_MODULES_NET #endif // __LIBJIN_NET_H diff --git a/src/libjin/Thread/Thread.cpp b/src/libjin/Thread/Thread.cpp index 0703f1b..6eefca1 100644 --- a/src/libjin/Thread/Thread.cpp +++ b/src/libjin/Thread/Thread.cpp @@ -295,7 +295,7 @@ namespace jin unlock(); } - } // thread -} // jin + } // namespace thread +} // namespace jin #endif // LIBJIN_MODULES_THREAD \ No newline at end of file diff --git a/src/libjin/Thread/Thread.h b/src/libjin/Thread/Thread.h index d6d0a19..7c126e4 100644 --- a/src/libjin/Thread/Thread.h +++ b/src/libjin/Thread/Thread.h @@ -159,8 +159,8 @@ namespace jin }; - } // thread -} // jin + } // namespace thread +} // namespace jin #endif // LIBJIN_MODULES_THREAD #endif // __LIBJIN_THREAD_H \ No newline at end of file diff --git a/src/libjin/Thread/thread.cpp b/src/libjin/Thread/thread.cpp index 0703f1b..6eefca1 100644 --- a/src/libjin/Thread/thread.cpp +++ b/src/libjin/Thread/thread.cpp @@ -295,7 +295,7 @@ namespace jin unlock(); } - } // thread -} // jin + } // namespace thread +} // namespace jin #endif // LIBJIN_MODULES_THREAD \ No newline at end of file diff --git a/src/libjin/Thread/thread.h b/src/libjin/Thread/thread.h index d6d0a19..7c126e4 100644 --- a/src/libjin/Thread/thread.h +++ b/src/libjin/Thread/thread.h @@ -159,8 +159,8 @@ namespace jin }; - } // thread -} // jin + } // namespace thread +} // namespace jin #endif // LIBJIN_MODULES_THREAD #endif // __LIBJIN_THREAD_H \ No newline at end of file diff --git a/src/libjin/Time/Timer.cpp b/src/libjin/Time/Timer.cpp index 426f2d5..54fb2a3 100644 --- a/src/libjin/Time/Timer.cpp +++ b/src/libjin/Time/Timer.cpp @@ -94,7 +94,7 @@ namespace jin return true; } - } // time -} // jin + } // namespace time +} // namespace jin #endif // LIBJIN_MODULES_TIME diff --git a/src/libjin/Time/Timer.h b/src/libjin/Time/Timer.h index 93a90ae..8f49ec3 100644 --- a/src/libjin/Time/Timer.h +++ b/src/libjin/Time/Timer.h @@ -70,8 +70,8 @@ namespace jin #endif } - } // time -} // jin + } // namespace time +} // namespace jin #endif // LIBJIN_MODULES_TIME #endif // __LIBJIN_TIMER_H diff --git a/src/libjin/audio/audio.cpp b/src/libjin/audio/audio.cpp index d148467..6c68b35 100644 --- a/src/libjin/audio/audio.cpp +++ b/src/libjin/audio/audio.cpp @@ -9,7 +9,7 @@ namespace jin namespace audio { - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO diff --git a/src/libjin/audio/audio.h b/src/libjin/audio/audio.h index 48cbfe4..5ba0844 100644 --- a/src/libjin/audio/audio.h +++ b/src/libjin/audio/audio.h @@ -45,8 +45,8 @@ namespace jin }; - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO #endif // __LIBJIN_AUDIO_H diff --git a/src/libjin/audio/source.cpp b/src/libjin/audio/source.cpp index 306d93f..8da4cde 100644 --- a/src/libjin/audio/source.cpp +++ b/src/libjin/audio/source.cpp @@ -23,7 +23,7 @@ namespace jin return SourceType::INVALID; } - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO diff --git a/src/libjin/audio/source.h b/src/libjin/audio/source.h index 40707de..07a9a4e 100644 --- a/src/libjin/audio/source.h +++ b/src/libjin/audio/source.h @@ -40,8 +40,8 @@ namespace jin }; - } // audio -} // jin + } // namespace audio +} // namespace jin #endif // LIBJIN_MODULES_AUDIO #endif // __LIBJIN_AUDIO_SOURCE_H diff --git a/src/libjin/input/event.cpp b/src/libjin/input/event.cpp index 3edff01..c8eb78c 100644 --- a/src/libjin/input/event.cpp +++ b/src/libjin/input/event.cpp @@ -4,4 +4,4 @@ namespace jin { -} // jin \ No newline at end of file +} // namespace jin \ No newline at end of file diff --git a/src/libjin/input/event.h b/src/libjin/input/event.h index 9a31c06..af2ced2 100644 --- a/src/libjin/input/event.h +++ b/src/libjin/input/event.h @@ -98,8 +98,8 @@ namespace jin */ #endif // LIBJIN_INPUT_SDL - } // input - } // jin + } // namespace input +} // namespace jin - #endif // LIBJIN_MODULES_INPUT +#endif // LIBJIN_MODULES_INPUT #endif \ No newline at end of file diff --git a/src/libjin/input/joypad.h b/src/libjin/input/joypad.h index 50cbe01..570699e 100644 --- a/src/libjin/input/joypad.h +++ b/src/libjin/input/joypad.h @@ -44,7 +44,7 @@ namespace jin } } - } // input -} // jin + } // namespace input +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/input/keyboard.h b/src/libjin/input/keyboard.h index b50302c..60f1169 100644 --- a/src/libjin/input/keyboard.h +++ b/src/libjin/input/keyboard.h @@ -11,7 +11,7 @@ namespace jin }; - } // input -} // jin + } // namespace input +} // namespace jin #endif // __LIBJIN_KEYBOARD_H \ No newline at end of file diff --git a/src/libjin/input/mouse.cpp b/src/libjin/input/mouse.cpp index 3869337..9fcb4ee 100644 --- a/src/libjin/input/mouse.cpp +++ b/src/libjin/input/mouse.cpp @@ -21,7 +21,7 @@ namespace jin SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE); } - } // input -} // jin + } // namespace input +} // namespace jin #endif // LIBJIN_MODULES_INPUT \ No newline at end of file diff --git a/src/libjin/input/mouse.h b/src/libjin/input/mouse.h index 29d730b..5f77f0d 100644 --- a/src/libjin/input/mouse.h +++ b/src/libjin/input/mouse.h @@ -24,8 +24,8 @@ namespace jin }; - } // input -} // jin + } // namespace input +} // namespace jin #endif // LIBJIN_MODULES_INPUT #endif // __LIBJIN_MOUSE_H \ No newline at end of file diff --git a/src/libjin/math/math.h b/src/libjin/math/math.h index 98f9cd8..c1b5084 100644 --- a/src/libjin/math/math.h +++ b/src/libjin/math/math.h @@ -71,7 +71,7 @@ namespace jin return a + t * (b - a); } - } // math -} // jin + } // namespace math +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/math/matrix.cpp b/src/libjin/math/matrix.cpp index 74d3a58..9f933f8 100644 --- a/src/libjin/math/matrix.cpp +++ b/src/libjin/math/matrix.cpp @@ -190,5 +190,5 @@ namespace jin } } - } // math -} // jin \ No newline at end of file + } // namespace math +} // namespace jin \ No newline at end of file diff --git a/src/libjin/math/matrix.h b/src/libjin/math/matrix.h index c1f903a..1fe6ab1 100644 --- a/src/libjin/math/matrix.h +++ b/src/libjin/math/matrix.h @@ -153,7 +153,7 @@ namespace jin }; - } // math -} // jin + } // namespace math +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/math/quad.h b/src/libjin/math/quad.h index c649cf7..6eb4f45 100644 --- a/src/libjin/math/quad.h +++ b/src/libjin/math/quad.h @@ -11,7 +11,7 @@ namespace jin float x, y, w, h; }; - } // math -} // jin + } // namespace math +} // namespace jin #endif \ No newline at end of file diff --git a/src/libjin/net/net.cpp b/src/libjin/net/net.cpp index 8fd4256..940b239 100644 --- a/src/libjin/net/net.cpp +++ b/src/libjin/net/net.cpp @@ -20,5 +20,5 @@ namespace jin } - } // net -} // jin \ No newline at end of file + } // namespace net +} // namespace jin \ No newline at end of file diff --git a/src/libjin/net/net.h b/src/libjin/net/net.h index b5f999f..4cf6e93 100644 --- a/src/libjin/net/net.h +++ b/src/libjin/net/net.h @@ -24,8 +24,8 @@ namespace jin }; - } // net -} // jin + } // namespace net +} // namespace jin #endif // LIBJIN_MODULES_NET #endif // __LIBJIN_NET_H diff --git a/src/libjin/thread/thread.cpp b/src/libjin/thread/thread.cpp index 0703f1b..6eefca1 100644 --- a/src/libjin/thread/thread.cpp +++ b/src/libjin/thread/thread.cpp @@ -295,7 +295,7 @@ namespace jin unlock(); } - } // thread -} // jin + } // namespace thread +} // namespace jin #endif // LIBJIN_MODULES_THREAD \ No newline at end of file diff --git a/src/libjin/thread/thread.h b/src/libjin/thread/thread.h index d6d0a19..7c126e4 100644 --- a/src/libjin/thread/thread.h +++ b/src/libjin/thread/thread.h @@ -159,8 +159,8 @@ namespace jin }; - } // thread -} // jin + } // namespace thread +} // namespace jin #endif // LIBJIN_MODULES_THREAD #endif // __LIBJIN_THREAD_H \ No newline at end of file -- cgit v1.1-26-g67d0