From 400afa99811f7ebaa598244e3826be7ba78edd2e Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Wed, 28 Dec 2011 17:38:29 -0200 Subject: [PATCH] fix outfit glitches, init combobox, move shaders, remove unused particles files, create timer utility --- CMakeLists.txt | 2 +- modules/addon_playground/playground.lua | 11 +- modules/circle2.png | Bin 845 -> 0 bytes modules/core_scripts/util.lua | 14 ++ modules/core_styles/core_styles.otmod | 1 + modules/core_styles/images/combobox.png | Bin 0 -> 291 bytes modules/core_styles/styles/comboboxes.otui | 9 ++ modules/core_widgets/core_widgets.otmod | 1 + .../core_widgets/uicombobox/uicombobox.lua | 1 + modules/game_shaders/map.frag | 10 ++ modules/{ => game_shaders}/outfit.frag | 7 +- modules/particle.otpa | 102 --------------- modules/shadertest.frag | 123 ------------------ src/framework/CMakeLists.txt | 1 + src/framework/application.cpp | 7 +- src/framework/core/clock.h | 15 --- src/framework/core/eventdispatcher.cpp | 1 - src/framework/core/logger.cpp | 2 +- src/framework/core/logger.h | 1 - src/framework/core/module.cpp | 4 +- src/framework/core/timer.cpp | 35 +++++ src/framework/core/timer.h | 43 ++++++ src/framework/graphics/hardwarebuffer.cpp | 25 ++++ src/framework/graphics/hardwarebuffer.h | 31 +++++ .../graphics/paintershaderprogram.cpp | 14 +- src/framework/graphics/paintershaderprogram.h | 4 +- src/framework/platform/x11window.cpp | 5 + src/framework/util/tools.h | 2 + src/otclient/core/creature.cpp | 15 ++- src/otclient/core/gameshadermanager.cpp | 24 ++++ src/otclient/core/gameshadermanager.h | 30 +++++ src/otclient/core/map.cpp | 2 +- 32 files changed, 273 insertions(+), 269 deletions(-) delete mode 100644 modules/circle2.png create mode 100644 modules/core_styles/images/combobox.png create mode 100644 modules/core_styles/styles/comboboxes.otui create mode 100644 modules/core_widgets/uicombobox/uicombobox.lua create mode 100644 modules/game_shaders/map.frag rename modules/{ => game_shaders}/outfit.frag (87%) delete mode 100644 modules/particle.otpa delete mode 100644 modules/shadertest.frag create mode 100644 src/framework/core/timer.cpp create mode 100644 src/framework/core/timer.h create mode 100644 src/framework/graphics/hardwarebuffer.cpp create mode 100644 src/framework/graphics/hardwarebuffer.h create mode 100644 src/otclient/core/gameshadermanager.cpp create mode 100644 src/otclient/core/gameshadermanager.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1561590c..653862a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ PROJECT(otclient) INCLUDE(src/framework/CMakeLists.txt) INCLUDE(src/otclient/CMakeLists.txt) -OPTION(USE_PCH "Use precompiled header (speed up compile)" ON) +OPTION(USE_PCH "Use precompiled header (speed up compile)" OFF) SET(executable_SOURCES src/main.cpp) diff --git a/modules/addon_playground/playground.lua b/modules/addon_playground/playground.lua index 805983c3..02ec1df1 100644 --- a/modules/addon_playground/playground.lua +++ b/modules/addon_playground/playground.lua @@ -1 +1,10 @@ --- place any code for testing purposes here \ No newline at end of file +-- place any code for testing purposes here + +function init() + local box = UIComboBox.create() + box:setStyle('ComboBox') + box:moveTo({x=100, y=8}) + UI.display(box) +end + +addEvent(init) \ No newline at end of file diff --git a/modules/circle2.png b/modules/circle2.png deleted file mode 100644 index 5b3a1b1c966e39d2a6497c642bd5471c6ec8ed56..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 845 zcmV-T1G4;yP)Px#24YJ`L;wH)0002_L%V+f000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipt@ z1}QW1&Sr=J0013nR9JLFZ*6U5Zgc_CX>@2HM@dakWG-a~0007{ zNklUI{*`z zUjeAumjEv8l}z&$0tTJ{NCC{)&-t9NpKyE)pderY-~`~z_0N1CJQ6nmz98rwfE9ox z-_6)mfr2du@B!ce;3&2dB+*5{zzui};DP;`q~@LiC$>G?RBQ)AqL+Z3xyii(umSMM zw&njNzpDZ#?)+W8#T_2fgb1j?&A9tDfqw#c2JnMQ+*2V{AP2A`xm3QHH&h|-a2@ie z-2DRyJOg+E@I)1ifGUuabSm%7GcL4`i`YV^0#i!3qyk&+{E13Dl3eO3;DcB6fD_3b z#WVg=KrP>nU_k;KDzPQ_hG26cwnyc<_xCR z|6UKYUSbLL4ac?KJj;mnz#45AfkqZ6B&nDi4i2;XZPw#(QvG6Ok`EJ!l;2Px62F%?ncrA)PrToTLJlFZz= z99t7Mff~*Lj$bTF3-9bl5%5W<0_T5SmPaG*hBv*KL?bV!H@lieSKN-j<#Kv8z|ij# XeS}(9KIvJ?00000NkvXXu0mjfH9%j& diff --git a/modules/core_scripts/util.lua b/modules/core_scripts/util.lua index cd65806e..b7173229 100644 --- a/modules/core_scripts/util.lua +++ b/modules/core_scripts/util.lua @@ -55,3 +55,17 @@ function resolveFileFullPath(filePath, depth) return filePath end end + +function extends(base) + local derived = {} + function derived.internalCreate() + local instance = base.create() + for k,v in pairs(derived) do + instance[k] = v + end + return instance + end + derived.create = derived.internalCreate + return derived +end + diff --git a/modules/core_styles/core_styles.otmod b/modules/core_styles/core_styles.otmod index cdf885e1..1a1b372c 100644 --- a/modules/core_styles/core_styles.otmod +++ b/modules/core_styles/core_styles.otmod @@ -15,4 +15,5 @@ Module importStyles 'styles/listboxes.otui' importStyles 'styles/items.otui' importStyles 'styles/creatures.otui' + importStyles 'styles/comboboxes.otui' return true diff --git a/modules/core_styles/images/combobox.png b/modules/core_styles/images/combobox.png new file mode 100644 index 0000000000000000000000000000000000000000..068d7ed906eebcdf8f69777d7268222f43096af3 GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^kw7fM!3HFsot-EPq!^2X+?^QKos)S996*@0SdC0c>21s-{uiz6_h{6@ZcR#NH#MhqQp5r zH#aq}1juDza4t$sEJ;mKD9TWe18^dAc};L>zv5VgX`=leP zE&|qt{~dF3?>KF_z`CcQBK&9EOoy(1fk{j9X6OZGY*l%>%=ORiRalXEFBY-lX);Q}BMQVC@)v07y)4aOAVGa(KqYZq&&0X@7i;-2VS5 Z<;?eld8f?g{Pq~+JWp3Ymvv4FO#sKRVdDS* literal 0 HcmV?d00001 diff --git a/modules/core_styles/styles/comboboxes.otui b/modules/core_styles/styles/comboboxes.otui new file mode 100644 index 00000000..1e709ebf --- /dev/null +++ b/modules/core_styles/styles/comboboxes.otui @@ -0,0 +1,9 @@ +ComboBox < UIComboBox + font: verdana-11px-antialised + color: #aaaaaa + size: 86 20 + text-margin: 3 + border-image: + source: /core_styles/images/combobox.png + border: 1 + border.right: 17 diff --git a/modules/core_widgets/core_widgets.otmod b/modules/core_widgets/core_widgets.otmod index 6b228a62..9cb08d05 100644 --- a/modules/core_widgets/core_widgets.otmod +++ b/modules/core_widgets/core_widgets.otmod @@ -7,4 +7,5 @@ Module onLoad: | require 'tooltip/tooltip' require 'messagebox/messagebox' + require 'uicombobox/uicombobox' return true \ No newline at end of file diff --git a/modules/core_widgets/uicombobox/uicombobox.lua b/modules/core_widgets/uicombobox/uicombobox.lua new file mode 100644 index 00000000..613c15bc --- /dev/null +++ b/modules/core_widgets/uicombobox/uicombobox.lua @@ -0,0 +1 @@ +UIComboBox = extends(UIWidget) diff --git a/modules/game_shaders/map.frag b/modules/game_shaders/map.frag new file mode 100644 index 00000000..f407109c --- /dev/null +++ b/modules/game_shaders/map.frag @@ -0,0 +1,10 @@ +uniform float opacity; // painter opacity +uniform vec4 color; // painter color +uniform float time; // time in seconds since shader linkage +uniform sampler2D texture; // map texture +varying vec2 textureCoords; // map texture coords + +void main() +{ + gl_FragColor = texture2D(texture, textureCoords) * color * opacity; +} diff --git a/modules/outfit.frag b/modules/game_shaders/outfit.frag similarity index 87% rename from modules/outfit.frag rename to modules/game_shaders/outfit.frag index f8d156d4..214d9089 100644 --- a/modules/outfit.frag +++ b/modules/game_shaders/outfit.frag @@ -1,6 +1,6 @@ -uniform float opacity; -uniform vec4 color; -uniform float ticks; +uniform float opacity; // painter opacity +uniform vec4 color; // painter color +uniform float time; // time in seconds since shader linkage uniform sampler2D texture; // outfit texture varying vec2 textureCoords; // outfit texture coords @@ -38,3 +38,4 @@ void main() { gl_FragColor = calcOutfitPixel() * color * opacity; } + diff --git a/modules/particle.otpa b/modules/particle.otpa deleted file mode 100644 index 9c537642..00000000 --- a/modules/particle.otpa +++ /dev/null @@ -1,102 +0,0 @@ -ParticleSystem - - AttractionAffector - position: 320 180 - acceleration: 500 - repelish: true - delay: 0.5 - - // Fire - Emitter - position: 295 180 - duration: 0.5 - burstRate: 0.0166 - burstCount: 3 - delay: 0 - - particle-min-duration: 0.3 - particle-max-duration: 0.5 - - particle-position-radius: 0 - - particle-min-velocity: 200 - particle-max-velocity: 240 - particle-min-velocity-angle: -10 - particle-max-velocity-angle: 10 - - particle-acceleration: 0 - - particle-start-size: 16 16 - particle-final-size: 64 64 - - particle-colors: #ffcc0050 #ffff0025 #ff000000 - particle-colors-stops: 0 0.15 0.3 - - particle-composition-mode: addition - particle-texture: circle2.png - - - // Fire ball - Emitter - position: 295 180 - duration: 0 - burstRate: 0.0166 - burstCount: 3 - delay: 0 - - particle-min-duration: 0.5 - particle-max-duration: 0.9 - - particle-position-radius: 0 - - particle-min-velocity: 80 - particle-max-velocity: 110 - particle-min-velocity-angle: -30 - particle-max-velocity-angle: 30 - - particle-acceleration: 0 - - particle-start-size: 16 16 - particle-final-size: 32 32 - - particle-composition-mode: addition - particle-colors: #19191980 #0f0f0f80 #00000000 - particle-colors-stops: 0 0.45 0.9 - - particle-texture: circle2.png - -ParticleSystem - - AttractionAffector - position: 320 180 - acceleration: 30 - repelish: true - - // Smoke - Emitter - position: 295 180 - duration: 0.7 - burstRate: 0.0166 - burstCount: 3 - delay: 0.4 - - particle-min-duration: 0.9 - particle-max-duration: 0.9 - - particle-position-radius: 0 - - particle-min-velocity: 60 - particle-max-velocity: 85 - particle-min-velocity-angle: -20 - particle-max-velocity-angle: 20 - - particle-acceleration: 0 - - particle-start-size: 8 8 - particle-final-size: 64 64 - - particle-colors: #66666610 #00000000 - particle-colors-stops: 0 0.9 - - particle-texture: circle2.png - diff --git a/modules/shadertest.frag b/modules/shadertest.frag deleted file mode 100644 index 210d1b34..00000000 --- a/modules/shadertest.frag +++ /dev/null @@ -1,123 +0,0 @@ -varying vec2 textureCoords; -uniform float opacity; -uniform vec4 color; -uniform float ticks; -uniform sampler2D texture; - -void main() -{ - gl_FragColor = texture2D(texture, textureCoords) * color * opacity; -} - -/* -varying vec2 textureCoords; -uniform vec4 color; -uniform float ticks; -uniform sampler2D texture; - -void main() -{ - int num = 4; - vec4 sum = vec4(0); - int i, j; - for(i=-num/2;i& args, int appFlags) // fire first resize resize(g_window.getSize()); - } - // finally show the window - if(m_appFlags & Fw::AppEnableGraphics) - g_window.show(); + // display window when the application starts running + g_dispatcher.addEvent([]{ g_window.show(); }); + } if(m_appFlags & Fw::AppEnableModules) g_modules.discoverModulesPath(); diff --git a/src/framework/core/clock.h b/src/framework/core/clock.h index 72f68330..39c2a747 100644 --- a/src/framework/core/clock.h +++ b/src/framework/core/clock.h @@ -48,20 +48,5 @@ private: extern Clock g_clock; -class Timer -{ -public: - Timer() { restart(); } - - void restart() { m_startTicks = g_clock.ticks(); } - - ticks_t startTicks() { return m_startTicks; } - ticks_t ticksElapsed() { return g_clock.ticks() - m_startTicks; } - double timeElapsed() { return ticksElapsed()/1000.0; } - -private: - ticks_t m_startTicks; -}; - #endif diff --git a/src/framework/core/eventdispatcher.cpp b/src/framework/core/eventdispatcher.cpp index a2692113..f7940710 100644 --- a/src/framework/core/eventdispatcher.cpp +++ b/src/framework/core/eventdispatcher.cpp @@ -30,7 +30,6 @@ void EventDispatcher::flush() { poll(); - m_eventList.clear(); while(!m_scheduledEventList.empty()) m_scheduledEventList.pop(); } diff --git a/src/framework/core/logger.cpp b/src/framework/core/logger.cpp index f4e636d6..7149ae9e 100644 --- a/src/framework/core/logger.cpp +++ b/src/framework/core/logger.cpp @@ -25,7 +25,7 @@ Logger g_logger; -Logger::Logger() : m_terminated(false) +Logger::Logger() { } diff --git a/src/framework/core/logger.h b/src/framework/core/logger.h index 45d4dc72..b1360325 100644 --- a/src/framework/core/logger.h +++ b/src/framework/core/logger.h @@ -48,7 +48,6 @@ public: private: std::list m_logMessages; OnLogCallback m_onLog; - bool m_terminated; }; extern Logger g_logger; diff --git a/src/framework/core/module.cpp b/src/framework/core/module.cpp index ea2361ae..843135a3 100644 --- a/src/framework/core/module.cpp +++ b/src/framework/core/module.cpp @@ -48,14 +48,14 @@ void Module::discover(const OTMLNodePtr& moduleNode) // set onLoad callback if(OTMLNodePtr node = moduleNode->get("onLoad")) { - g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]"); + g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]"); g_lua.useValue(); m_loadCallback = g_lua.polymorphicPop(); } // set onUnload callback if(OTMLNodePtr node = moduleNode->get("onUnload")) { - g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]"); + g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]"); g_lua.useValue(); m_unloadCallback = g_lua.polymorphicPop(); } diff --git a/src/framework/core/timer.cpp b/src/framework/core/timer.cpp new file mode 100644 index 00000000..e23cf516 --- /dev/null +++ b/src/framework/core/timer.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2010-2011 OTClient + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#include "timer.h" +#include "clock.h" + +void Timer::restart() +{ + m_startTicks = g_clock.ticks(); +} + +ticks_t Timer::ticksElapsed() +{ + return g_clock.ticks() - m_startTicks; +} diff --git a/src/framework/core/timer.h b/src/framework/core/timer.h new file mode 100644 index 00000000..d743a132 --- /dev/null +++ b/src/framework/core/timer.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2010-2011 OTClient + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef TIMER_H +#define TIMER_H + +#include + +class Timer +{ +public: + Timer() { restart(); } + + void restart(); + + ticks_t startTicks() { return m_startTicks; } + ticks_t ticksElapsed(); + double timeElapsed() { return ticksElapsed()/1000.0; } + +private: + ticks_t m_startTicks; +}; + +#endif diff --git a/src/framework/graphics/hardwarebuffer.cpp b/src/framework/graphics/hardwarebuffer.cpp new file mode 100644 index 00000000..e3ef9d11 --- /dev/null +++ b/src/framework/graphics/hardwarebuffer.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2010-2011 OTClient + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#include "hardwarebuffer.h" + diff --git a/src/framework/graphics/hardwarebuffer.h b/src/framework/graphics/hardwarebuffer.h new file mode 100644 index 00000000..1cdd2481 --- /dev/null +++ b/src/framework/graphics/hardwarebuffer.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2010-2011 OTClient + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#ifndef HARDWAREBUFFER_H +#define HARDWAREBUFFER_H + +class HardwareBuffer +{ +}; + +#endif diff --git a/src/framework/graphics/paintershaderprogram.cpp b/src/framework/graphics/paintershaderprogram.cpp index 5f9f498c..fbc91982 100644 --- a/src/framework/graphics/paintershaderprogram.cpp +++ b/src/framework/graphics/paintershaderprogram.cpp @@ -36,9 +36,10 @@ bool PainterShaderProgram::link() bindUniformLocation(COLOR_UNIFORM, "color"); bindUniformLocation(OPACITY_UNIFORM, "opacity"); bindUniformLocation(TEXTURE_UNIFORM, "texture"); - bindUniformLocation(TICKS_UNIFORM, "ticks"); + bindUniformLocation(TIME_UNIFORM, "ticks"); return true; } + m_startTimer.restart(); return false; } @@ -62,10 +63,11 @@ void PainterShaderProgram::setOpacity(float opacity) void PainterShaderProgram::setUniformTexture(int location, const TexturePtr& texture, int index) { - if(!texture) - return; - glActiveTexture(GL_TEXTURE0 + index); - glBindTexture(GL_TEXTURE_2D, texture->getId()); + if(index > 0) + glActiveTexture(GL_TEXTURE0 + index); + glBindTexture(GL_TEXTURE_2D, texture ? texture->getId() : 0); + if(index > 0) + glActiveTexture(GL_TEXTURE0); setUniformValue(location, index); } @@ -90,7 +92,7 @@ void PainterShaderProgram::draw(const CoordsBuffer& coordsBuffer, DrawMode drawM { assert(bind()); - setUniformValue(TICKS_UNIFORM, (float)g_clock.ticks()); + setUniformValue(TIME_UNIFORM, (float)m_startTimer.timeElapsed()); int numVertices = coordsBuffer.getVertexCount(); if(numVertices == 0) diff --git a/src/framework/graphics/paintershaderprogram.h b/src/framework/graphics/paintershaderprogram.h index 5cb77714..3480d169 100644 --- a/src/framework/graphics/paintershaderprogram.h +++ b/src/framework/graphics/paintershaderprogram.h @@ -25,6 +25,7 @@ #include "shaderprogram.h" #include "coordsbuffer.h" +#include class PainterShaderProgram : public ShaderProgram { @@ -36,7 +37,7 @@ class PainterShaderProgram : public ShaderProgram COLOR_UNIFORM = 2, OPACITY_UNIFORM = 3, TEXTURE_UNIFORM = 4, - TICKS_UNIFORM = 5 + TIME_UNIFORM = 5 }; public: enum DrawMode { @@ -55,6 +56,7 @@ public: private: DrawMode m_drawMode; + Timer m_startTimer; }; #endif diff --git a/src/framework/platform/x11window.cpp b/src/framework/platform/x11window.cpp index 5a786df6..467a3da1 100644 --- a/src/framework/platform/x11window.cpp +++ b/src/framework/platform/x11window.cpp @@ -427,7 +427,12 @@ bool X11Window::isExtensionSupported(const char *ext) void X11Window::move(const Point& pos) { + bool wasVisible = isVisible(); + if(!wasVisible) + show(); XMoveWindow(m_display, m_window, pos.x, pos.y); + if(!wasVisible) + hide(); } void X11Window::resize(const Size& size) diff --git a/src/framework/util/tools.h b/src/framework/util/tools.h index 8f579303..3289edf8 100644 --- a/src/framework/util/tools.h +++ b/src/framework/util/tools.h @@ -299,4 +299,6 @@ inline float randomRange(float min, float max) { // shortcut for Fw::dump const static Fw::dumper dump; +#define forever for(;;) + #endif diff --git a/src/otclient/core/creature.cpp b/src/otclient/core/creature.cpp index c434fad0..8a7fbca1 100644 --- a/src/otclient/core/creature.cpp +++ b/src/otclient/core/creature.cpp @@ -67,7 +67,7 @@ void Creature::draw(const Point& p) if(!outfitProgram) { outfitProgram = PainterShaderProgramPtr(new PainterShaderProgram); outfitProgram->addShaderFromSourceCode(Shader::Vertex, glslMainWithTexCoordsVertexShader + glslPositionOnlyVertexShader); - outfitProgram->addShaderFromSourceFile(Shader::Fragment, "/outfit.frag"); + outfitProgram->addShaderFromSourceFile(Shader::Fragment, "/game_shaders/outfit.frag"); assert(outfitProgram->link()); outfitProgram->bindUniformLocation(HEAD_COLOR_UNIFORM, "headColor"); outfitProgram->bindUniformLocation(BODY_COLOR_UNIFORM, "bodyColor"); @@ -93,6 +93,13 @@ void Creature::draw(const Point& p) for(int h = 0; h < m_type->dimensions[ThingType::Height]; h++) { for(int w = 0; w < m_type->dimensions[ThingType::Width]; w++) { + int spriteId = m_type->getSpriteId(w, h, 0, m_xPattern, m_yPattern, m_zPattern, m_animation); + if(!spriteId) + continue; + TexturePtr spriteTex = g_sprites.getSpriteTexture(spriteId); + if(!spriteTex) + continue; + if(m_type->dimensions[ThingType::Layers] > 1) { int maskId = m_type->getSpriteId(w, h, 1, m_xPattern, m_yPattern, m_zPattern, m_animation); if(!maskId) @@ -101,12 +108,6 @@ void Creature::draw(const Point& p) outfitProgram->setUniformTexture(MASK_TEXTURE_UNIFORM, maskTex, 1); } - int spriteId = m_type->getSpriteId(w, h, 0, m_xPattern, m_yPattern, m_zPattern, m_animation); - if(!spriteId) - continue; - - TexturePtr spriteTex = g_sprites.getSpriteTexture(spriteId); - Rect drawRect(((p + m_walkOffset).x - w*32) - m_type->parameters[ThingType::DisplacementX], ((p + m_walkOffset).y - h*32) - m_type->parameters[ThingType::DisplacementY], 32, 32); diff --git a/src/otclient/core/gameshadermanager.cpp b/src/otclient/core/gameshadermanager.cpp new file mode 100644 index 00000000..1345f29a --- /dev/null +++ b/src/otclient/core/gameshadermanager.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2010-2011 OTClient + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "gameshadermanager.h" + diff --git a/src/otclient/core/gameshadermanager.h b/src/otclient/core/gameshadermanager.h new file mode 100644 index 00000000..8618ef62 --- /dev/null +++ b/src/otclient/core/gameshadermanager.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010-2011 OTClient + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef GAMESHADERMANAGER_H +#define GAMESHADERMANAGER_H + +class GameShaderManager +{ +}; + +#endif diff --git a/src/otclient/core/map.cpp b/src/otclient/core/map.cpp index 0dcaa7d8..52538a14 100644 --- a/src/otclient/core/map.cpp +++ b/src/otclient/core/map.cpp @@ -48,7 +48,7 @@ void Map::draw(const Rect& rect) program = PainterShaderProgramPtr(new PainterShaderProgram); program->addShaderFromSourceCode(Shader::Vertex, glslMainWithTexCoordsVertexShader + glslPositionOnlyVertexShader); - program->addShaderFromSourceFile(Shader::Fragment, "/shadertest.frag"); + program->addShaderFromSourceFile(Shader::Fragment, "/game_shaders/map.frag"); assert(program->link()); }