From: <cn...@us...> - 2010-04-05 06:12:42
|
Revision: 688 http://hgengine.svn.sourceforge.net/hgengine/?rev=688&view=rev Author: cnlohr Date: 2010-04-05 06:12:33 +0000 (Mon, 05 Apr 2010) Log Message: ----------- Tweak to allow detection of actual mouse-motion commands, as to prevent confusing the rest of the system. Modified Paths: -------------- Mercury2/modules/Cu2.cpp Mercury2/src/MercuryInput.cpp Mercury2/src/MercuryInput.h Mercury2/src/X11Window.cpp Modified: Mercury2/modules/Cu2.cpp =================================================================== --- Mercury2/modules/Cu2.cpp 2010-03-29 18:38:45 UTC (rev 687) +++ Mercury2/modules/Cu2.cpp 2010-04-05 06:12:33 UTC (rev 688) @@ -59,7 +59,7 @@ m_bWasMouseInThisFrame = bIsInside; - for( unsigned button = 0; button < 8; button++ ) + for( unsigned button = 0; button < 3; button++ ) { unsigned char Mask = 1<<button; bool bWasDown = iLastButtonMask & Mask; Modified: Mercury2/src/MercuryInput.cpp =================================================================== --- Mercury2/src/MercuryInput.cpp 2010-03-29 18:38:45 UTC (rev 687) +++ Mercury2/src/MercuryInput.cpp 2010-04-05 06:12:33 UTC (rev 688) @@ -11,7 +11,7 @@ buttons.data = 0; } -void MouseInput::ProcessMouseInput(int dx, int dy, bool leftButton, bool rightButton, bool centerButton, bool scrollUpButton, bool scrollDownButton) +void MouseInput::ProcessMouseInput(int dx, int dy, bool leftButton, bool rightButton, bool centerButton, bool scrollUpButton, bool scrollDownButton, bool bMotionEvent ) { MouseInput* mi = new MouseInput(); mi->dx = dx; @@ -23,6 +23,7 @@ buttons.scrollup = scrollUpButton; buttons.scrolldown = scrollDownButton; mi->buttons = buttons; + mi->buttons.motion = bMotionEvent; currentButtonMasks = buttons; GlobalMouseX_Set.Set( dx ); Modified: Mercury2/src/MercuryInput.h =================================================================== --- Mercury2/src/MercuryInput.h 2010-03-29 18:38:45 UTC (rev 687) +++ Mercury2/src/MercuryInput.h 2010-04-05 06:12:33 UTC (rev 688) @@ -19,14 +19,15 @@ unsigned int center: 1; unsigned int scrollup: 1; unsigned int scrolldown: 1; + unsigned int motion : 1; //if 1, don't expect other button info, it's a mouse-motion event. }; } buttonMask; - static void ProcessMouseInput(int dx, int dy, bool leftButton, bool rightButton, bool centerButton, bool scrollUpButton, bool scrollDownButton); + static void ProcessMouseInput(int dx, int dy, bool leftButton, bool rightButton, bool centerButton, bool scrollUpButton, bool scrollDownButton, bool motionevent); MouseInput(); int32_t dx, dy; buttonMask buttons; - + private: static buttonMask currentButtonMasks; }; Modified: Mercury2/src/X11Window.cpp =================================================================== --- Mercury2/src/X11Window.cpp 2010-03-29 18:38:45 UTC (rev 687) +++ Mercury2/src/X11Window.cpp 2010-04-05 06:12:33 UTC (rev 688) @@ -289,7 +289,7 @@ sd = ((e->state & X11_MASK(MOUSE_BTN_SCROLL_DOWN))!=0) ^ (e->button == MOUSE_BTN_SCROLL_DOWN); MouseInput::ProcessMouseInput(m_iLastMouseX, m_iLastMouseY , - left, right, center, su, sd); + left, right, center, su, sd, false); break; } case KeyPress: @@ -327,7 +327,7 @@ { m_iLastMouseX = x; m_iLastMouseY = y; - MouseInput::ProcessMouseInput(x, y, left, right, center, su, sd); + MouseInput::ProcessMouseInput(x, y, left, right, center, su, sd, true); XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2); } } @@ -335,7 +335,7 @@ { m_iLastMouseX = e->x; m_iLastMouseY = e->y; - MouseInput::ProcessMouseInput(e->x, e->y, left, right, center, su, sd); + MouseInput::ProcessMouseInput(e->x, e->y, left, right, center, su, sd, true); } break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2010-04-25 02:50:19
|
Revision: 694 http://hgengine.svn.sourceforge.net/hgengine/?rev=694&view=rev Author: cnlohr Date: 2010-04-25 02:50:12 +0000 (Sun, 25 Apr 2010) Log Message: ----------- commit dabbling with Wii... it may go somewhere... Modified Paths: -------------- Mercury2/base_set.sh Mercury2/cnconfigure Mercury2/src/Mercury2.cpp Mercury2/src/MercuryCrash.c Added Paths: ----------- Mercury2/tools/wii_libs/ Mercury2/tools/wii_libs/Makefile Mercury2/tools/wii_libs/Makefile.png Mercury2/tools/wii_libs/Makefile.zlib Modified: Mercury2/base_set.sh =================================================================== --- Mercury2/base_set.sh 2010-04-22 00:01:37 UTC (rev 693) +++ Mercury2/base_set.sh 2010-04-25 02:50:12 UTC (rev 694) @@ -8,7 +8,7 @@ ISMAC=1; fi -OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg" +OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg wii" OPT_X11=1 OPT_OGL=1 OPT_libxml=1 @@ -18,6 +18,7 @@ OPT_instancewatch=1 OPT_alsa=1 OPT_ogg=1 +OPT_wii=0 DEFINES="WAS_CONFIGURED USE_MSTRING" @@ -52,9 +53,17 @@ WANT_L="iberty" CC_BASE="$CC_BASE -I." -NEED_L="m c z pthread png pthread"; +if test $OPT_wii = 1; then + CC="$DEVKITPPC/bin/powerpc-eabi-g++" + EXTRA_BEGIN="include $DEVKITPPC/wii_rules" + LD_BASE="$LD_BASE -g $MACHDEP -Ltools/wii_png -Wl,-Map,mercury.map $DEVKITPRO/libogc/lib/wii/libwiiuse.a $DEVKITPRO/libogc/lib/wii/libbte.a $DEVKITPRO/libogc/lib/wii/libogc.a" + NEED_L="m c png" + CC_BASE="$CC_BASE -I$DEVKITPRO/libogc/include" +else + NEED_L="m c z pthread png pthread"; + CC="cc" +fi - if test $OPT_libxml = 1; then CC_BASE="$CC_BASE -I/usr/include/libxml2" NEED_H="$NEED_H libxml/parser.h" @@ -110,10 +119,14 @@ ARCH=`uname -m` -if test $ARCH = "i686" || test $ARCH = "i586"; then - if test $OPT_sse = 1; then - CC_BASE="$CC_BASE -march=pentium3" - else - CC_BASE="$CC_BASE -march=pentium" +if test $OPT_wii = 1; then + CC_BASE="$CC_BASE -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float" +else + if test $ARCH = "i686" || test $ARCH = "i586"; then + if test $OPT_sse = 1; then + CC_BASE="$CC_BASE -march=pentium3" + else + CC_BASE="$CC_BASE -march=pentium" + fi fi fi Modified: Mercury2/cnconfigure =================================================================== --- Mercury2/cnconfigure 2010-04-22 00:01:37 UTC (rev 693) +++ Mercury2/cnconfigure 2010-04-25 02:50:12 UTC (rev 694) @@ -11,8 +11,8 @@ { echo -n "Checking for <$1>... " echo -e "#include <$1>\n" > tmp.c -#echo gcc $CC_BASE -E tmp.c -if gcc $CC_BASE -E tmp.c 1> foo 2> foo; then +#echo ${CC} $CC_BASE -E tmp.c +if $CC $CC_BASE -E tmp.c 1> foo 2> foo; then # rm ./tmp.c rm ./foo echo "yes" @@ -29,8 +29,8 @@ { echo -n "Checking for -l$1... " echo -e "int main() { return 0; }" > tmp.c -#echo gcc $CC_BASE $LD_BASE -o bar tmp.c -l$1 -if gcc $CC_BASE $LD_BASE -o bar tmp.c -l$1 1> foo 2> foo; then +#echo $CC $CC_BASE $LD_BASE -o bar tmp.c -l$1 +if $CC $CC_BASE $LD_BASE -o bar tmp.c -l$1 1> foo 2> foo; then rm ./tmp.c rm ./foo rm ./bar @@ -58,11 +58,11 @@ echo "#define $i" >> configuration.h done -echo "Compile line used: cc $CC_BASE" +echo "Compile line used: $CC $CC_BASE" echo -n "Checking to make sure standard cflags and compile are acceptable... " echo -e "\n" > tmp.c -if cc $CC_BASE -E tmp.c 1> foo 2> foo; then +if $CC $CC_BASE -E tmp.c 1> foo 2> foo; then rm ./foo echo "yes" else @@ -71,10 +71,10 @@ exit -1 fi -echo "Link line used: g++ $CC_BASE $LD_BASE" +echo "Link line used: $CC $CC_BASE $LD_BASE" echo -n "Checking to make sure ldflags and cflags are acceptable... " echo -e "int main() { return 0; }" > tmp.c -if g++ $CC_BASE $LD_BASE -o bar tmp.c 1> foo 2> foo; then +if $CC $CC_BASE $LD_BASE -o bar tmp.c 1> foo 2> foo; then rm ./tmp.c rm ./foo rm ./bar @@ -128,7 +128,7 @@ return 0; }\n" > tmp.c -if gcc -o tmp.o tmp.c; then +if cc -o tmp.o tmp.c; then echo -n "Compile OK. " rm ./tmp.c else @@ -170,6 +170,9 @@ echo "" > Makefile +#if we need extra beginning parameters, tack them in here +echo $EXTRA_BEGIN >> Makefile + echo -n "SOURCES=" >> Makefile for i in $SOURCES; do echo -n "$i " >> Makefile @@ -184,16 +187,17 @@ LDFLAGS="$LDFLAGS $LD_BASE" -echo "Final compile line: cc ${CC_BASE} ${CFLAGS} -c -o \$@ \$<" +echo "Final compile line: ${CC} ${CC_BASE} ${CFLAGS} -c -o \$@ \$<" echo "Final link line: g++ -o \$@ \$^ ${LDFLAGS}" echo "PROJ=$PROJ" >> Makefile +echo "CC=$CC" >> Makefile echo "CFLAGS=$CC_BASE $CFLAGS" >> Makefile echo "LDFLAGS=$LDFLAGS" >> Makefile echo "">>Makefile echo -e "all : \$(PROJ) library allmodules" >> Makefile echo -e "\$(PROJ) : \$(OBJ)" >> Makefile -echo -e "\tg++ -o \$@ \$^ \$(LDFLAGS)" >> Makefile +echo -e "\t${cc} -o \$@ \$^ \$(LDFLAGS)" >> Makefile echo -e "help : " >> Makefile echo -e " echo \"Available: <\$(PROJ)> <clean> <library> <help>\"" >> Makefile if test `uname -s` == "Darwin" ; then @@ -208,7 +212,7 @@ echo "" >> Makefile for i in $SOURCES; do echo "Processing: $i" - cc $CC_BASE $CFLAGS -MM "$i" -MT $( echo "$i" | sed "s/\.S/\.o/g;s/\.cpp/\.o/g;s/\.c/\.o/g" ) >> Makefile + ${CC} $CC_BASE $CFLAGS -MM "$i" -MT $( echo "$i" | sed "s/\.S/\.o/g;s/\.cpp/\.o/g;s/\.c/\.o/g" ) >> Makefile #FIX THIS!!!! It should be don at make time, not here. echo -e "\t\$(CC) \$(CC_BASE) \$(CFLAGS) -c -o \$@ \$<" >> Makefile echo "" >> Makefile Modified: Mercury2/src/Mercury2.cpp =================================================================== --- Mercury2/src/Mercury2.cpp 2010-04-22 00:01:37 UTC (rev 693) +++ Mercury2/src/Mercury2.cpp 2010-04-25 02:50:12 UTC (rev 694) @@ -15,7 +15,9 @@ #include <MercuryTimer.h> #include <RenderGraph.h> #include <Texture.h> +#ifdef _HAVE_LIB_GL #include <GLHeaders.h> +#endif #include <ModuleManager.h> #include <MercuryFile.h> @@ -200,8 +202,10 @@ //uncomment the next 2 lines to use threads // UpdateLoopGo.Increment(); // updateThread.Wait(); - + +#ifdef _HAVE_LIB_GL PrintGLFunctionCalls(); +#endif SAFE_DELETE(root); SAFE_DELETE(w); Modified: Mercury2/src/MercuryCrash.c =================================================================== --- Mercury2/src/MercuryCrash.c 2010-04-22 00:01:37 UTC (rev 693) +++ Mercury2/src/MercuryCrash.c 2010-04-25 02:50:12 UTC (rev 694) @@ -21,7 +21,7 @@ #ifndef __USE_POSIX #define __USE_POSIX #include <signal.h> -#undef__USE_POSIX +#undef __USE_POSIX #else #include <signal.h> #endif Added: Mercury2/tools/wii_libs/Makefile =================================================================== --- Mercury2/tools/wii_libs/Makefile (rev 0) +++ Mercury2/tools/wii_libs/Makefile 2010-04-25 02:50:12 UTC (rev 694) @@ -0,0 +1,38 @@ +include $(DEVKITPPC)/wii_rules + +all : libpng.a libz.a + +PNG_TGZ:=libpng-1.4.1.tar.gz +PNG_FOLDER:=libpng-1.4.1 + +Z_TGZ:=zlib-1.2.4.tar.gz +Z_FOLDER:=zlib-1.2.4 + +$(PNG_TGZ) : + wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.4.1.tar.gz + +$(PNG_FOLDER) : $(PNG_TGZ) + tar xzvf $(PNG_TGZ) + +libpng.a : $(PNG_FOLDER) libz.a + (cd $(PNG_FOLDER)&&make -f../Makefile.png&&cd ..) + cp $(PNG_FOLDER)/libpng.a . + +$(Z_TGZ) : + wget http://zlib.net/zlib-1.2.4.tar.gz + +$(Z_FOLDER) : $(Z_TGZ) + tar xzvf $(Z_TGZ) + +libz.a : $(Z_FOLDER) + (cd $(Z_FOLDER)&&make -f../Makefile.zlib&&cd ..) + cp $(Z_FOLDER)/libz.a . + +clobber : clean + rm -rf $(PNG_TGZ) $(PNG_FOLDER) $(Z_TGZ) $(Z_FOLDER) + +clean : + rm -rf *~ libz.a libpng.a + (cd $(Z_FOLDER)&&make -f../Makefile.zlib clean&&cd ..) + (cd $(PNG_FOLDER)&&make -f../Makefile.png clean&&cd ..) + Added: Mercury2/tools/wii_libs/Makefile.png =================================================================== --- Mercury2/tools/wii_libs/Makefile.png (rev 0) +++ Mercury2/tools/wii_libs/Makefile.png 2010-04-25 02:50:12 UTC (rev 694) @@ -0,0 +1,17 @@ +all : libpng.a minitest + +OBJS:=png.o pngerror.o pngget.o pngpread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o +SRCS:=png.c pngerror.c pngget.c pngpread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c + +libpng.a : $(OBJS) + $(DEVKITPPC)/bin/powerpc-eabi-ar rcs $@ $^ + +%.o : %.c + $(DEVKITPPC)/bin/powerpc-eabi-gcc -I../zlib-1.2.4 -O2 -c -o $@ $^ + +minitest : libpng.a + $(DEVKITPPC)/bin/powerpc-eabi-gcc -I../zlib-1.2.4 -O2 -c example.c -c -o example.o + $(DEVKITPPC)/bin/powerpc-eabi-gcc example.o -L. -L.. -lz -lpng + +clean : + rm -rf *~ *.o libz.a Added: Mercury2/tools/wii_libs/Makefile.zlib =================================================================== --- Mercury2/tools/wii_libs/Makefile.zlib (rev 0) +++ Mercury2/tools/wii_libs/Makefile.zlib 2010-04-25 02:50:12 UTC (rev 694) @@ -0,0 +1,17 @@ +all : libz.a minitest + +OBJS:=adler32.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inftrees.o inffast.o inflate.o trees.o uncompr.o zutil.o +SRCS:=adler32.c crc32.c deflate.c gzclose.c gzlib.c gzread.c gzwrite.c infback.c inftrees.c inffast.c inflate.c trees.c uncompr.c zutil.c + +libz.a : $(OBJS) + $(DEVKITPPC)/bin/powerpc-eabi-ar rcs $@ $^ + +%.o : %.c + $(DEVKITPPC)/bin/powerpc-eabi-gcc -O2 -c -o $@ $^ + +minitest : libz.a + $(DEVKITPPC)/bin/powerpc-eabi-gcc -O2 -c minigzip.c -c -o minigzip.o + $(DEVKITPPC)/bin/powerpc-eabi-gcc minigzip.o -L. -lz + +clean : + rm -rf *~ *.o libz.a This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2010-04-25 20:16:58
|
Revision: 699 http://hgengine.svn.sourceforge.net/hgengine/?rev=699&view=rev Author: cnlohr Date: 2010-04-25 20:16:49 +0000 (Sun, 25 Apr 2010) Log Message: ----------- Fix Mercury, Win32. Modified Paths: -------------- Mercury2/Mercury2.vcproj Mercury2/src/FullscreenQuad.cpp Mercury2/src/GLHelpers.cpp Mercury2/src/Mercury2.cpp Mercury2/src/MercuryAsset.cpp Mercury2/src/MercuryFBO.cpp Mercury2/src/MercurySound.h Mercury2/src/Win32Window.cpp Mercury2/src/Win32Window.h Modified: Mercury2/Mercury2.vcproj =================================================================== --- Mercury2/Mercury2.vcproj 2010-04-25 19:42:25 UTC (rev 698) +++ Mercury2/Mercury2.vcproj 2010-04-25 20:16:49 UTC (rev 699) @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="modules;.;src;src/include;src/include/png;src/include/zlib;src/DataStructures;src/DataTypes" - PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS" + PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS;_HAVE_LIB_GL" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -115,7 +115,7 @@ <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories=".;src;src/include;src/include/png;src/include/zlib" - PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS" + PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS;_HAVE_LIB_GL" RuntimeLibrary="0" UsePrecompiledHeader="0" WarningLevel="3" Modified: Mercury2/src/FullscreenQuad.cpp =================================================================== --- Mercury2/src/FullscreenQuad.cpp 2010-04-25 19:42:25 UTC (rev 698) +++ Mercury2/src/FullscreenQuad.cpp 2010-04-25 20:16:49 UTC (rev 699) @@ -7,7 +7,7 @@ : Quad( key, bInstanced ) { m_matrix = MercuryMatrix::Identity(); - m_matrix.Transotale(0,0,-1,0,0,0,2,2,0.01); + m_matrix.Transotale(0,0,-1,0,0,0,2,2,0.01f); // m_matrix.Scale(2,2,1); m_matrix.Transpose(); } Modified: Mercury2/src/GLHelpers.cpp =================================================================== --- Mercury2/src/GLHelpers.cpp 2010-04-25 19:42:25 UTC (rev 698) +++ Mercury2/src/GLHelpers.cpp 2010-04-25 20:16:49 UTC (rev 699) @@ -111,13 +111,13 @@ modelview, projection, viewport, &dox, &doy, &doz); - p = MercuryVertex( dox, doy, doz ); + p = MercuryVertex( (float)dox, (float)doy, (float)doz ); gluUnProject( winX, winY, 1, modelview, projection, viewport, &dox, &doy, &doz ); - r = MercuryVertex( dox, doy, doz ) - p; + r = MercuryVertex( (float)dox, (float)doy, (float)doz ) - p; r.NormalizeSelf(); Modified: Mercury2/src/Mercury2.cpp =================================================================== --- Mercury2/src/Mercury2.cpp 2010-04-25 19:42:25 UTC (rev 698) +++ Mercury2/src/Mercury2.cpp 2010-04-25 20:16:49 UTC (rev 699) @@ -15,9 +15,9 @@ #include <MercuryTimer.h> #include <RenderGraph.h> #include <Texture.h> -#ifdef _HAVE_LIB_GL +#ifdef _HAVE_LIB_GL #include <GLHeaders.h> -#endif +#endif #include <ModuleManager.h> #include <MercuryFile.h> @@ -202,10 +202,10 @@ //uncomment the next 2 lines to use threads // UpdateLoopGo.Increment(); // updateThread.Wait(); - + #ifdef _HAVE_LIB_GL PrintGLFunctionCalls(); -#endif +#endif SAFE_DELETE(root); SAFE_DELETE(w); Modified: Mercury2/src/MercuryAsset.cpp =================================================================== --- Mercury2/src/MercuryAsset.cpp 2010-04-25 19:42:25 UTC (rev 698) +++ Mercury2/src/MercuryAsset.cpp 2010-04-25 20:16:49 UTC (rev 699) @@ -55,7 +55,7 @@ void MercuryAsset::PreRender(const MercuryNode* node) { - uint32_t t = time(0); + uint32_t t = (uint32_t)time(0); if ( m_lastNewerCheck < t ) { m_lastNewerCheck = t; Modified: Mercury2/src/MercuryFBO.cpp =================================================================== --- Mercury2/src/MercuryFBO.cpp 2010-04-25 19:42:25 UTC (rev 698) +++ Mercury2/src/MercuryFBO.cpp 2010-04-25 20:16:49 UTC (rev 699) @@ -95,7 +95,7 @@ int h = MercuryWindow::GetCurrentWindow()->Height(); if ((m_width != w) || (m_height != h)) { - m_width = w; m_height = h; + m_width = (unsigned short) w; m_height = (unsigned short)h; for (uint8_t i = 0; i < m_numTextures; ++i) { MString n = ssprintf("%s_%d", m_name.c_str(), i); @@ -153,16 +153,16 @@ void MercuryFBO::LoadFromXML(const XMLNode& node) { if ( !node.Attribute("width").empty() ) - SetWidth( StrToInt(node.Attribute("width")) ); + SetWidth( (unsigned short) StrToInt(node.Attribute("width")) ); if ( !node.Attribute("height").empty() ) - SetHeight( StrToInt(node.Attribute("height")) ); + SetHeight( (unsigned short) StrToInt(node.Attribute("height")) ); if ( !node.Attribute("depth").empty() ) SetUseDepth( node.Attribute("depth") == "true"?true:false ); if ( !node.Attribute("tnum").empty() ) - SetNumTextures( StrToInt(node.Attribute("tnum")) ); + SetNumTextures( (unsigned char)StrToInt(node.Attribute("tnum")) ); if ( !node.Attribute("usescreensize").empty() ) m_useScreenSize = node.Attribute("usescreensize") == "true"?true:false; Modified: Mercury2/src/MercurySound.h =================================================================== --- Mercury2/src/MercurySound.h 2010-04-25 19:42:25 UTC (rev 698) +++ Mercury2/src/MercurySound.h 2010-04-25 20:16:49 UTC (rev 699) @@ -70,8 +70,8 @@ //Useful tools - inline float GetSecondsSinceLastFrame() { float tr = m_tLastTrip.Age(); return (tr>1.)?1.:tr; } - inline unsigned int SamplesSinceLastFrame() { float tr = m_tLastTrip.Age(); return (tr>1.)?fSPS:(tr*fSPS); } + inline float GetSecondsSinceLastFrame() { float tr = m_tLastTrip.Age(); return (tr>1.f)?1.f:tr; } + inline unsigned int SamplesSinceLastFrame() { float tr = m_tLastTrip.Age(); return (unsigned int)(tr>1.)?fSPS:(tr*fSPS); } //For registering and creation of new sound sources... MAutoPtr< MercurySoundSource > LoadSoundSource( const MString & sSourceType, MAutoPtr< MercurySoundSource > Chain = 0 ); Modified: Mercury2/src/Win32Window.cpp =================================================================== --- Mercury2/src/Win32Window.cpp 2010-04-25 19:42:25 UTC (rev 698) +++ Mercury2/src/Win32Window.cpp 2010-04-25 20:16:49 UTC (rev 699) @@ -2,7 +2,10 @@ //#include <Windowsx.h> #include <GLHeaders.h> #include <MercuryInput.h> +#include <MercuryMessageManager.h> +MVRefBool GlobalMouseGrabbed_Set( "Input.CursorGrabbed" ); + LRESULT CALLBACK WindowCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); //Window callback Callback0R< MercuryWindow* > MercuryWindow::genWindowClbk(Win32Window::GenWin32Window); //Register window generation callback bool ACTIVE = false; @@ -120,7 +123,11 @@ SetForegroundWindow(m_hwnd); // Slightly Higher Priority SetFocus(m_hwnd); // Sets Keyboard Focus To The Window - + //Resize windows so it's actually as big as we want, not minus borders.s + GetClientRect( m_hwnd, &rect ); + int diffx = m_width - rect.right; + int diffy = m_height - rect.bottom; + SetWindowPos( m_hwnd, HWND_TOP, 0, 0, diffx + m_width, diffy + m_height, 0 ); } void Win32Window::SetPixelType() @@ -191,17 +198,29 @@ bool Win32Window::PumpMessages() { + static int lastx, lasty; + static bool bWasCursorVisible; MSG message; if ( InFocus() != ACTIVE ) { m_inFocus = ACTIVE; ShowCursor(!m_inFocus); - PointerToCenter(); + if( GlobalMouseGrabbed_Set.Get() ) + { + RECT rect; + GetWindowRect(m_hwnd, &rect); + SetCursorPos( rect.left + m_width/2, rect.top + m_height/2 ); + } } while (PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) { + RECT rect; + GetClientRect( m_hwnd, &rect ); + m_width = rect.right; + m_height = rect.bottom; + if ( InFocus() ) { switch( message.message ) @@ -221,33 +240,74 @@ case WM_MOUSEMOVE: { POINT pos; + RECT rect; + GetWindowRect(m_hwnd, &rect); GetCursorPos(&pos); - if (pos.x!=m_cX || pos.y!=m_cY) //ignore the resets to center + ScreenToClient(m_hwnd, &pos ); + bool left = message.wParam&MK_LBUTTON; + bool right = message.wParam&MK_RBUTTON; + bool center = message.wParam&MK_MBUTTON; + bool su = 0; + bool sd = 0; + int px = pos.x;// - rect.left - borderx; + int py = pos.y;// - rect.top - bordery; + + if( GlobalMouseGrabbed_Set.Get() ) { - int dx = m_cX - pos.x; - int dy = m_cY - pos.y; - m_iLastMouseX += dx; - m_iLastMouseY += dy; - MouseInput::ProcessMouseInput(dx, dy, message.wParam&MK_LBUTTON, message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0); - PointerToCenter(); + int x, y; + x = m_width/2 - px; + y = m_height/2 - py; + if (x!=0 || y!=0) //prevent recursive XWarp + { + m_iLastMouseX = x; + m_iLastMouseY = y; + MouseInput::ProcessMouseInput(x, y, left, right, center, su, sd, true); + lastx = x; lasty = y; + + pos.x = m_width/2; + pos.y = m_height/2; + ClientToScreen(m_hwnd, &pos ); + SetCursorPos( pos.x, pos.y); + if( bWasCursorVisible ) + { + bWasCursorVisible = false; + ShowCursor( false ); + } + } } + else + { + m_iLastMouseX = px; + m_iLastMouseY = py; + lastx = px; lasty = py; + MouseInput::ProcessMouseInput(px, py, left, right, center, su, sd, true); + if( !bWasCursorVisible ) + { + ShowCursor( true ); + bWasCursorVisible = true; + } + } } break; case WM_LBUTTONDOWN: - break; case WM_LBUTTONUP: - break; case WM_RBUTTONDOWN: - break; case WM_RBUTTONUP: - break; case WM_MBUTTONDOWN: - break; case WM_MBUTTONUP: + MouseInput::ProcessMouseInput( lastx, lasty, message.wParam&MK_LBUTTON, + message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0, false); break; - case 0x020A: //Do nothing (at least now) It's a mouse wheel! + case 0x020A: //Not-too-well-documented mouse wheel. + { + short cx = short(message.wParam>>16); + MouseInput::ProcessMouseInput( lastx, lasty, message.wParam&MK_LBUTTON, + message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, (cx>0), (cx<0), false); + MouseInput::ProcessMouseInput( lastx, lasty, message.wParam&MK_LBUTTON, + message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0, false); break; } + } } TranslateMessage(&message); // Translate The Message DispatchMessage(&message); // Dispatch The Message @@ -272,15 +332,6 @@ return (c&65535) > 1; } -void Win32Window::PointerToCenter() -{ - RECT rect; - GetWindowRect(m_hwnd, &rect); - m_cX = rect.left+m_width/2; - m_cY = rect.top+m_height/2; - SetCursorPos(m_cX, m_cY); -} - short Win32Window::ConvertScancode( uint32_t scanin ) { // Specifies the scan code. The value depends on the OEM. Modified: Mercury2/src/Win32Window.h =================================================================== --- Mercury2/src/Win32Window.h 2010-04-25 19:42:25 UTC (rev 698) +++ Mercury2/src/Win32Window.h 2010-04-25 20:16:49 UTC (rev 699) @@ -28,8 +28,6 @@ void CreateRenderingContext(); void GenPixelType(); - void PointerToCenter(); - HWND m_hwnd; //window handle HDC m_hdc; //device handle PIXELFORMATDESCRIPTOR m_pfd; //pixel format descriptor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2010-06-02 04:49:29
|
Revision: 750 http://hgengine.svn.sourceforge.net/hgengine/?rev=750&view=rev Author: cnlohr Date: 2010-06-02 04:49:22 +0000 (Wed, 02 Jun 2010) Log Message: ----------- make Mercury compile under clang, still won't run Modified Paths: -------------- Mercury2/base_set.sh Mercury2/src/MercuryLog.cpp Mercury2/src/MercuryLog.h Mercury2/src/MercurySoundDriverALSA.cpp Mercury2/src/MercurySoundSourceVorbis.cpp Mercury2/src/XMLParser.cpp Modified: Mercury2/base_set.sh =================================================================== --- Mercury2/base_set.sh 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/base_set.sh 2010-06-02 04:49:22 UTC (rev 750) @@ -8,7 +8,7 @@ ISMAC=1; fi -OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg wii" +OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg wii clang" OPT_X11=1 OPT_OGL=1 OPT_libxml=1 @@ -19,6 +19,7 @@ OPT_alsa=1 OPT_ogg=1 OPT_wii=0 +OPT_clang=0 DEFINES="WAS_CONFIGURED USE_MSTRING" @@ -64,6 +65,10 @@ CC="cc" fi +if test $OPT_clang = 1; then + CC="clang" +fi + if test $OPT_libxml = 1; then CC_BASE="$CC_BASE -I/usr/include/libxml2" NEED_H="$NEED_H libxml/parser.h" Modified: Mercury2/src/MercuryLog.cpp =================================================================== --- Mercury2/src/MercuryLog.cpp 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/src/MercuryLog.cpp 2010-06-02 04:49:22 UTC (rev 750) @@ -7,7 +7,9 @@ void* MercuryLog::ThreadLoop(void* d) { + MercuryLog* log = static_cast<MercuryLog*>(d); + log->Open( "log.txt" ); while (true) { @@ -15,6 +17,7 @@ log->WriteQueue(); msleep(100); //10x/sec } + log->Close(); return 0; } @@ -34,12 +37,19 @@ void MercuryLog::Open(const MString& file) { - m_file.open(file.c_str()); + if( m_file ) + Close(); + + m_file = fopen( file.c_str(), "w" ); } void MercuryLog::Close() { - m_file.close(); + if( m_file ) + { + fclose( m_file ); + m_file = 0; + } } void MercuryLog::Write(const MString& message) @@ -74,11 +84,11 @@ for (i = m_outQueue.begin(); i != m_outQueue.end(); ++i) { const MString& m = *i; - cout << m << endl; - m_file << m << endl; + fprintf( m_file, "%s\n", m.c_str() ); + printf( "%s\n", m.c_str() ); } - m_file.flush(); + fflush( m_file ); m_outQueue.clear(); } @@ -89,7 +99,6 @@ if (!pl) { pl = new MercuryProgramLog; - pl->m_log.Open("log.txt"); } return *pl; } Modified: Mercury2/src/MercuryLog.h =================================================================== --- Mercury2/src/MercuryLog.h 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/src/MercuryLog.h 2010-06-02 04:49:22 UTC (rev 750) @@ -1,7 +1,6 @@ #ifndef MERCURYLOG_H #define MERCURYLOG_H -#include <fstream> #include <list> #include <MercuryString.h> #include <MercuryThreads.h> @@ -26,10 +25,10 @@ void CopyQueue(); void WriteQueue(); + FILE * m_file; std::list< MString > m_queue; std::list< MString > m_outQueue; - std::ofstream m_file; MercuryMutex m_mutex; MercuryThread m_thread; Modified: Mercury2/src/MercurySoundDriverALSA.cpp =================================================================== --- Mercury2/src/MercurySoundDriverALSA.cpp 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/src/MercurySoundDriverALSA.cpp 2010-06-02 04:49:22 UTC (rev 750) @@ -34,7 +34,7 @@ snd_pcm_sw_params_t *sw_params; int err; - MString sDevice = sParameters.length()?sParameters:"default"; + MString sDevice = sParameters.length()?sParameters:MString("default"); unsigned int Samplerate = 44100; int Channels = 2; @@ -217,8 +217,8 @@ int MercurySoundDriverALSA::playback_function(int nrframes) { int err; - short buf[nrframes*2]; - float ibuf[nrframes*2]; + short *buf = new short[nrframes*2]; + float *ibuf = new float[nrframes*2]; SOUNDMAN.FillBuffer( ibuf, nrframes ); @@ -236,6 +236,8 @@ SOUNDMAN.PostFill(); + delete buf; + delete ibuf; return err; } Modified: Mercury2/src/MercurySoundSourceVorbis.cpp =================================================================== --- Mercury2/src/MercurySoundSourceVorbis.cpp 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/src/MercurySoundSourceVorbis.cpp 2010-06-02 04:49:22 UTC (rev 750) @@ -188,7 +188,7 @@ unsigned long BF = BufferFree(); unsigned long BFL = BF; - short tibuf[BF * 2]; + short * tibuf = new short[BF * 2]; do { @@ -198,7 +198,10 @@ Vorbistotal_bytes_read += Vorbisbytes_read; } while( Vorbisbytes_read > 0 && BFL ); if( Vorbisbytes_read < 0 ) + { + delete tibuf; return false; + } for( unsigned i = 0; i < BF; i++ ) { @@ -208,9 +211,15 @@ } if( Vorbisbytes_read == 0 && PlayLeft() == 0 ) + { + delete tibuf; return false; + } else + { + delete tibuf; return true; + } } Modified: Mercury2/src/XMLParser.cpp =================================================================== --- Mercury2/src/XMLParser.cpp 2010-05-23 15:56:37 UTC (rev 749) +++ Mercury2/src/XMLParser.cpp 2010-06-02 04:49:22 UTC (rev 750) @@ -125,8 +125,8 @@ MString path((const char*)d); int pos = path.find("."); - MString name = pos<=0?path:path.substr(0, pos); - MString rpath = pos<=0?"":path.substr(pos+1); //skip the period + MString name = (pos<=0)?path:path.substr(0, pos); + MString rpath = (pos<=0)?MString():path.substr(pos+1); //skip the period XMLNode parent = FindParentWithName( name ); if ( !parent.IsValid() ) @@ -167,8 +167,8 @@ if (path.length() > 0) { int pos = path.find("."); - MString name = pos<=0?path:path.substr(0, pos); - MString rpath = pos<=0?"":path.substr(pos+1); //skip the period + MString name = (pos<=0)?path:path.substr(0, pos); + MString rpath = (pos<=0)?MString():path.substr(pos+1); //skip the period for (XMLNode n = this->Child(); n.IsValid(); n = n.NextNode()) if (n.Attribute("name") == name) return n.RecursiveFindFallbackNode(rpath); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2010-11-21 04:02:03
|
Revision: 766 http://hgengine.svn.sourceforge.net/hgengine/?rev=766&view=rev Author: axlecrusher Date: 2010-11-21 04:01:56 +0000 (Sun, 21 Nov 2010) Log Message: ----------- Optimize access to commonly modified shader attributes by using pointers to the attributes rather than searching for the attributes each time. Storing pointers to attributes does not seem like the best way to do this. I think there may be a better way to do this, like having a enumeration for each attribute, or an integer computer at compile time to represent a specific attribute. Modified Paths: -------------- Mercury2/modules/ParticleEmitter.cpp Mercury2/modules/ParticleEmitter.h Mercury2/src/MercuryNode.cpp Mercury2/src/MercuryNode.h Mercury2/src/Shader.cpp Mercury2/src/Shader.h Modified: Mercury2/modules/ParticleEmitter.cpp =================================================================== --- Mercury2/modules/ParticleEmitter.cpp 2010-11-13 21:42:25 UTC (rev 765) +++ Mercury2/modules/ParticleEmitter.cpp 2010-11-21 04:01:56 UTC (rev 766) @@ -95,7 +95,8 @@ m_particles(NULL), GenerateParticlesClbk(NULL), m_fLastD(0),m_fLastI(0), m_dBegin(0), m_dEnd(0), - m_iBegin(0), m_iEnd(0) + m_iBegin(0), m_iEnd(0), + m_shdrAttrEmitterTime(NULL) { m_bufferID[0] = 0; m_iForcePasses = m_iForcePasses | (1<<15); @@ -280,11 +281,12 @@ void ParticleEmitter::Render(const MercuryMatrix& matrix) { - ShaderAttribute sa; - sa.type = ShaderAttribute::TYPE_FLOAT; - sa.value.fFloat = m_age; - Shader::SetAttribute("EmitterTime", sa); + if (m_shdrAttrEmitterTime==NULL) + m_shdrAttrEmitterTime = Shader::GetAttribute("EmitterTime"); + m_shdrAttrEmitterTime->type = ShaderAttribute::TYPE_FLOAT; + m_shdrAttrEmitterTime->value.fFloat = m_age; + GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_CURRENT_BIT) ); GLCALL( glDisable(GL_CULL_FACE) ); Modified: Mercury2/modules/ParticleEmitter.h =================================================================== --- Mercury2/modules/ParticleEmitter.h 2010-11-13 21:42:25 UTC (rev 765) +++ Mercury2/modules/ParticleEmitter.h 2010-11-21 04:01:56 UTC (rev 766) @@ -88,6 +88,9 @@ void *m_dBegin, *m_dEnd; //pointers to area of the m_vertexDynamicData that changed void *m_iBegin, *m_iEnd; //pointers to area of the m_indexData that changed + ShaderAttribute* m_shdrAttrEmitterTime; + + std::list< ParticleBase* > m_active, m_inactive; static uint32_t m_particlesDrawn; }; Modified: Mercury2/src/MercuryNode.cpp =================================================================== --- Mercury2/src/MercuryNode.cpp 2010-11-13 21:42:25 UTC (rev 765) +++ Mercury2/src/MercuryNode.cpp 2010-11-21 04:01:56 UTC (rev 766) @@ -18,7 +18,8 @@ MercuryNode::MercuryNode() :m_parent(NULL), m_prevSibling(NULL), m_nextSibling(NULL), m_flags(SAVECHILDREN & ENABLESAVE), - m_iPasses( DEFAULT_PASSES ), m_iForcePasses( 0 ) + m_iPasses( DEFAULT_PASSES ), m_iForcePasses( 0 ), + m_shaderAttrModelMatrix(NULL) { m_pGlobalMatrix = &MercuryMatrix::IdentityMatrix; m_pModelViewMatrix = &MercuryMatrix::IdentityMatrix; @@ -238,7 +239,7 @@ const MercuryMatrix& matrix = GetGlobalMatrix(); const MercuryMatrix& modelView = GetModelViewMatrix(); //get the one computed in the last transform - ShaderAttribute sa; +// ShaderAttribute sa; //A lot of this stuff could be moved into the transform node, BUT //the alpha render path requires that all things things happen, so @@ -246,10 +247,13 @@ //RenderGraph::RenderAlpha GLCALL( glLoadMatrix( modelView ) ); - sa.type = ShaderAttribute::TYPE_MATRIX; - sa.value.matrix = matrix.Ptr(); - Shader::SetAttribute("HG_ModelMatrix", sa); + if (m_shaderAttrModelMatrix == NULL) + m_shaderAttrModelMatrix = Shader::GetAttribute("HG_ModelMatrix"); + + m_shaderAttrModelMatrix->type = ShaderAttribute::TYPE_MATRIX; + m_shaderAttrModelMatrix->value.matrix = matrix.Ptr(); + Render( modelView ); //calls on children assets //call render on other render graph entries under me @@ -262,7 +266,7 @@ } GLCALL( glLoadMatrix( modelView ) ); - Shader::SetAttribute("HG_ModelMatrix", sa); + m_shaderAttrModelMatrix->value.matrix = matrix.Ptr(); PostRender( modelView ); //calls on children assets Modified: Mercury2/src/MercuryNode.h =================================================================== --- Mercury2/src/MercuryNode.h 2010-11-13 21:42:25 UTC (rev 765) +++ Mercury2/src/MercuryNode.h 2010-11-21 04:01:56 UTC (rev 766) @@ -17,6 +17,7 @@ Each node exists as a single entity in the scene graph. **/ +#include <Shader.h> #define STANDARD_PASS 7 ///Which passes, by default, should be run on all nodes. @@ -173,6 +174,7 @@ const MercuryMatrix * m_pGlobalMatrix; const MercuryMatrix * m_pModelViewMatrix; + ShaderAttribute* m_shaderAttrModelMatrix; friend class RenderGraph; }; Modified: Mercury2/src/Shader.cpp =================================================================== --- Mercury2/src/Shader.cpp 2010-11-13 21:42:25 UTC (rev 765) +++ Mercury2/src/Shader.cpp 2010-11-21 04:01:56 UTC (rev 766) @@ -462,6 +462,19 @@ return -1; } +ShaderAttribute* Shader::GetAttribute(const MString& name) +{ + ShaderAttribute* a = m_globalAttributes.get(name); + if (a == NULL) + { + ShaderAttribute blank; + m_globalAttributes[name] = blank; + a = m_globalAttributes.get(name); + } + + return a; +} + void Shader::SetAttribute(const MString& name, const ShaderAttribute& x) { m_globalAttributes[name] = x; Modified: Mercury2/src/Shader.h =================================================================== --- Mercury2/src/Shader.h 2010-11-13 21:42:25 UTC (rev 765) +++ Mercury2/src/Shader.h 2010-11-21 04:01:56 UTC (rev 766) @@ -82,6 +82,7 @@ virtual void LoadFromXML(const XMLNode& node); + static ShaderAttribute* GetAttribute(const MString& name); static void SetAttribute(const MString& name, const ShaderAttribute& x); static void RemoveAttribute(const MString& name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |