From 435a1f782415b50c187bac8dea01ffbcd6856034 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 1 Jan 2019 23:20:53 +0800 Subject: *misc --- bin/SDL2.dll | Bin 771072 -> 771072 bytes bin/cembed.exe | Bin 11264 -> 11264 bytes bin/jin.exe | Bin 572928 -> 572928 bytes bin/lua51.dll | Bin 364544 -> 364544 bytes samples/post-processing/main.lua | 23 ++++++++++++++++++++--- src/libjin/graphics/shaders/je_shader.cpp | 22 ++++++++++++---------- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/bin/SDL2.dll b/bin/SDL2.dll index 9859a9c..0015b07 100644 Binary files a/bin/SDL2.dll and b/bin/SDL2.dll differ diff --git a/bin/cembed.exe b/bin/cembed.exe index d3c0e2f..fa1f590 100644 Binary files a/bin/cembed.exe and b/bin/cembed.exe differ diff --git a/bin/jin.exe b/bin/jin.exe index dc7d697..ece88fa 100644 Binary files a/bin/jin.exe and b/bin/jin.exe differ diff --git a/bin/lua51.dll b/bin/lua51.dll index b054a3f..66f6326 100644 Binary files a/bin/lua51.dll and b/bin/lua51.dll differ diff --git a/samples/post-processing/main.lua b/samples/post-processing/main.lua index 5ed54bc..8577432 100644 --- a/samples/post-processing/main.lua +++ b/samples/post-processing/main.lua @@ -30,6 +30,8 @@ local noise = nil local radial = nil local glow = nil +local panel_shader = nil + function jin.core.onLoad() jin.log.info("=============== Start Game ===============") @@ -114,7 +116,21 @@ function jin.core.onLoad() } #END_FRAGMENT_SHADER ]] - + panel_shader = jin.graphics.newShader[[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + col.a *= v.uv.x; + return col; + } + #END_FRAGMENT_SHADER + ]] pp = jin.graphics.newShaderf("./shaders/curling.jsl") pixel = jin.graphics.newShaderf("./shaders/pixel.jsl") @@ -144,6 +160,7 @@ function jin.core.onLoad() ]] jin.log.info(xml.test["@one"]) + jin.graphics.showWindow() end @@ -201,8 +218,8 @@ function jin.core.onDraw() jin.graphics.rect(jin.graphics.RenderMode.FILL, 300, 300, 100, 50) jin.graphics.unuseShader() - jin.graphics.setColor(100, 100, 100, 100) - jin.graphics.useShader(jin.graphics.Shaders.Shape) + jin.graphics.setColor(100, 100, 100, 255) + jin.graphics.useShader(panel_shader) jin.graphics.rect(jin.graphics.RenderMode.FILL, 440, 0, 140, 150) jin.graphics.unuseShader() jin.graphics.setColor(255, 255, 255, 255) diff --git a/src/libjin/graphics/shaders/je_shader.cpp b/src/libjin/graphics/shaders/je_shader.cpp index 4fa3b9e..6235128 100644 --- a/src/libjin/graphics/shaders/je_shader.cpp +++ b/src/libjin/graphics/shaders/je_shader.cpp @@ -89,7 +89,9 @@ namespace JinEngine sendVec2(SHADER_RENDERTARGET_SIZE, rt->getWidth(), rt->getHeight()); } // Reset attribute index. - mAttributeIndex = 0; + for(; mAttributeIndex > 0; --mAttributeIndex) + glDisableVertexAttribArray(mAttributeIndex); + return *this; } @@ -103,15 +105,15 @@ namespace JinEngine return false; } - #define glsl(SHADER_MODE, SHADER, SRC) \ - do{ \ - const GLchar* src = SRC.c_str(); \ - glShaderSource(SHADER, 1, &src, NULL); \ - glCompileShader(SHADER); \ - GLint success; \ - glGetShaderiv(SHADER, GL_COMPILE_STATUS, &success); \ - if (success == GL_FALSE) \ - return false; \ + #define glsl(SHADER_MODE, SHADER, SRC) \ + do{ \ + const GLchar* src = SRC.c_str(); \ + glShaderSource(SHADER, 1, &src, NULL); \ + glCompileShader(SHADER); \ + GLint success; \ + glGetShaderiv(SHADER, GL_COMPILE_STATUS, &success); \ + if (success == GL_FALSE) \ + return false; \ }while(0) // Compile vertex shader. -- cgit v1.1-26-g67d0