You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(46) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(185) |
Feb
(242) |
Mar
(237) |
Apr
(180) |
May
(102) |
Jun
(278) |
Jul
(114) |
Aug
(92) |
Sep
(246) |
Oct
(212) |
Nov
(279) |
Dec
(99) |
| 2007 |
Jan
(130) |
Feb
(194) |
Mar
(22) |
Apr
(72) |
May
(40) |
Jun
(111) |
Jul
(114) |
Aug
(154) |
Sep
(114) |
Oct
(2) |
Nov
(1) |
Dec
(5) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(51) |
Nov
(34) |
Dec
(130) |
| 2009 |
Jan
(22) |
Feb
(20) |
Mar
(41) |
Apr
(45) |
May
(82) |
Jun
(96) |
Jul
(48) |
Aug
(90) |
Sep
(13) |
Oct
(49) |
Nov
(31) |
Dec
(21) |
| 2010 |
Jan
(25) |
Feb
(9) |
Mar
(7) |
Apr
(28) |
May
(27) |
Jun
(7) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(13) |
Dec
(2) |
| 2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <axl...@us...> - 2009-01-01 17:01:53
|
Revision: 134
http://hgengine.svn.sourceforge.net/hgengine/?rev=134&view=rev
Author: axlecrusher
Date: 2009-01-01 17:01:48 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
Add timer
Added Paths:
-----------
Mercury2/src/MercuryTimer.cpp
Mercury2/src/MercuryTimer.h
Added: Mercury2/src/MercuryTimer.cpp
===================================================================
--- Mercury2/src/MercuryTimer.cpp (rev 0)
+++ Mercury2/src/MercuryTimer.cpp 2009-01-01 17:01:48 UTC (rev 134)
@@ -0,0 +1,89 @@
+#include <MercuryTimer.h>
+
+#ifndef WIN32
+#include <sys/time.h>
+#else
+#include <windows.h>
+#endif
+
+int64_t GetTimeInMicroSeconds()
+{
+ struct timeval tv;
+ gettimeofday( &tv, 0 );
+
+ return (int64_t(tv.tv_sec) * 1000000) + tv.tv_usec;
+}
+
+MercuryTimer::MercuryTimer()
+ :m_lastTouch(0), m_thisTouch(0)
+{
+ if (m_initTime == 0)
+ m_initTime = GetTimeInMicroSeconds();
+
+ Touch();
+ m_lastTouch = m_thisTouch;
+}
+
+uint64_t MercuryTimer::MicrosecondsSinceInit()
+{
+ return m_thisTouch;
+}
+
+float MercuryTimer::Touch()
+{
+ m_lastTouch = m_thisTouch;
+ m_thisTouch = GetTimeInMicroSeconds() - m_initTime;
+ return Age();
+}
+
+float MercuryTimer::Touch(const MercuryTimer& t)
+{
+ m_thisTouch = t.m_thisTouch;
+ return Age();
+}
+
+float MercuryTimer::Age()
+{
+ return (m_thisTouch - m_lastTouch)/1000000.0f;
+}
+
+const MercuryTimer& MercuryTimer::operator=(const MercuryTimer& t)
+{
+ m_lastTouch = t.m_lastTouch;
+ m_thisTouch = t.m_thisTouch;
+ return *this;
+}
+
+uint64_t MercuryTimer::m_initTime = 0;
+
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Added: Mercury2/src/MercuryTimer.h
===================================================================
--- Mercury2/src/MercuryTimer.h (rev 0)
+++ Mercury2/src/MercuryTimer.h 2009-01-01 17:01:48 UTC (rev 134)
@@ -0,0 +1,62 @@
+#ifndef MERCURYTIMER_H
+#define MERCURYTIMER_H
+
+#include <stdint.h>
+
+class MercuryTimer
+{
+ public:
+ MercuryTimer();
+
+ uint64_t MicrosecondsSinceInit();
+
+ ///returns the age
+ float Touch();
+
+ ///sets this touch equal to t.m_thisTouch, leaves last touch unchanged
+ float Touch(const MercuryTimer& t);
+
+ ///time between last last touch and this touch
+ float Age();
+
+ const MercuryTimer& operator=(const MercuryTimer& t);
+ private:
+ static uint64_t m_initTime;
+
+ uint64_t m_lastTouch;
+ uint64_t m_thisTouch;
+};
+
+#endif
+
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-01-01 03:45:41
|
Revision: 133
http://hgengine.svn.sourceforge.net/hgengine/?rev=133&view=rev
Author: axlecrusher
Date: 2009-01-01 03:45:38 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
update
Modified Paths:
--------------
Mercury2/mercury2.kdevelop
Modified: Mercury2/mercury2.kdevelop
===================================================================
--- Mercury2/mercury2.kdevelop 2009-01-01 03:44:13 UTC (rev 132)
+++ Mercury2/mercury2.kdevelop 2009-01-01 03:45:38 UTC (rev 133)
@@ -2,7 +2,7 @@
<kdevelop>
<general>
<author>Joshua Allen</author>
- <email></email>
+ <email/>
<version>2.0</version>
<projectmanagement>KDevAutoProject</projectmanagement>
<primarylanguage>C++</primarylanguage>
@@ -14,8 +14,8 @@
<projectname>Mercury2</projectname>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
- <description></description>
- <defaultencoding></defaultencoding>
+ <description/>
+ <defaultencoding/>
<versioncontrol/>
</general>
<kdevautoproject>
@@ -26,8 +26,8 @@
<run>
<mainprogram>/home/josh/Mercury2/debug/src/mercury2</mainprogram>
<terminal>false</terminal>
- <programargs></programargs>
- <globaldebugarguments></globaldebugarguments>
+ <programargs/>
+ <globaldebugarguments/>
<globalcwd>/home/josh/Mercury2</globalcwd>
<useglobalprogram>true</useglobalprogram>
<autocompile>false</autocompile>
@@ -43,15 +43,15 @@
<f77compiler>kdevg77options</f77compiler>
<cxxflags>-O2 -g0 -Wall</cxxflags>
<envvars/>
- <configargs></configargs>
- <topsourcedir></topsourcedir>
+ <configargs/>
+ <topsourcedir/>
<cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags>
<ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags>
- <ccompilerbinary></ccompilerbinary>
- <cxxcompilerbinary></cxxcompilerbinary>
- <f77compilerbinary></f77compilerbinary>
- <cflags></cflags>
- <f77flags></f77flags>
+ <ccompilerbinary/>
+ <cxxcompilerbinary/>
+ <f77compilerbinary/>
+ <cflags/>
+ <f77flags/>
</optimized>
<debug>
<configargs>--enable-debug=full</configargs>
@@ -61,14 +61,14 @@
<f77compiler>kdevg77options</f77compiler>
<cxxflags>-O0 -g3 -Wall</cxxflags>
<envvars/>
- <topsourcedir></topsourcedir>
+ <topsourcedir/>
<cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags>
<ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags>
- <ccompilerbinary></ccompilerbinary>
- <cxxcompilerbinary></cxxcompilerbinary>
- <f77compilerbinary></f77compilerbinary>
- <cflags></cflags>
- <f77flags></f77flags>
+ <ccompilerbinary/>
+ <cxxcompilerbinary/>
+ <f77compilerbinary/>
+ <cflags/>
+ <f77flags/>
</debug>
<default>
<envvars/>
@@ -83,7 +83,7 @@
<runmultiplejobs>true</runmultiplejobs>
<numberofjobs>3</numberofjobs>
<dontact>false</dontact>
- <makebin></makebin>
+ <makebin/>
<prio>0</prio>
</make>
</kdevautoproject>
@@ -208,7 +208,7 @@
<includePaths>.;</includePaths>
</codecompletion>
<creategettersetter>
- <prefixGet></prefixGet>
+ <prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
@@ -229,11 +229,11 @@
</cppsupportpart>
<kdevdebugger>
<general>
- <gdbpath></gdbpath>
+ <gdbpath/>
<dbgshell>libtool</dbgshell>
- <configGdbScript></configGdbScript>
- <runShellScript></runShellScript>
- <runGdbScript></runGdbScript>
+ <configGdbScript/>
+ <runShellScript/>
+ <runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-01-01 03:44:17
|
Revision: 132
http://hgengine.svn.sourceforge.net/hgengine/?rev=132&view=rev
Author: axlecrusher
Date: 2009-01-01 03:44:13 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
update for message system
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-01-01 03:40:46 UTC (rev 131)
+++ Mercury2/src/Mercury2.cpp 2009-01-01 03:44:13 UTC (rev 132)
@@ -12,7 +12,7 @@
#include <MercuryCrash.h>
#include <MercuryBacktrace.h>
-
+#include <MercuryMessageManager.h>
MSemaphore UpdateLoopGo;
void* UpdateThread(void* node)
{
@@ -37,7 +37,9 @@
int main()
{
unsigned long m_count = 0;
-
+ uint64_t startTime = GetTimeInMicroSeconds();
+ uint64_t timeSinceStart = 0;
+
cnset_execute_on_crash( SignalHandler );
MercuryWindow* w = MercuryWindow::MakeWindow();
@@ -50,30 +52,30 @@
SAFE_DELETE(doc);
- uint64_t oTime = GetTimeInMicroSeconds();
+ uint64_t oTime = timeSinceStart;
uint64_t m_time = oTime;
//uncomment the next 2 lines to use threads
// MercuryThread updateThread;
// updateThread.Create( UpdateThread, root, false);
-
do
{
- uint64_t curTime = GetTimeInMicroSeconds();
- root->RecursiveUpdate((curTime-oTime)/1000000.0f); //comment to use threads
+ timeSinceStart = GetTimeInMicroSeconds() - startTime;
+ MESSAGEMAN::GetInstance().PumpMessages( timeSinceStart );
+ root->RecursiveUpdate((timeSinceStart-oTime)/1000000.0f); //comment to use threads
RenderableNode::RecursiveRender(root);
w->SwapBuffers();
++m_count;
- float seconds = (curTime-m_time)/1000000.0f;
+ float seconds = (timeSinceStart-m_time)/1000000.0f;
if (seconds > 1)
{
- m_time = curTime;
+ m_time = timeSinceStart;
printf("FPS: %f\n", m_count/seconds);
m_count = 0;
}
- oTime = curTime;
+ oTime = timeSinceStart;
}
while ( w->PumpMessages() );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-01-01 03:40:51
|
Revision: 131
http://hgengine.svn.sourceforge.net/hgengine/?rev=131&view=rev
Author: axlecrusher
Date: 2009-01-01 03:40:46 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
use MessageHandler as base
Modified Paths:
--------------
Mercury2/src/MercuryAsset.h
Mercury2/src/MercuryNode.h
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2009-01-01 03:38:38 UTC (rev 130)
+++ Mercury2/src/MercuryAsset.h 2009-01-01 03:40:46 UTC (rev 131)
@@ -3,10 +3,10 @@
#include <MAutoPtr.h>
#include <MercuryNode.h>
-
+#include <MessageHandler.h>
#include <map>
-class MercuryAsset : public RefBase
+class MercuryAsset : public RefBase, MessageHandler
{
public:
MercuryAsset();
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-01-01 03:38:38 UTC (rev 130)
+++ Mercury2/src/MercuryNode.h 2009-01-01 03:40:46 UTC (rev 131)
@@ -6,6 +6,7 @@
#include <typeinfo>
#include <XMLParser.h>
#include <MercuryUtil.h>
+#include <MessageHandler.h>
/** This is the basic node of the scene graph. It is not intended to be instanced.
Each node exists as a single entity in the scene graph.
@@ -22,7 +23,7 @@
while(tn) { if (typeid(x) == typeid(*tn)) return true; tn = *n; } \
return false;}
*/
-class MercuryNode
+class MercuryNode : public MessageHandler
{
public:
MercuryNode();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-01-01 03:38:45
|
Revision: 130
http://hgengine.svn.sourceforge.net/hgengine/?rev=130&view=rev
Author: axlecrusher
Date: 2009-01-01 03:38:38 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
add message manager
Added Paths:
-----------
Mercury2/src/MercuryMessageManager.cpp
Mercury2/src/MercuryMessageManager.h
Mercury2/src/MessageHandler.h
Mercury2/src/PriorityQueue.h
Added: Mercury2/src/MercuryMessageManager.cpp
===================================================================
--- Mercury2/src/MercuryMessageManager.cpp (rev 0)
+++ Mercury2/src/MercuryMessageManager.cpp 2009-01-01 03:38:38 UTC (rev 130)
@@ -0,0 +1,76 @@
+#include <MercuryMessageManager.h>
+
+void MercuryMessageManager::PostMessage(const MString& message, float delay)
+{
+ uint64_t fireTime = m_currTime + uint64_t(delay*1000000);
+ m_messageQueue.Insert(fireTime, message);
+}
+
+void MercuryMessageManager::PumpMessages(const uint64_t& currTime)
+{
+ m_currTime = currTime;
+ while ( !m_messageQueue.empty() )
+ {
+ if ( m_messageQueue.PeekNextPriority() > m_currTime ) return;
+
+ MString& message = m_messageQueue.GetNext();
+ FireOffMessage( message );
+ m_messageQueue.PopNext();
+ }
+}
+
+void MercuryMessageManager::RegisterForMessage(const MString& message, MessageHandler* ptr)
+{
+ m_messageRecipients[message].push_back(ptr);
+}
+
+void MercuryMessageManager::FireOffMessage(const MString& message)
+{
+ std::map< MString, std::list< MessageHandler* > >::iterator i = m_messageRecipients.find(message);
+
+
+ std::list< MessageHandler* >::iterator recipients = i->second.begin();
+
+ for (; recipients != i->second.end(); ++recipients)
+ (*recipients)->HandleMessage(message);
+}
+
+MercuryMessageManager& MercuryMessageManager::GetInstance()
+{
+ static MercuryMessageManager *instance = NULL;
+ if (!instance)
+ instance = new MercuryMessageManager();
+ return *instance;
+}
+
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Added: Mercury2/src/MercuryMessageManager.h
===================================================================
--- Mercury2/src/MercuryMessageManager.h (rev 0)
+++ Mercury2/src/MercuryMessageManager.h 2009-01-01 03:38:38 UTC (rev 130)
@@ -0,0 +1,71 @@
+#ifndef MERCURYMESSAGEMANAGER_H
+#define MERCURYMESSAGEMANAGER_H
+
+#include <Callback.h>
+#include <MessageHandler.h>
+#include <map>
+#include <PriorityQueue.h>
+#include <MercuryString.h>
+#include <MercuryUtil.h>
+
+/* This message system uses absolute integer time values to fire off events.
+This ensures accuarate firing times while eliminating floating point error.
+Because we use absolute times in the queue we do not need to "count down" the
+firing times of all the messages. We only need to pop off the nearest events
+from the beginning of the queue." */
+class MercuryMessageManager
+{
+ public:
+ void PostMessage(const MString& message, float delay);
+ void PumpMessages(const uint64_t& currTime);
+ void RegisterForMessage(const MString& message, MessageHandler* ptr);
+
+ static MercuryMessageManager& GetInstance();
+ private:
+ void FireOffMessage(const MString& message);
+
+ PriorityQueue<uint64_t, MString> m_messageQueue;
+ uint64_t m_currTime; //microseconds
+
+ std::map< MString, std::list< MessageHandler* > > m_messageRecipients;
+};
+
+static InstanceCounter<MercuryMessageManager> MMcounter("MessageManager");
+
+#define MESSAGEMAN MercuryMessageManager
+#define REGISTER_FOR_MESSAGE(x) MESSAGEMAN::GetInstance().RegisterForMessage(#x, this)
+#define POST_MESSAGE(x,delay) MESSAGEMAN::GetInstance().PostMessage(#x, delay)
+
+#endif
+
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Added: Mercury2/src/MessageHandler.h
===================================================================
--- Mercury2/src/MessageHandler.h (rev 0)
+++ Mercury2/src/MessageHandler.h 2009-01-01 03:38:38 UTC (rev 130)
@@ -0,0 +1,44 @@
+#ifndef MESSAGEHANDLER_H
+#define MESSAGEHANDLER_H
+
+#include <MercuryString.h>
+
+class MessageHandler
+{
+ public:
+ virtual ~MessageHandler() {};
+ virtual void HandleMessage(const MString& message) {};
+};
+
+#endif
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Added: Mercury2/src/PriorityQueue.h
===================================================================
--- Mercury2/src/PriorityQueue.h (rev 0)
+++ Mercury2/src/PriorityQueue.h 2009-01-01 03:38:38 UTC (rev 130)
@@ -0,0 +1,64 @@
+#ifndef PRIORITYQUEUE_H
+#define PRIORITYQUEUE_H
+
+#include <list>
+#include <map>
+
+template<typename T1, typename T2>
+class PriorityQueue
+{
+ public:
+ void Insert(const T1& priority, const T2& x)
+ {
+ m_queue[priority].push_back(x);
+ }
+
+ bool empty() { return m_queue.empty(); }
+
+ const T1& PeekNextPriority() { return m_queue.begin()->first; }
+ T2& GetNext() { return m_queue.begin()->second.front(); }
+ void PopNext()
+ {
+ m_queue.begin()->second.pop_front();
+
+ if ( m_queue.begin()->second.empty() )
+ m_queue.erase( m_queue.begin() );
+ }
+
+ private:
+ std::map< T1, std::list<T2> > m_queue;
+};
+
+#endif
+
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-31 20:17:34
|
Revision: 129
http://hgengine.svn.sourceforge.net/hgengine/?rev=129&view=rev
Author: axlecrusher
Date: 2008-12-31 20:17:29 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
fake normals if they don't exist
Modified Paths:
--------------
Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp
Modified: Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp
===================================================================
--- Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2008-12-31 20:15:14 UTC (rev 128)
+++ Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2008-12-31 20:17:29 UTC (rev 129)
@@ -46,6 +46,7 @@
*/
void LineParser(const string &line)
{
+ if (line.empty()) return;
string token = line.substr(0,2);
if (token == "v ")
{
@@ -57,6 +58,7 @@
{
MercuryPoint tv;
sscanf(line.c_str(), "vt %f %f", &tv.x, &tv.y);
+ tv.y = 1 - tv.y; //XXX reverse
vt.push_back(tv);
}
else if (token == "vn")
@@ -68,8 +70,18 @@
else if (token == "f ")
{
uint32_t iv[3], ivt[3], ivn[3];
- sscanf(line.c_str(), "f %d/%d/%d %d/%d/%d %d/%d/%d", &iv[0], &ivt[0], &ivn[0], &iv[1], &ivt[1], &ivn[1], &iv[2], &ivt[2], &ivn[2]);
+ int r;
+ r = sscanf(line.c_str(), "f %d/%d/%d %d/%d/%d %d/%d/%d", &iv[0], &ivt[0], &ivn[0], &iv[1], &ivt[1], &ivn[1], &iv[2], &ivt[2], &ivn[2]);
+
+ if (r != 9)
+ {
+ r = sscanf(line.c_str(), "f %d/%d %d/%d %d/%d", &iv[0], &ivt[0], &iv[1], &ivt[1], &iv[2], &ivt[2]);
+ ivn[0] = ivn[1] = ivn[2] = 1;
+ MercuryPoint tv;
+ vn.push_back(tv);
+ }
+
Vertex tv[3];
for (int i=0; i < 3; ++i)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-31 20:15:21
|
Revision: 128
http://hgengine.svn.sourceforge.net/hgengine/?rev=128&view=rev
Author: axlecrusher
Date: 2008-12-31 20:15:14 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
call base constructor
Modified Paths:
--------------
Mercury2/src/Quad.cpp
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2008-12-31 15:02:36 UTC (rev 127)
+++ Mercury2/src/Quad.cpp 2008-12-31 20:15:14 UTC (rev 128)
@@ -8,6 +8,7 @@
REGISTER_ASSET_TYPE(Quad);
Quad::Quad()
+ :MercuryVBO()
{
AllocateIndexSpace(6);
AllocateVertexSpace(4);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-31 15:02:39
|
Revision: 127
http://hgengine.svn.sourceforge.net/hgengine/?rev=127&view=rev
Author: axlecrusher
Date: 2008-12-31 15:02:36 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
instance models and change m_isLoaded to m_isInstanced, make the factory set the IsInstanced flag
Modified Paths:
--------------
Mercury2/scenegraph.xml
Mercury2/src/HGMDLModel.cpp
Mercury2/src/HGMDLModel.h
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryAsset.h
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2008-12-31 05:04:06 UTC (rev 126)
+++ Mercury2/scenegraph.xml 2008-12-31 15:02:36 UTC (rev 127)
@@ -26,4 +26,10 @@
<asset type="hgmdlmodel" file="beerhall.hgmdl"/>
</node>
</node>
+ <node type="rotatornode" movz="-2" movx="2" scalex="0.05" scaley="0.05" scalez="0.05" >
+ <node type="renderablenode">
+ <asset type="texture" file="test.bmp"/>
+ <asset type="hgmdlmodel" file="beerhall.hgmdl"/>
+ </node>
+ </node>
</SceneGraph>
Modified: Mercury2/src/HGMDLModel.cpp
===================================================================
--- Mercury2/src/HGMDLModel.cpp 2008-12-31 05:04:06 UTC (rev 126)
+++ Mercury2/src/HGMDLModel.cpp 2008-12-31 15:02:36 UTC (rev 127)
@@ -2,20 +2,20 @@
REGISTER_ASSET_TYPE(HGMDLModel);
+HGMDLModel::HGMDLModel()
+ :MercuryAsset()
+{
+}
+
+HGMDLModel::~HGMDLModel()
+{
+ REMOVE_ASSET_INSTANCE(HGMDLModel, m_path);
+}
+
void HGMDLModel::LoadFromXML(const XMLNode& node)
{
- if ( !node.Attribute("file").empty() )
- {
- //FILE* f = fopen( node.Attribute("file").c_str(), "rb" );
- MercuryFile * f = FILEMAN.Open( node.Attribute("file") );
- if( !f )
- {
- printf( "Could not open file: \"%s\" for model\n", node.Attribute("file").c_str() );
- return;
- }
- LoadModel( f );
- delete f;
- }
+ MString path = node.Attribute("file");
+ LoadHGMDL( path );
}
void HGMDLModel::LoadModel(MercuryFile* hgmdl)
@@ -59,8 +59,27 @@
m_meshes[i]->Render(node);
}
+void HGMDLModel::LoadHGMDL( const MString& path )
+{
+ if ( m_isInstanced ) return;
+ if ( !path.empty() )
+ {
+ ADD_ASSET_INSTANCE(HGMDLModel, path, this);
+ m_path = path;
+ MercuryFile * f = FILEMAN.Open( path );
+ if( !f )
+ {
+ printf( "Could not open file: \"%s\" for model\n", path.c_str() );
+ return;
+ }
+ LoadModel( f );
+ delete f;
+ }
+}
+
HGMDLModel* HGMDLModel::Generate()
{
+ printf("new HGMDL\n");
return new HGMDLModel();
}
Modified: Mercury2/src/HGMDLModel.h
===================================================================
--- Mercury2/src/HGMDLModel.h 2008-12-31 05:04:06 UTC (rev 126)
+++ Mercury2/src/HGMDLModel.h 2008-12-31 15:02:36 UTC (rev 127)
@@ -10,6 +10,8 @@
class HGMDLModel : public MercuryAsset
{
public:
+ HGMDLModel();
+ ~HGMDLModel();
virtual void LoadFromXML(const XMLNode& node);
@@ -19,6 +21,9 @@
virtual void Render(MercuryNode* node);
private:
+ void LoadHGMDL( const MString& path );
+
+ MString m_path;
std::vector< MAutoPtr< HGMDLMesh > > m_meshes;
};
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2008-12-31 05:04:06 UTC (rev 126)
+++ Mercury2/src/MercuryAsset.cpp 2008-12-31 15:02:36 UTC (rev 127)
@@ -1,6 +1,12 @@
#include <MercuryAsset.h>
#include <RenderableNode.h>
+MercuryAsset::MercuryAsset()
+ :m_isInstanced(false)
+{
+}
+
+
void MercuryAsset::Init(MercuryNode* node)
{
RenderableNode* rn;
@@ -47,6 +53,7 @@
void AssetFactory::AddAssetInstance(const MString& key, MercuryAsset* asset)
{
+ asset->IsInstanced(true);
m_assetInstances[key] = asset;
}
@@ -54,7 +61,10 @@
{
std::map<MString, MercuryAsset*>::iterator asset = m_assetInstances.find(key);
if ( asset != m_assetInstances.end() )
+ {
m_assetInstances.erase( asset );
+ printf("removed asset %s\n", key.c_str());
+ }
}
std::map<MString, MercuryAsset*> AssetFactory::m_assetInstances;
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2008-12-31 05:04:06 UTC (rev 126)
+++ Mercury2/src/MercuryAsset.h 2008-12-31 15:02:36 UTC (rev 127)
@@ -9,6 +9,7 @@
class MercuryAsset : public RefBase
{
public:
+ MercuryAsset();
virtual ~MercuryAsset() {};
virtual void Init(MercuryNode* node);
@@ -19,6 +20,10 @@
///Loads an asset from an XMLAsset representing itself
virtual void LoadFromXML(const XMLNode& node) {};
+
+ inline void IsInstanced(bool b) { m_isInstanced = b; }
+ protected:
+ bool m_isInstanced;
};
class AssetFactory
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2008-12-31 05:04:06 UTC (rev 126)
+++ Mercury2/src/Texture.cpp 2008-12-31 15:02:36 UTC (rev 127)
@@ -12,7 +12,7 @@
REGISTER_ASSET_TYPE(Texture);
Texture::Texture()
- :m_raw(NULL),m_textureID(0),m_isLoaded(false)
+ :MercuryAsset(), m_raw(NULL),m_textureID(0)
{
if (!m_initTextureSuccess)
{
@@ -94,7 +94,6 @@
void Texture::LoadFromXML(const XMLNode& node)
{
- if (m_isLoaded) return;
LoadImage( node.Attribute("file") );
}
@@ -121,11 +120,11 @@
void Texture::LoadImage(const MString& path)
{
+ if (m_isInstanced) return;
if ( !path.empty() )
{
- m_isLoaded = true;
+ ADD_ASSET_INSTANCE(Texture, path, this);
m_filename = path;
- ADD_ASSET_INSTANCE(Texture, m_filename, this);
RawImageData* d = ImageLoader::GetInstance().LoadImage( m_filename );
if (d) LoadFromRaw( d );
}
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2008-12-31 05:04:06 UTC (rev 126)
+++ Mercury2/src/Texture.h 2008-12-31 15:02:36 UTC (rev 127)
@@ -37,7 +37,6 @@
static unsigned short m_activeTextures;
MString m_filename;
- bool m_isLoaded;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-31 05:04:10
|
Revision: 126
http://hgengine.svn.sourceforge.net/hgengine/?rev=126&view=rev
Author: axlecrusher
Date: 2008-12-31 05:04:06 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
don't give access to the factory's locate function, go through the factory's generate
Modified Paths:
--------------
Mercury2/src/MercuryAsset.h
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2008-12-31 04:52:33 UTC (rev 125)
+++ Mercury2/src/MercuryAsset.h 2008-12-31 05:04:06 UTC (rev 126)
@@ -30,10 +30,10 @@
void AddAssetInstance(const MString& key, MercuryAsset* asset);
void RemoveAssetInstance(const MString& key);
-
+
+ private:
MercuryAsset* LocateAsset( const MString& key );
- private:
std::list< std::pair< MString, Callback0R< MAutoPtr<MercuryAsset> > > > m_factoryCallbacks;
static std::map<MString, MercuryAsset*> m_assetInstances;
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2008-12-31 04:52:33 UTC (rev 125)
+++ Mercury2/src/Texture.cpp 2008-12-31 05:04:06 UTC (rev 126)
@@ -136,11 +136,12 @@
return new Texture();
}
-Texture* Texture::LoadFromFile(const MString& path)
+MAutoPtr< Texture > Texture::LoadFromFile(const MString& path)
{
- Texture *t = (Texture*)AssetFactory::GetInstance().LocateAsset("TEXTURE" + path);
- if (!t) t = Generate();
- t->LoadImage( path );
+ MAutoPtr< MercuryAsset > t( AssetFactory::GetInstance().Generate("Texture", path) );
+ Texture *a = (Texture*)&(*t);
+ a->LoadImage( path );
+ return a;
}
bool Texture::m_initTextureSuccess = false;
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2008-12-31 04:52:33 UTC (rev 125)
+++ Mercury2/src/Texture.h 2008-12-31 05:04:06 UTC (rev 126)
@@ -22,7 +22,7 @@
inline static unsigned short NumberActiveTextures() { return m_activeTextures; }
static Texture* Generate();
- static Texture* LoadFromFile(const MString& path);
+ static MAutoPtr< Texture > LoadFromFile(const MString& path);
private:
void LoadImage(const MString& path);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-31 04:52:38
|
Revision: 125
http://hgengine.svn.sourceforge.net/hgengine/?rev=125&view=rev
Author: axlecrusher
Date: 2008-12-31 04:52:33 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
updates
Modified Paths:
--------------
Mercury2/mercury2.kdevelop
Mercury2/scenegraph.xml
Modified: Mercury2/mercury2.kdevelop
===================================================================
--- Mercury2/mercury2.kdevelop 2008-12-31 04:49:29 UTC (rev 124)
+++ Mercury2/mercury2.kdevelop 2008-12-31 04:52:33 UTC (rev 125)
@@ -21,13 +21,13 @@
<kdevautoproject>
<general>
<activetarget>src/mercury2</activetarget>
- <useconfiguration>optimized</useconfiguration>
+ <useconfiguration>debug</useconfiguration>
</general>
<run>
<mainprogram>/home/josh/Mercury2/debug/src/mercury2</mainprogram>
<terminal>false</terminal>
- <programargs/>
- <globaldebugarguments/>
+ <programargs></programargs>
+ <globaldebugarguments></globaldebugarguments>
<globalcwd>/home/josh/Mercury2</globalcwd>
<useglobalprogram>true</useglobalprogram>
<autocompile>false</autocompile>
@@ -45,7 +45,7 @@
<envvars/>
<configargs></configargs>
<topsourcedir></topsourcedir>
- <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE</cppflags>
+ <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags>
<ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags>
<ccompilerbinary></ccompilerbinary>
<cxxcompilerbinary></cxxcompilerbinary>
@@ -62,7 +62,7 @@
<cxxflags>-O0 -g3 -Wall</cxxflags>
<envvars/>
<topsourcedir></topsourcedir>
- <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE</cppflags>
+ <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags>
<ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags>
<ccompilerbinary></ccompilerbinary>
<cxxcompilerbinary></cxxcompilerbinary>
@@ -70,6 +70,9 @@
<cflags></cflags>
<f77flags></f77flags>
</debug>
+ <default>
+ <envvars/>
+ </default>
</configurations>
<make>
<envvars>
@@ -80,7 +83,7 @@
<runmultiplejobs>true</runmultiplejobs>
<numberofjobs>3</numberofjobs>
<dontact>false</dontact>
- <makebin/>
+ <makebin></makebin>
<prio>0</prio>
</make>
</kdevautoproject>
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2008-12-31 04:49:29 UTC (rev 124)
+++ Mercury2/scenegraph.xml 2008-12-31 04:52:33 UTC (rev 125)
@@ -4,7 +4,7 @@
</node>
<node type="transformnode" movz="-3">
<node type="renderablenode">
- <asset type="texture" imagefile="test.bmp"/>
+ <asset type="texture" file="test.bmp"/>
<asset type="quad"/>
</node>
</node>
@@ -15,14 +15,14 @@
</node>
<node type="transformnode" movz="-3" movx="1" movy="-1">
<node type="renderablenode">
- <asset type="texture" imagefile="test2.png"/>
- <asset type="texture" imagefile="test.bmp"/>
+ <asset type="texture" file="test2.png"/>
+ <asset type="texture" file="test.bmp"/>
<asset type="quad"/>
</node>
</node>
<node type="rotatornode" movz="-2" scalex="0.05" scaley="0.05" scalez="0.05" >
<node type="renderablenode">
- <asset type="texture" imagefile="test.bmp"/>
+ <asset type="texture" file="test.bmp"/>
<asset type="hgmdlmodel" file="beerhall.hgmdl"/>
</node>
</node>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-31 04:49:32
|
Revision: 124
http://hgengine.svn.sourceforge.net/hgengine/?rev=124&view=rev
Author: axlecrusher
Date: 2008-12-31 04:49:29 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
make macros to add and remove instances
Modified Paths:
--------------
Mercury2/src/MercuryAsset.h
Mercury2/src/Quad.cpp
Mercury2/src/Texture.cpp
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2008-12-31 04:37:02 UTC (rev 123)
+++ Mercury2/src/MercuryAsset.h 2008-12-31 04:49:29 UTC (rev 124)
@@ -47,7 +47,12 @@
Callback0R< MAutoPtr<MercuryAsset> > factoryclbk##class( FactoryFunct##class ); \
bool GlobalRegisterSuccess##class = AssetFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class);
+#define ADD_ASSET_INSTANCE(class, key, ptr)\
+ AssetFactory::GetInstance().AddAssetInstance( ToUpper(#class)+key, ptr );
+#define REMOVE_ASSET_INSTANCE(class, key)\
+ AssetFactory::GetInstance().RemoveAssetInstance( ToUpper(#class)+key );
+
#endif
/***************************************************************************
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2008-12-31 04:37:02 UTC (rev 123)
+++ Mercury2/src/Quad.cpp 2008-12-31 04:49:29 UTC (rev 124)
@@ -39,13 +39,13 @@
Quad::~Quad()
{
- AssetFactory::GetInstance().RemoveAssetInstance( "QUAD" );
+ REMOVE_ASSET_INSTANCE(Quad,"");
}
Quad* Quad::Generate()
{
Quad *asset = new Quad();
- AssetFactory::GetInstance().AddAssetInstance( "QUAD", asset );
+ ADD_ASSET_INSTANCE(Quad,"",asset);
printf("new quad\n");
return asset;
}
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2008-12-31 04:37:02 UTC (rev 123)
+++ Mercury2/src/Texture.cpp 2008-12-31 04:49:29 UTC (rev 124)
@@ -23,7 +23,7 @@
Texture::~Texture()
{
- AssetFactory::GetInstance().RemoveAssetInstance( "TEXTURE"+m_filename );
+ REMOVE_ASSET_INSTANCE(TEXTURE, m_filename);
if (m_textureID) glDeleteTextures(1, &m_textureID);
m_textureID = 0;
@@ -125,7 +125,7 @@
{
m_isLoaded = true;
m_filename = path;
- AssetFactory::GetInstance().AddAssetInstance("TEXTURE" + m_filename, this);
+ ADD_ASSET_INSTANCE(Texture, m_filename, this);
RawImageData* d = ImageLoader::GetInstance().LoadImage( m_filename );
if (d) LoadFromRaw( d );
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-31 04:37:05
|
Revision: 123
http://hgengine.svn.sourceforge.net/hgengine/?rev=123&view=rev
Author: axlecrusher
Date: 2008-12-31 04:37:02 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
Use the unified asset instances in the asset factory
Modified Paths:
--------------
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryAsset.h
Mercury2/src/Quad.cpp
Mercury2/src/Quad.h
Mercury2/src/RenderableNode.cpp
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2008-12-31 00:35:14 UTC (rev 122)
+++ Mercury2/src/MercuryAsset.cpp 2008-12-31 04:37:02 UTC (rev 123)
@@ -24,9 +24,13 @@
return true;
}
-MAutoPtr<MercuryAsset> AssetFactory::Generate(const MString& type)
+MAutoPtr<MercuryAsset> AssetFactory::Generate(const MString& type, const MString& key)
{
MString t = ToUpper( type );
+
+ MercuryAsset *asset = LocateAsset(t+key);
+ if ( asset ) return asset;
+
std::list< std::pair< MString, Callback0R< MAutoPtr<MercuryAsset> > > >::iterator i;
for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i)
if (i->first == t) return i->second();
@@ -34,6 +38,27 @@
return NULL;
}
+MercuryAsset* AssetFactory::LocateAsset( const MString& key )
+{
+ std::map<MString, MercuryAsset*>::iterator asset = m_assetInstances.find(key);
+ if ( asset != m_assetInstances.end() ) return asset->second;
+ return NULL;
+}
+
+void AssetFactory::AddAssetInstance(const MString& key, MercuryAsset* asset)
+{
+ m_assetInstances[key] = asset;
+}
+
+void AssetFactory::RemoveAssetInstance(const MString& key)
+{
+ std::map<MString, MercuryAsset*>::iterator asset = m_assetInstances.find(key);
+ if ( asset != m_assetInstances.end() )
+ m_assetInstances.erase( asset );
+}
+
+std::map<MString, MercuryAsset*> AssetFactory::m_assetInstances;
+
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2008-12-31 00:35:14 UTC (rev 122)
+++ Mercury2/src/MercuryAsset.h 2008-12-31 04:37:02 UTC (rev 123)
@@ -4,6 +4,8 @@
#include <MAutoPtr.h>
#include <MercuryNode.h>
+#include <map>
+
class MercuryAsset : public RefBase
{
public:
@@ -24,10 +26,18 @@
public:
static AssetFactory& GetInstance();
bool RegisterFactoryCallback(const MString& type, Callback0R< MAutoPtr<MercuryAsset> >);
- MAutoPtr<MercuryAsset> Generate(const MString& type);
+ MAutoPtr<MercuryAsset> Generate(const MString& type, const MString& key);
+
+ void AddAssetInstance(const MString& key, MercuryAsset* asset);
+ void RemoveAssetInstance(const MString& key);
- private:
+ MercuryAsset* LocateAsset( const MString& key );
+
+ private:
std::list< std::pair< MString, Callback0R< MAutoPtr<MercuryAsset> > > > m_factoryCallbacks;
+
+ static std::map<MString, MercuryAsset*> m_assetInstances;
+
};
static InstanceCounter<AssetFactory> AFcounter("AssetFactory");
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2008-12-31 00:35:14 UTC (rev 122)
+++ Mercury2/src/Quad.cpp 2008-12-31 04:37:02 UTC (rev 123)
@@ -39,19 +39,17 @@
Quad::~Quad()
{
- if (m_myInstance == this)
- m_myInstance = NULL;
+ AssetFactory::GetInstance().RemoveAssetInstance( "QUAD" );
}
Quad* Quad::Generate()
{
- if ( !m_myInstance )
- m_myInstance = new Quad();
- return m_myInstance;
+ Quad *asset = new Quad();
+ AssetFactory::GetInstance().AddAssetInstance( "QUAD", asset );
+ printf("new quad\n");
+ return asset;
}
-Quad* Quad::m_myInstance = NULL;
-
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/Quad.h
===================================================================
--- Mercury2/src/Quad.h 2008-12-31 00:35:14 UTC (rev 122)
+++ Mercury2/src/Quad.h 2008-12-31 04:37:02 UTC (rev 123)
@@ -13,7 +13,6 @@
static Quad* Generate();
private:
- static Quad* m_myInstance;
};
#endif
Modified: Mercury2/src/RenderableNode.cpp
===================================================================
--- Mercury2/src/RenderableNode.cpp 2008-12-31 00:35:14 UTC (rev 122)
+++ Mercury2/src/RenderableNode.cpp 2008-12-31 04:37:02 UTC (rev 123)
@@ -143,7 +143,8 @@
{
if ( child.Name() == "asset" )
{
- MAutoPtr< MercuryAsset > asset( AssetFactory::GetInstance().Generate(child.Attribute("type") ) );
+ MString key = child.Attribute("file");
+ MAutoPtr< MercuryAsset > asset( AssetFactory::GetInstance().Generate( child.Attribute("type"), key ) );
if ( asset.IsValid() )
{
asset->LoadFromXML( child );
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2008-12-31 00:35:14 UTC (rev 122)
+++ Mercury2/src/Texture.cpp 2008-12-31 04:37:02 UTC (rev 123)
@@ -12,7 +12,7 @@
REGISTER_ASSET_TYPE(Texture);
Texture::Texture()
- :m_raw(NULL),m_textureID(0)
+ :m_raw(NULL),m_textureID(0),m_isLoaded(false)
{
if (!m_initTextureSuccess)
{
@@ -23,6 +23,8 @@
Texture::~Texture()
{
+ AssetFactory::GetInstance().RemoveAssetInstance( "TEXTURE"+m_filename );
+
if (m_textureID) glDeleteTextures(1, &m_textureID);
m_textureID = 0;
@@ -92,12 +94,8 @@
void Texture::LoadFromXML(const XMLNode& node)
{
- if ( !node.Attribute("imagefile").empty() )
- {
-// RawImageData* d = LoadBMP( node.Attribute("imagefile") );
- RawImageData* d = ImageLoader::GetInstance().LoadImage( node.Attribute("imagefile") );
- if (d) LoadFromRaw( d );
- }
+ if (m_isLoaded) return;
+ LoadImage( node.Attribute("file") );
}
void Texture::BindTexture()
@@ -121,9 +119,34 @@
--m_activeTextures;
}
+void Texture::LoadImage(const MString& path)
+{
+ if ( !path.empty() )
+ {
+ m_isLoaded = true;
+ m_filename = path;
+ AssetFactory::GetInstance().AddAssetInstance("TEXTURE" + m_filename, this);
+ RawImageData* d = ImageLoader::GetInstance().LoadImage( m_filename );
+ if (d) LoadFromRaw( d );
+ }
+}
+
+Texture* Texture::Generate()
+{
+ return new Texture();
+}
+
+Texture* Texture::LoadFromFile(const MString& path)
+{
+ Texture *t = (Texture*)AssetFactory::GetInstance().LocateAsset("TEXTURE" + path);
+ if (!t) t = Generate();
+ t->LoadImage( path );
+}
+
bool Texture::m_initTextureSuccess = false;
unsigned short Texture::m_activeTextures = 0;
+
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2008-12-31 00:35:14 UTC (rev 122)
+++ Mercury2/src/Texture.h 2008-12-31 04:37:02 UTC (rev 123)
@@ -21,8 +21,11 @@
inline static unsigned short NumberActiveTextures() { return m_activeTextures; }
- static Texture* Generate() { return new Texture(); }
+ static Texture* Generate();
+ static Texture* LoadFromFile(const MString& path);
private:
+ void LoadImage(const MString& path);
+
void BindTexture();
void UnbindTexture();
@@ -32,6 +35,9 @@
static bool m_initTextureSuccess;
static unsigned short m_activeTextures;
+
+ MString m_filename;
+ bool m_isLoaded;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-31 00:35:23
|
Revision: 122
http://hgengine.svn.sourceforge.net/hgengine/?rev=122&view=rev
Author: cnlohr
Date: 2008-12-31 00:35:14 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
revert - use pngs and bmps
Modified Paths:
--------------
Mercury2/scenegraph.xml
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2008-12-31 00:30:44 UTC (rev 121)
+++ Mercury2/scenegraph.xml 2008-12-31 00:35:14 UTC (rev 122)
@@ -4,7 +4,7 @@
</node>
<node type="transformnode" movz="-3">
<node type="renderablenode">
- <asset type="texture" imagefile="test2.png"/>
+ <asset type="texture" imagefile="test.bmp"/>
<asset type="quad"/>
</node>
</node>
@@ -16,7 +16,7 @@
<node type="transformnode" movz="-3" movx="1" movy="-1">
<node type="renderablenode">
<asset type="texture" imagefile="test2.png"/>
- <asset type="texture" imagefile="test2.png"/>
+ <asset type="texture" imagefile="test.bmp"/>
<asset type="quad"/>
</node>
</node>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-31 00:30:53
|
Revision: 121
http://hgengine.svn.sourceforge.net/hgengine/?rev=121&view=rev
Author: cnlohr
Date: 2008-12-31 00:30:44 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
make Meshes use MercuryFile *'s
Modified Paths:
--------------
Mercury2/src/HGMDLMesh.cpp
Mercury2/src/HGMDLMesh.h
Mercury2/src/HGMDLModel.cpp
Mercury2/src/HGMDLModel.h
Modified: Mercury2/src/HGMDLMesh.cpp
===================================================================
--- Mercury2/src/HGMDLMesh.cpp 2008-12-31 00:12:56 UTC (rev 120)
+++ Mercury2/src/HGMDLMesh.cpp 2008-12-31 00:30:44 UTC (rev 121)
@@ -1,34 +1,41 @@
#include <HGMDLMesh.h>
-void HGMDLMesh::LoadFromFile(FILE* hgmdl)
+void HGMDLMesh::LoadFromFile(MercuryFile* hgmdl)
{
uint32_t nameLength;
- fread(&nameLength, sizeof(uint32_t), 1, hgmdl);
+ //fread(&nameLength, sizeof(uint32_t), 1, hgmdl);
+ hgmdl->Read( &nameLength, sizeof( uint32_t ) );
if (nameLength > 0)
{
char* name = new char[nameLength+1];
name[nameLength] = 0;
- fread(name, nameLength, 1, hgmdl);
+ hgmdl->Read( name, nameLength );
+ //fread(name, nameLength, 1, hgmdl);
m_name = name;
}
- fread(&m_cachable, sizeof(bool), 1, hgmdl);
+ hgmdl->Read( &m_cachable, sizeof( char ) );
+ //fread(&m_cachable, sizeof(bool), 1, hgmdl);
uint32_t dataLength;
- fread(&dataLength, sizeof(uint32_t), 1, hgmdl);
+ //fread(&dataLength, sizeof(uint32_t), 1, hgmdl);
+ hgmdl->Read( &dataLength, sizeof( uint32_t ) );
if (dataLength > 0)
{
m_vertexData.Allocate( dataLength/sizeof(float) ); //they are all floats
- fread(m_vertexData.Buffer(), dataLength, 1, hgmdl);
+ //fread(m_vertexData.Buffer(), dataLength, 1, hgmdl);
+ hgmdl->Read( m_vertexData.Buffer(), dataLength );
}
uint16_t numIndices;
- fread(&numIndices, sizeof(uint16_t), 1, hgmdl);
+ //fread(&numIndices, sizeof(uint16_t), 1, hgmdl);
+ hgmdl->Read( &numIndices, sizeof( uint16_t ) );
if (numIndices > 0)
{
m_indexData.Allocate( numIndices );
- fread(m_indexData.Buffer(), numIndices*sizeof(uint16_t), 1, hgmdl);
+ //fread(m_indexData.Buffer(), numIndices*sizeof(uint16_t), 1, hgmdl);
+ hgmdl->Read( m_indexData.Buffer(), numIndices*sizeof(uint16_t) );
}
}
Modified: Mercury2/src/HGMDLMesh.h
===================================================================
--- Mercury2/src/HGMDLMesh.h 2008-12-31 00:12:56 UTC (rev 120)
+++ Mercury2/src/HGMDLMesh.h 2008-12-31 00:30:44 UTC (rev 121)
@@ -2,11 +2,12 @@
#define HGMDLMESH_H
#include <MercuryVBO.h>
+#include <MercuryFile.h>
class HGMDLMesh : public MercuryVBO
{
public:
- void LoadFromFile(FILE* hgmdl);
+ void LoadFromFile(MercuryFile* hgmdl);
private:
MString m_name;
bool m_cachable;
Modified: Mercury2/src/HGMDLModel.cpp
===================================================================
--- Mercury2/src/HGMDLModel.cpp 2008-12-31 00:12:56 UTC (rev 120)
+++ Mercury2/src/HGMDLModel.cpp 2008-12-31 00:30:44 UTC (rev 121)
@@ -6,18 +6,25 @@
{
if ( !node.Attribute("file").empty() )
{
- FILE* f = fopen( node.Attribute("file").c_str(), "rb" );
+ //FILE* f = fopen( node.Attribute("file").c_str(), "rb" );
+ MercuryFile * f = FILEMAN.Open( node.Attribute("file") );
+ if( !f )
+ {
+ printf( "Could not open file: \"%s\" for model\n", node.Attribute("file").c_str() );
+ return;
+ }
LoadModel( f );
- fclose( f );
+ delete f;
}
}
-void HGMDLModel::LoadModel(FILE* hgmdl)
+void HGMDLModel::LoadModel(MercuryFile* hgmdl)
{
char fingerPrint[5];
fingerPrint[4] = 0;
- fread(fingerPrint, 4, 1, hgmdl);
+ hgmdl->Read( fingerPrint, 4 );
+
MString p(fingerPrint);
if (p != "MBMF")
{
@@ -26,7 +33,8 @@
}
uint32_t version;
- fread(&version, 4, 1, hgmdl);
+ //fread(&version, 4, 1, hgmdl);
+ hgmdl->Read( &version, 4 );
if (version != 200)
{
@@ -35,7 +43,8 @@
}
uint16_t numMeshes;
- fread(&numMeshes, sizeof(uint16_t), 1, hgmdl);
+
+ hgmdl->Read( &numMeshes, sizeof( uint16_t ) );
for (uint16_t i = 0; i < numMeshes; ++i)
{
MAutoPtr< HGMDLMesh > mesh( new HGMDLMesh() );
Modified: Mercury2/src/HGMDLModel.h
===================================================================
--- Mercury2/src/HGMDLModel.h 2008-12-31 00:12:56 UTC (rev 120)
+++ Mercury2/src/HGMDLModel.h 2008-12-31 00:30:44 UTC (rev 121)
@@ -3,6 +3,7 @@
#include <MercuryAsset.h>
#include <HGMDLMesh.h>
+#include <MercuryFile.h>
#include <vector>
@@ -12,7 +13,7 @@
virtual void LoadFromXML(const XMLNode& node);
- void LoadModel(FILE* hgmdl);
+ void LoadModel(MercuryFile* hgmdl);
static HGMDLModel* Generate();
virtual void Render(MercuryNode* node);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-31 00:12:59
|
Revision: 120
http://hgengine.svn.sourceforge.net/hgengine/?rev=120&view=rev
Author: cnlohr
Date: 2008-12-31 00:12:56 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
use MercuryFiles for images
Modified Paths:
--------------
Mercury2/scenegraph.xml
Mercury2/src/BMPLoader.cpp
Mercury2/src/ImageLoader.cpp
Mercury2/src/ImageLoader.h
Mercury2/src/MercuryUtil.cpp
Mercury2/src/PNGLoader.cpp
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2008-12-30 23:50:34 UTC (rev 119)
+++ Mercury2/scenegraph.xml 2008-12-31 00:12:56 UTC (rev 120)
@@ -4,7 +4,7 @@
</node>
<node type="transformnode" movz="-3">
<node type="renderablenode">
- <asset type="texture" imagefile="test.bmp"/>
+ <asset type="texture" imagefile="test2.png"/>
<asset type="quad"/>
</node>
</node>
@@ -16,7 +16,7 @@
<node type="transformnode" movz="-3" movx="1" movy="-1">
<node type="renderablenode">
<asset type="texture" imagefile="test2.png"/>
- <asset type="texture" imagefile="test.bmp"/>
+ <asset type="texture" imagefile="test2.png"/>
<asset type="quad"/>
</node>
</node>
Modified: Mercury2/src/BMPLoader.cpp
===================================================================
--- Mercury2/src/BMPLoader.cpp 2008-12-30 23:50:34 UTC (rev 119)
+++ Mercury2/src/BMPLoader.cpp 2008-12-31 00:12:56 UTC (rev 120)
@@ -4,7 +4,7 @@
using namespace std;
-RawImageData* LoadBMP( FILE* file )
+RawImageData* LoadBMP( MercuryFile * file )
{
int offset;
char* tmp = new char[sizeof(int)];
@@ -15,7 +15,6 @@
unsigned char b[3];
unsigned int res_x, res_y;
-// FILE* file = fopen(filename.c_str(), "rb");
printf( "BMP Load Start\n" );
if (file==NULL)
{
@@ -26,8 +25,8 @@
//Get the type of file and test
memset(tmp, 0, 4);
-// file->Read(tmp, sizeof(char) * 2);
- fread(tmp, sizeof(char) * 2, 1, file);
+ file->Read(tmp, sizeof(char) * 2);
+// fread(tmp, sizeof(char) * 2, 1, file);
MString type(tmp);
if (type != "BM")
@@ -37,33 +36,33 @@
return NULL;
}
//Offset of bitmap data.
- fseek(file, 10, SEEK_SET);
-// file->Seek(10);
- fread(tmp, 4, 1, file);
-// file->Read(tmp, 4);
+// fseek(file, 10, SEEK_SET);
+ file->Seek(10);
+// fread(tmp, 4, 1, file);
+ file->Read(tmp, 4);
memcpy(&offset, tmp, 4);
TO_ENDIAN( offset );
RawImageData* image = new RawImageData;
//width & width
- fseek(file, 18, SEEK_SET);
-// file->Seek(18);
- fread(tmp, sizeof(int), 1, file);
-// file->Read(tmp, sizeof(int));
+// fseek(file, 18, SEEK_SET);
+ file->Seek(18);
+// fread(tmp, sizeof(int), 1, file);
+ file->Read(tmp, sizeof(int));
memcpy(&image->m_width, tmp, sizeof(int));
TO_ENDIAN( image->m_width );
- fread(tmp, sizeof(int), 1, file);
-// file->Read(tmp, sizeof(int));
+// fread(tmp, sizeof(int), 1, file);
+ file->Read(tmp, sizeof(int));
memcpy(&image->m_height, tmp, sizeof(int));
TO_ENDIAN( image->m_height );
//bits per pixel
memset(tmp, 0, sizeof(int));
- fseek(file, 28, SEEK_SET);
-// file->Seek(28);
-// file->Read(tmp, sizeof(int));
- fread(tmp, sizeof(int), 1, file);
+// fseek(file, 28, SEEK_SET);
+ file->Seek(28);
+// fread(tmp, sizeof(int), 1, file);
+ file->Read(tmp, sizeof(int));
memcpy(&bitsapix, tmp, sizeof(int));
TO_ENDIAN( bitsapix );
@@ -76,10 +75,10 @@
}
//compression
-// file->Seek(30);
- fseek(file, 30, SEEK_SET);
-// file->Read(tmp, sizeof(int));
- fread(tmp, sizeof(int), 1, file);
+ file->Seek(30);
+// fseek(file, 30, SEEK_SET);
+ file->Read(tmp, sizeof(int));
+// fread(tmp, sizeof(int), 1, file);
memcpy(&compression, tmp, sizeof(int));
TO_ENDIAN(compression);
@@ -93,19 +92,19 @@
//pix/m X
memset(tmp, 0, sizeof(int));
-// file->Seek(38);
- fseek(file, 38, SEEK_SET);
-// file->Read(tmp, sizeof(int));
- fread(tmp, sizeof(int), 1, file);
+// fseek(file, 38, SEEK_SET);
+ file->Seek(38);
+// fread(tmp, sizeof(int), 1, file);
+ file->Read(tmp, sizeof(int));
memcpy(&res_x, tmp, sizeof(int));
TO_ENDIAN(res_x);
//pix/m Y
memset(tmp, 0, sizeof(int));
- fseek(file, 42, SEEK_SET);
-// file->Seek(42);
-// file->Read(tmp, sizeof(int));
- fread(tmp, sizeof(int), 1, file);
+// fseek(file, 42, SEEK_SET);
+ file->Seek(42);
+// fread(tmp, sizeof(int), 1, file);
+ file->Read(tmp, sizeof(int));
memcpy(&res_y, tmp, sizeof(int));
TO_ENDIAN(res_y);
@@ -120,9 +119,9 @@
}
//Get the file length
-// length = file->Length();
- fseek(file,0,SEEK_END);
- length = ftell(file);
+ length = file->Length();
+// fseek(file,0,SEEK_END);
+// length = ftell(file);
rawlength = (length) - (offset-1); //Remember to subtract 1 from the offset.
//Allocate space
@@ -132,19 +131,19 @@
memset(image->m_data, 0, rawlength);
//Get raw data and convert BGR->RGB
-// file->Seek(offset);
- fseek(file, offset, SEEK_SET);
+ file->Seek(offset);
+// fseek(file, offset, SEEK_SET);
image->m_ColorByteType = RGB;
unsigned long row, pixel;
unsigned char* rowPtr;
- for (unsigned int x = 0; !feof(file) && (x+3 < (unsigned)rawlength); x += 3)
+ for (unsigned int x = 0; !file->Eof() && (x+3 < (unsigned)rawlength); x += 3)
{
memset(b, 0, sizeof(unsigned char) * 3);
-// file->Read((char*)&b, sizeof(unsigned char) * 3);
- fread(&b, sizeof(unsigned char) * 3, 1, file);
+ file->Read((char*)&b, sizeof(unsigned char) * 3);
+// fread(&b, sizeof(unsigned char) * 3, 1, file);
row = image->m_height - (x/3)/image->m_width - 1; //current row
pixel = (x/3)%image->m_width; //which pixel in the row
Modified: Mercury2/src/ImageLoader.cpp
===================================================================
--- Mercury2/src/ImageLoader.cpp 2008-12-30 23:50:34 UTC (rev 119)
+++ Mercury2/src/ImageLoader.cpp 2008-12-31 00:12:56 UTC (rev 120)
@@ -11,35 +11,41 @@
return *instance;
}
-bool ImageLoader::RegisterFactoryCallback(const MString& type, Callback1R< FILE*, RawImageData* > functor)
+bool ImageLoader::RegisterFactoryCallback(const MString& type, Callback1R< MercuryFile*, RawImageData* > functor)
{
MString t = ToUpper( type );
- std::pair<MString, Callback1R< FILE*, RawImageData* > > pp(t, functor);
+ std::pair<MString, Callback1R< MercuryFile*, RawImageData* > > pp(t, functor);
m_factoryCallbacks.push_back( pp );
return true;
}
RawImageData* ImageLoader::LoadImage(const MString& filename)
{
- FILE* f = fopen(filename.c_str(), "rb");
+ MercuryFile* f = FILEMAN.Open( filename );
char fingerprint[4];
fingerprint[3] = 0;
+
+ if( !f )
+ {
+ printf( "Error opening image: %s\n", filename.c_str() );
+ return 0;
+ }
+
+ f->Read( fingerprint, 3 );
+ f->Seek( 0 );
- fread(fingerprint, sizeof(char)*3, 1, f);
- fseek(f, 0, SEEK_SET);
-
MString t(fingerprint);// = ToUpper( type );
- std::list< std::pair< MString, Callback1R< FILE*, RawImageData* > > >::iterator i;
+ std::list< std::pair< MString, Callback1R< MercuryFile*, RawImageData* > > >::iterator i;
for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i)
{
if (i->first == t)
{
RawImageData* d = i->second(f);
- fclose(f);
+ delete f;
return d;
}
}
- fclose(f);
+ delete f;
return NULL;
}
Modified: Mercury2/src/ImageLoader.h
===================================================================
--- Mercury2/src/ImageLoader.h 2008-12-30 23:50:34 UTC (rev 119)
+++ Mercury2/src/ImageLoader.h 2008-12-31 00:12:56 UTC (rev 120)
@@ -2,6 +2,7 @@
#define IMAGELOADER_H
#include <RawImageData.h>
+#include <MercuryFile.h>
#include <Callback.h>
#include <list>
#include <MercuryUtil.h>
@@ -10,17 +11,17 @@
{
public:
static ImageLoader& GetInstance();
- bool RegisterFactoryCallback(const MString& type, Callback1R< FILE*, RawImageData* >);
+ bool RegisterFactoryCallback(const MString& type, Callback1R< MercuryFile *, RawImageData* >);
RawImageData* LoadImage(const MString& filename);
private:
- std::list< std::pair< MString, Callback1R< FILE*, RawImageData* > > > m_factoryCallbacks;
+ std::list< std::pair< MString, Callback1R< MercuryFile*, RawImageData* > > > m_factoryCallbacks;
};
static InstanceCounter<ImageLoader> ILcounter("ImageLoader");
#define REGISTER_IMAGE_TYPE(fingerprint,functor)\
- Callback1R< FILE*, RawImageData* > factoryclbk##functor( functor ); \
+ Callback1R< MercuryFile*, RawImageData* > factoryclbk##functor( functor ); \
bool GlobalImageRegisterSuccess##functor = ImageLoader::GetInstance().RegisterFactoryCallback(#fingerprint, factoryclbk##functor);
Modified: Mercury2/src/MercuryUtil.cpp
===================================================================
--- Mercury2/src/MercuryUtil.cpp 2008-12-30 23:50:34 UTC (rev 119)
+++ Mercury2/src/MercuryUtil.cpp 2008-12-31 00:12:56 UTC (rev 120)
@@ -58,11 +58,14 @@
if( !data )
{
data = 0;
+ delete f;
return -1;
}
int r = f->Read( data, length );
+ delete f;
+
if( r != length )
{
free( data );
Modified: Mercury2/src/PNGLoader.cpp
===================================================================
--- Mercury2/src/PNGLoader.cpp 2008-12-30 23:50:34 UTC (rev 119)
+++ Mercury2/src/PNGLoader.cpp 2008-12-31 00:12:56 UTC (rev 120)
@@ -6,10 +6,10 @@
void PNGRead( png_struct *png, png_byte *p, png_size_t size )
{
- FILE* f = (FILE*)png->io_ptr;
+ MercuryFile * f = (MercuryFile*)png->io_ptr;
-// int got = f->Read( p, size );
- int got = fread(p, size, 1, f );
+ int got = f->Read( p, size );
+// int got = fread(p, size, 1, f );
if( got == -1 )
png_error( png, "Error reading from file");
@@ -17,7 +17,7 @@
// png_error( png, "Unexpected EOF" );
}
-RawImageData* LoadPNG( FILE * fp )
+RawImageData* LoadPNG( MercuryFile * fp )
{
png_structp png_ptr;
png_infop info_ptr;
@@ -31,8 +31,8 @@
//open file and test for it being a png
if (!fp)
assert("[read_png_file] File %s could not be opened for reading");
-// fp->Read(header, 8 );
- fread(header, 8, 1, fp);
+ fp->Read(header, 8 );
+// fread(header, 8, 1, fp);
if (png_sig_cmp(header, 0, 8))
assert("[read_png_file] File %s is not recognized as a PNG file");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 23:50:48
|
Revision: 119
http://hgengine.svn.sourceforge.net/hgengine/?rev=119&view=rev
Author: cnlohr
Date: 2008-12-30 23:50:34 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
make the XML Parser use MercuryFiles
Modified Paths:
--------------
Mercury2/src/XMLParser.cpp
Modified: Mercury2/src/XMLParser.cpp
===================================================================
--- Mercury2/src/XMLParser.cpp 2008-12-30 23:50:17 UTC (rev 118)
+++ Mercury2/src/XMLParser.cpp 2008-12-30 23:50:34 UTC (rev 119)
@@ -1,4 +1,6 @@
#include <XMLParser.h>
+#include <MercuryFile.h>
+
#include <libxml/parser.h>
#include <libxml/tree.h>
@@ -96,8 +98,24 @@
XMLDocument* xmldoc = new XMLDocument();
xmlInitParser(); //XXX WTF am I supposed to do with this
- xmldoc->m_doc = xmlReadFile(file.c_str(), NULL, 0);
-
+
+ char * doc;
+
+ int ret = FileToString( file, doc );
+
+ if( ret == -1 ) //File error
+ {
+ printf( "Warning: Could not open XML File: \"%s\".\n", file.c_str() );
+ return xmldoc;
+ }
+
+ if( (xmldoc->m_doc = xmlReadMemory( doc, ret, NULL, NULL, 0) ) == 0 )
+ {
+ printf( "Warning: Could not parse XML File: \"%s\".\n", file.c_str() );
+ }
+
+ free( doc );
+
return xmldoc;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 23:50:20
|
Revision: 118
http://hgengine.svn.sourceforge.net/hgengine/?rev=118&view=rev
Author: cnlohr
Date: 2008-12-30 23:50:17 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
add utility function to dump a file to a buffer
Modified Paths:
--------------
Mercury2/src/MercuryUtil.cpp
Mercury2/src/MercuryUtil.h
Modified: Mercury2/src/MercuryUtil.cpp
===================================================================
--- Mercury2/src/MercuryUtil.cpp 2008-12-30 23:46:54 UTC (rev 117)
+++ Mercury2/src/MercuryUtil.cpp 2008-12-30 23:50:17 UTC (rev 118)
@@ -1,4 +1,5 @@
#include <MercuryUtil.h>
+#include <MercuryFile.h>
#include <stdint.h>
#ifndef WIN32
@@ -43,6 +44,36 @@
}
+long FileToString( const MString & sFileName, char * & data )
+{
+ data = 0;
+
+ MercuryFile * f = FILEMAN.Open( sFileName );
+ if( !f ) return -1;
+
+ int length = f->Length();
+
+ data = (char*)malloc( length + 1 );
+
+ if( !data )
+ {
+ data = 0;
+ return -1;
+ }
+
+ int r = f->Read( data, length );
+
+ if( r != length )
+ {
+ free( data );
+ data = 0;
+ return -1;
+ }
+
+ return length;
+}
+
+
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/MercuryUtil.h
===================================================================
--- Mercury2/src/MercuryUtil.h 2008-12-30 23:46:54 UTC (rev 117)
+++ Mercury2/src/MercuryUtil.h 2008-12-30 23:50:17 UTC (rev 118)
@@ -67,6 +67,10 @@
template<typename T>
unsigned long InstanceCounter<T>::m_count = 0;
+///Open up filename: sFileName and dump it into a new buffer; you must delete the return value when done.
+///The return value is -1 if there was an issue, otherwise it is valid.
+long FileToString( const MString & sFileName, char * & data );
+
#endif
/* Copyright (c) 2008, Joshua Allen
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 23:47:04
|
Revision: 117
http://hgengine.svn.sourceforge.net/hgengine/?rev=117&view=rev
Author: axlecrusher
Date: 2008-12-30 23:46:54 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
comment the lines for using threads
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2008-12-30 23:26:56 UTC (rev 116)
+++ Mercury2/src/Mercury2.cpp 2008-12-30 23:46:54 UTC (rev 117)
@@ -37,7 +37,6 @@
int main()
{
unsigned long m_count = 0;
-// long m_time;
cnset_execute_on_crash( SignalHandler );
@@ -50,19 +49,18 @@
root->LoadFromXML( r );
SAFE_DELETE(doc);
-
-// MercuryThread updateThread;
-
-// m_time = time(NULL);
+
uint64_t oTime = GetTimeInMicroSeconds();
uint64_t m_time = oTime;
+ //uncomment the next 2 lines to use threads
+// MercuryThread updateThread;
// updateThread.Create( UpdateThread, root, false);
+
do
{
uint64_t curTime = GetTimeInMicroSeconds();
- root->RecursiveUpdate((curTime-oTime)/1000000.0f);
-// updateThread.Create( UpdateThread, root, false);
+ root->RecursiveUpdate((curTime-oTime)/1000000.0f); //comment to use threads
RenderableNode::RecursiveRender(root);
w->SwapBuffers();
++m_count;
@@ -79,6 +77,7 @@
}
while ( w->PumpMessages() );
+ //uncomment the next 2 lines to use threads
// UpdateLoopGo.Increment();
// updateThread.Wait();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 23:27:00
|
Revision: 116
http://hgengine.svn.sourceforge.net/hgengine/?rev=116&view=rev
Author: cnlohr
Date: 2008-12-30 23:26:56 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
add Mercury files (not net)
Modified Paths:
--------------
Mercury2/adv_set.c
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2008-12-30 23:26:25 UTC (rev 115)
+++ Mercury2/adv_set.c 2008-12-30 23:26:56 UTC (rev 116)
@@ -8,8 +8,16 @@
src/TransformNode.cpp src/MercuryMatrix.cpp src/Viewport.cpp src/Quad.cpp src/MercuryUtil.cpp \
src/Texture.cpp src/RawImageData.cpp src/BMPLoader.cpp src/PNGLoader.cpp src/ImageLoader.cpp \
src/MercuryVBO.cpp src/MSemaphore.cpp src/UpdateThreader.cpp src/HGMDLMesh.cpp \
- src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c"
+ src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c \
+ src/MercuryFile.cpp"
+
+SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
+ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
+
+//Not implemented yet, since we don't have ezsocekts
+//src/MercuryFileDriverNet.cpp
+
#ifdef USE_LIBXML
SOURCES="$SOURCES src/XMLParser.cpp"
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 22:35:32
|
Revision: 114
http://hgengine.svn.sourceforge.net/hgengine/?rev=114&view=rev
Author: axlecrusher
Date: 2008-12-30 22:35:28 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
use microseconds
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryUtil.cpp
Mercury2/src/MercuryUtil.h
Mercury2/src/TransformNode.cpp
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2008-12-30 22:10:30 UTC (rev 113)
+++ Mercury2/src/Mercury2.cpp 2008-12-30 22:35:28 UTC (rev 114)
@@ -8,6 +8,8 @@
#include <RenderableNode.h>
+#include <sys/time.h>
+
#include <MercuryCrash.h>
#include <MercuryBacktrace.h>
@@ -35,7 +37,7 @@
int main()
{
unsigned long m_count = 0;
- long m_time;
+// long m_time;
cnset_execute_on_crash( SignalHandler );
@@ -51,22 +53,29 @@
// MercuryThread updateThread;
- m_time = time(NULL);
+// m_time = time(NULL);
+ uint64_t oTime = GetTimeInMicroSeconds();
+ uint64_t m_time = oTime;
+
// updateThread.Create( UpdateThread, root, false);
do
{
- root->RecursiveUpdate(0.01f);
+ uint64_t curTime = GetTimeInMicroSeconds();
+ root->RecursiveUpdate((curTime-oTime)/1000000.0f);
// updateThread.Create( UpdateThread, root, false);
RenderableNode::RecursiveRender(root);
w->SwapBuffers();
++m_count;
- if (time(NULL) > m_time)
+ float seconds = (curTime-m_time)/1000000.0f;
+ if (seconds > 1)
{
- m_time = time(NULL);
- printf("FPS: %lu\n", m_count);
+ m_time = curTime;
+ printf("FPS: %f\n", m_count/seconds);
m_count = 0;
}
+
+ oTime = curTime;
}
while ( w->PumpMessages() );
@@ -109,3 +118,4 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
Modified: Mercury2/src/MercuryUtil.cpp
===================================================================
--- Mercury2/src/MercuryUtil.cpp 2008-12-30 22:10:30 UTC (rev 113)
+++ Mercury2/src/MercuryUtil.cpp 2008-12-30 22:35:28 UTC (rev 114)
@@ -1,6 +1,12 @@
#include <MercuryUtil.h>
#include <stdint.h>
+#ifndef WIN32
+#include <sys/time.h>
+#else
+#include <windows.h>
+#endif
+
MString ToUpper(const MString& s)
{
MString t = s;
@@ -28,6 +34,15 @@
return ptr;
}
+int64_t GetTimeInMicroSeconds()
+{
+ struct timeval tv;
+ gettimeofday( &tv, 0 );
+
+ return (int64_t(tv.tv_sec) * 1000000) + tv.tv_usec;
+
+}
+
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/MercuryUtil.h
===================================================================
--- Mercury2/src/MercuryUtil.h 2008-12-30 22:10:30 UTC (rev 113)
+++ Mercury2/src/MercuryUtil.h 2008-12-30 22:35:28 UTC (rev 114)
@@ -17,6 +17,8 @@
//returns an aligned pointer, mem is the actual (unaligned) pointer for freeing
void* mmemalign(size_t align, size_t size, void*& mem);
+int64_t GetTimeInMicroSeconds();
+
#if defined(__GNUC__)
#define M_ALIGN(n) __attribute__((aligned(n)))
//#define MMALLOC(n) memalign(32, n)
Modified: Mercury2/src/TransformNode.cpp
===================================================================
--- Mercury2/src/TransformNode.cpp 2008-12-30 22:10:30 UTC (rev 113)
+++ Mercury2/src/TransformNode.cpp 2008-12-30 22:35:28 UTC (rev 114)
@@ -147,8 +147,8 @@
void RotatorNode::Update(float dTime)
{
MercuryPoint r = GetRotation();
- r.x += (dTime)*2.5;
- r.y += (dTime)*5;
+ r.x += (dTime)*25;
+ r.y += (dTime)*75;
SetRotation( r );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 22:22:19
|
Revision: 112
http://hgengine.svn.sourceforge.net/hgengine/?rev=112&view=rev
Author: cnlohr
Date: 2008-12-30 21:37:42 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
fix warnings in GCC
Modified Paths:
--------------
Mercury2/src/AlignedBuffer.h
Modified: Mercury2/src/AlignedBuffer.h
===================================================================
--- Mercury2/src/AlignedBuffer.h 2008-12-30 21:37:18 UTC (rev 111)
+++ Mercury2/src/AlignedBuffer.h 2008-12-30 21:37:42 UTC (rev 112)
@@ -17,7 +17,9 @@
void Allocate(unsigned long count)
{
SAFE_FREE(m_mem);
- m_data = (T*)mmemalign(32, sizeof(T)*count, (void*&)m_mem);
+ void * m_memret;
+ m_data = (T*)mmemalign(32, sizeof(T)*count, m_memret);
+ m_mem = (T*)m_memret;
m_length = count;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 22:22:16
|
Revision: 111
http://hgengine.svn.sourceforge.net/hgengine/?rev=111&view=rev
Author: cnlohr
Date: 2008-12-30 21:37:18 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
fix library definition bit
Modified Paths:
--------------
Mercury2/cnconfigure
Modified: Mercury2/cnconfigure
===================================================================
--- Mercury2/cnconfigure 2008-12-30 21:26:46 UTC (rev 110)
+++ Mercury2/cnconfigure 2008-12-30 21:37:18 UTC (rev 111)
@@ -197,10 +197,12 @@
echo -e "help : " >> Makefile
echo -e " echo \"Available: <\$(PROJ)> <clean> <library> <help>\"" >> Makefile
if test `uname -s` == "Darwin" ; then
- echo -e "library : \$(OBJ)" >> Makefile
+ echo -e "library : \$(PROJ).dylib" >> Makefile
+ echo -e "\$(PROJ).dylib : \$(OBJ)" >> Makefile
echo -e "\tg++ -dynamiclib -o \$(PROJ).dylib \$^ \$(LDFLAGS)" >> Makefile
else
- echo -e "library : \$(OBJ)" >> Makefile
+ echo -e "library : \$(PROJ).so" >> Makefile
+ echo -e "\$(PROJ).so : \$(OBJ)" >> Makefile
echo -e "\tg++ -shared -o \$(PROJ).so \$^ \$(LDFLAGS)" >> Makefile
fi
echo "" >> Makefile
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 22:10:33
|
Revision: 113
http://hgengine.svn.sourceforge.net/hgengine/?rev=113&view=rev
Author: cnlohr
Date: 2008-12-30 22:10:30 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
crash handler
Modified Paths:
--------------
Mercury2/adv_set.c
Mercury2/src/Mercury2.cpp
Added Paths:
-----------
Mercury2/src/MercuryBacktrace.c
Mercury2/src/MercuryBacktrace.h
Mercury2/src/MercuryCrash.c
Mercury2/src/MercuryCrash.h
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2008-12-30 21:37:42 UTC (rev 112)
+++ Mercury2/adv_set.c 2008-12-30 22:10:30 UTC (rev 113)
@@ -3,17 +3,12 @@
FOLDERS="src"
-SOURCES="src/Mercury2.cpp src/MercuryAsset.cpp \
- src/MercuryNode.cpp src/MercuryPoint.cpp \
- src/MercuryThreads.cpp src/MercuryMath.cpp \
- src/MercuryWindow.cpp src/RenderableNode.cpp \
- src/TransformNode.cpp src/MercuryMatrix.cpp \
- src/Viewport.cpp src/Quad.cpp src/MercuryUtil.cpp \
- src/Texture.cpp src/RawImageData.cpp src/BMPLoader.cpp \
- src/PNGLoader.cpp src/ImageLoader.cpp \
- src/MercuryVBO.cpp src/MSemaphore.cpp \
- src/UpdateThreader.cpp src/HGMDLMesh.cpp \
- src/HGMDLModel.cpp src/MercuryString.cpp"
+SOURCES="src/Mercury2.cpp src/MercuryAsset.cpp src/MercuryNode.cpp src/MercuryPoint.cpp \
+ src/MercuryThreads.cpp src/MercuryMath.cpp src/MercuryWindow.cpp src/RenderableNode.cpp \
+ src/TransformNode.cpp src/MercuryMatrix.cpp src/Viewport.cpp src/Quad.cpp src/MercuryUtil.cpp \
+ src/Texture.cpp src/RawImageData.cpp src/BMPLoader.cpp src/PNGLoader.cpp src/ImageLoader.cpp \
+ src/MercuryVBO.cpp src/MSemaphore.cpp src/UpdateThreader.cpp src/HGMDLMesh.cpp \
+ src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c"
#ifdef USE_LIBXML
SOURCES="$SOURCES src/XMLParser.cpp"
@@ -24,8 +19,8 @@
#endif
PROJ="mercury"
-CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc"
-LDFLAGS="$LDFLAGS -rdynamic -g -fPIC"
+CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc -g "
+LDFLAGS="$LDFLAGS -rdynamic -g -fPIC "
/*
* (c) 2007-2008 Charles Lohr
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2008-12-30 21:37:42 UTC (rev 112)
+++ Mercury2/src/Mercury2.cpp 2008-12-30 22:10:30 UTC (rev 113)
@@ -8,6 +8,9 @@
#include <RenderableNode.h>
+#include <MercuryCrash.h>
+#include <MercuryBacktrace.h>
+
MSemaphore UpdateLoopGo;
void* UpdateThread(void* node)
{
@@ -19,11 +22,23 @@
return NULL;
}
+int SignalHandler( int signal )
+{
+ char buffer[2048];
+ printf( "Fatal error encountered in Mercury 2: %s\n", cn_get_crash_description( signal ) );
+ cnget_backtrace( 1, buffer, 2047 );
+ printf( "%s\n", buffer );
+
+ return 0; //Continue regular crash.
+}
+
int main()
{
unsigned long m_count = 0;
long m_time;
-
+
+ cnset_execute_on_crash( SignalHandler );
+
MercuryWindow* w = MercuryWindow::MakeWindow();
MercuryNode* root = new MercuryNode();
Added: Mercury2/src/MercuryBacktrace.c
===================================================================
--- Mercury2/src/MercuryBacktrace.c (rev 0)
+++ Mercury2/src/MercuryBacktrace.c 2008-12-30 22:10:30 UTC (rev 113)
@@ -0,0 +1,611 @@
+#include "MercuryBacktrace.h"
+
+
+#ifdef WIN32
+#define _CWINDOWS
+#else
+#if defined( MACOSX ) || defined( __APPLE__ )
+#define _CMAC
+#else
+#define _CLINUX
+#endif
+#endif
+
+
+
+#if defined ( _CWINDOWS )
+#define CPU_X86
+#include <windows.h>
+#include <dbghelp.h>
+#pragma comment( lib, "dbghelp.lib" )
+/*Since we have inline code in windows, there are
+ warnings associated with disabling optimization,
+ ignore them. */
+#pragma warning( disable : 4748)
+/*Ignore CRT_SECURE_NO_DEPRECIATE for snprintf */
+#pragma warning( disable : 4996)
+#elif defined( _CMAC ) || defined( _CLINUX )
+
+#ifdef _CLINUX
+#include <malloc.h>
+#include <execinfo.h>
+#define HAVE_EXECINFO
+#endif
+
+
+#ifdef HAVE_LIBIBERTY
+
+/*Ok, even StepMania had this question!:
+ This is in libiberty. Where is it declared? */
+#ifdef __cplusplus
+extern "C" {
+#endif
+char *cplus_demangle (const char *mangled, int options);
+#ifdef __cplusplus
+};
+#endif
+#endif
+
+#if !defined( __USE_GNU ) && !defined( _CMAC )
+
+typedef struct
+{
+ __const char *dli_fname; /* File name of defining object. */
+ void *dli_fbase; /* Load address of that object. */
+ __const char *dli_sname; /* Name of nearest symbol. */
+ void *dli_saddr; /* Exact value of nearest symbol. */
+} Dl_info;
+
+extern int dladdr (__const void *__address, Dl_info *__info);
+extern void *dlopen (__const char *__file, int __mode);
+extern int dlclose (void *__handle);
+extern void *dlsym (void *__restrict __handle,
+ __const char *__restrict __name);
+
+#endif
+
+#include <dlfcn.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+int bUseAddr2Line, DBGSetup = 0;
+
+#endif
+
+
+
+
+struct BacktraceContext
+{
+ int dummy;
+#if defined( _CWINDOWS)
+ CONTEXT context;
+ HANDLE hThread;
+ HANDLE hProcess;
+#endif
+};
+
+#include <stdio.h>
+
+int GetBacktrace( void **buf, unsigned size, struct BacktraceContext *ctx );
+int GetBTName( const void * ptr, char * str, int maxlen, struct BacktraceContext * ctx );
+void SetupDBGHelp();
+
+
+int cnget_backtrace( int SkipFirst, char * buffer, int max_size )
+{
+ char * tmpbuf = buffer;
+
+ void * buf[256];
+ int i = 0;
+ SetupDBGHelp();
+ GetBacktrace( (void **)buf, 256, 0 );
+
+ for( ; i < SkipFirst; i++ )
+ if( buf[i] == 0 )
+ return 0;
+
+ while( buf[i] != 0 )
+ {
+ int space_left = max_size-(int)(tmpbuf-buffer)-2;
+ tmpbuf+=GetBTName( buf[i], tmpbuf, space_left, 0 );
+ *tmpbuf='\n';
+ tmpbuf++;
+ *tmpbuf='\0';
+ i++;
+ }
+
+ return i-1;
+}
+
+
+
+
+
+
+
+#if defined( _CMAC ) || defined( _CLINUX )
+//Based off of http://stackoverflow.com/questions/289820/getting-the-current-stack-trace-on-mac-os-x
+
+int GetBacktrace( void **buffer, unsigned size, struct BacktraceContext *ctx )
+{
+#ifdef HAVE_EXECINFO
+ return backtrace( buffer, size );
+#else
+ //Todo: See if the return is beyond the end of a function.
+
+ void **frame = (void **)__builtin_frame_address(0);
+ void **bp = ( void **)(*frame);
+ void *ip = frame[1];
+ int i;
+
+ for ( i = 0; bp && ip && i < size; i++ )
+ {
+ *(buffer++) = ip;
+ ip = bp[1];
+ bp = (void**)(bp[0]);
+ }
+
+ return i;
+#endif
+}
+
+int Demangle( char * out, int maxlen, const char * in )
+{
+ *out = 0;
+ if( !in )
+ return 0;
+#ifdef HAVE_LIBIBERTY
+ int pos = 0;
+ char * demangled = cplus_demangle( in, 0 );
+ if( !demangled )
+ return 0;
+ while( demangled[pos] != 0 && pos + 1 < maxlen )
+ {
+ out[pos] = demangled[pos];
+ pos++;
+ }
+ out[pos] = 0;
+ free( demangled );
+ return pos;
+#else
+ return 0;
+#endif
+}
+
+
+int Addr2Line( char * out, char * demangled, int maxlen, const char * file, const void * offset )
+{
+ int tmp;
+ char execline[1024];
+ char buffer[1024];
+ int fds[2];
+ int readbytes;
+ int newlinepos;
+ int slashpos;
+
+ *out = 0;
+ *demangled = 0;
+
+ if( strlen( file ) < 1 )
+ return 0;
+
+ tmp = open( file, O_RDONLY );
+ if( !tmp )
+ return 0;
+ close( tmp );
+
+ if( pipe( fds ) != 0 )
+ return 0;
+
+#ifdef _CMAC
+ sprintf( execline, "atos -o %s 0x%lx 1>&%d", file, (unsigned long)offset, fds[1] );
+ printf( "Crash Progress: Executing command: %s\n", execline );
+#else
+ sprintf( execline, "addr2line -fC -e %s 0x%lx 1>&%d", file, (unsigned long)offset, fds[1] );
+#endif
+ system( execline );
+
+ readbytes = read( fds[0], buffer, 1024 );
+ if( readbytes + 1 >= maxlen )
+ readbytes = maxlen - 1;
+ close( fds[0] );
+ close( fds[1] );
+
+ //Something went wrong.
+ if( readbytes < 3 )
+ return 0;
+#ifdef _CMAC
+ memcpy( out, buffer, readbytes - 1 );
+ out[readbytes] = 0;
+ return 1;
+#else
+ //??:0 is a bad return value.
+ if( buffer[0] == '?' )
+ return 0;
+
+ if( strstr( buffer, ": No such file" ) > 0 )
+ return 0;
+
+ newlinepos = 0;
+ for( tmp = 0; tmp < readbytes; tmp++ )
+ if( buffer[tmp] == '\n' ) break;
+ newlinepos = tmp;
+
+ if( tmp == readbytes )
+ return 0;
+
+ memcpy( demangled, buffer, newlinepos );
+ demangled[newlinepos] = 0;
+
+ slashpos = 0;
+ for( tmp = newlinepos; tmp < readbytes; tmp++ )
+ {
+ if( buffer[tmp] == '/' ) slashpos = tmp;
+ }
+
+ if( slashpos == 0 )
+ slashpos = newlinepos;
+ slashpos++;
+ if( slashpos >= readbytes )
+ slashpos = 0;
+
+ readbytes -= slashpos;
+ memcpy( out, buffer + slashpos, readbytes );
+
+ if( readbytes > 1 )
+ out[readbytes-1] = 0;
+ else
+ out[readbytes] = 0;
+
+ return readbytes;
+#endif
+
+}
+
+
+int GetBTName( const void * ptr, char * str, int maxlen, struct BacktraceContext * ctx )
+{
+ char demangled[1024], floc[1024];
+ const char * symbol;
+ Dl_info dli;
+ int c = 0;
+ int useaddr=0;
+
+ c = snprintf(str, maxlen, " [%0*lx]", (int)sizeof(void*)*2, (long unsigned int)ptr );
+
+ if (dladdr(ptr, &dli))
+ {
+ unsigned offset;
+ symbol = dli.dli_sname;
+
+ if( dli.dli_fbase && dli.dli_fname )
+ {
+ if( bUseAddr2Line )
+ {
+ unsigned long actualptr = (unsigned long)ptr;
+ int fnamelen = strlen( dli.dli_fname );
+
+ //If it's a .so, we need ot check relatively to the start of the .so
+ //since it was compiled with -fPIC
+
+ if( dli.dli_fname[fnamelen-3] == '.' &&
+ dli.dli_fname[fnamelen-2] == 's' &&
+ dli.dli_fname[fnamelen-1] == 'o' )
+ {
+ actualptr-=(unsigned long)dli.dli_fbase;
+ }
+
+ if( Addr2Line( floc, demangled, 1024, dli.dli_fname, (void*)actualptr ) )
+ {
+ symbol = demangled;
+ useaddr=1;
+ }
+ }
+ }
+
+ //If addr2line doesn't work right, we can try using demangle from libiberty
+ if( !useaddr )
+ if( Demangle( demangled, 1024, symbol ) )
+ symbol = demangled;
+
+ if( symbol )
+ {
+ offset = ptr - dli.dli_saddr;
+ c += snprintf(str+c, maxlen-c, " (%s+0x%x (0x%lx))", symbol, offset,(unsigned long)dli.dli_saddr );
+ }
+ if( dli.dli_fbase && dli.dli_fname )
+ {
+ if( useaddr )
+ c += snprintf(str+c, maxlen-c, " [%s]", floc );
+ else
+ c += snprintf(str+c, maxlen-c, " [%s+0x%lx]", dli.dli_fname, (unsigned long)dli.dli_fbase );
+ }
+ }
+ return c;
+}
+
+void SetupDBGHelp()
+{
+ int fds[2];
+ char execline[1024];
+ if( DBGSetup )
+ return;
+ DBGSetup = 1;
+ pipe( fds );
+
+#ifdef _CMAC
+ sprintf( execline, "atos 2>&%d", fds[0] );
+#else
+ sprintf( execline, "addr2line -v 1>&%d", fds[0] );
+#endif
+
+ if( system( execline ) == 0 )
+ bUseAddr2Line = 1;
+ else
+ bUseAddr2Line = 0;
+ close( fds[0] );
+ close( fds[1] );
+}
+
+
+#elif defined( _CWINDOWS )
+
+int wGetCurrentContext( struct BacktraceContext *CTX )
+{
+ CTX->context.ContextFlags = CONTEXT_CONTROL;
+ CTX->hThread = GetCurrentThread();
+ CTX->hProcess = GetCurrentProcess();
+#ifdef CPU_X86
+ //no way to do it except in ASM, see below.
+#else
+ if( !RtlCaptureContext( &CTX->context ) )
+ {
+ printf( "Could not launch context helper.\n" );
+ return -1;
+ }
+#endif
+ return 0;
+}
+
+int GetBacktrace( void **buf, size_t size, struct BacktraceContext *CTX )
+{
+ const void **pLast = buf + size - 1;
+ int bFirst = 1;
+ DWORD MachineType;
+ CONTEXT * pContext;
+ HANDLE hThread;
+ HANDLE hProcess;
+ struct BacktraceContext MCTX; //in case we don't have a context.
+ int ActuallyThisThread = 0;
+ if( CTX == 0 )
+ {
+ if( wGetCurrentContext( &MCTX ) != 0)
+ return -2;
+ pContext = &(MCTX.context);
+ hThread = MCTX.hThread;
+ hProcess = MCTX.hProcess;
+ ActuallyThisThread = 1;
+ }
+ else
+ {
+ pContext = &(CTX->context);
+ hThread = CTX->hThread;
+ hProcess = CTX->hProcess;
+ }
+
+ {
+ size_t count = 0;
+ STACKFRAME64 sf64;
+
+#ifdef CPU_X86
+ CONTEXT Context;
+ MachineType = IMAGE_FILE_MACHINE_I386;
+
+ if( ActuallyThisThread )
+ {
+ ZeroMemory( &Context, sizeof( CONTEXT ) );
+
+ //http://jpassing.wordpress.com/2008/03/12/walking-the-stack-of-the-current-thread/
+ __asm
+ {
+ Label:
+ mov [Context.Ebp], ebp;
+ mov [Context.Esp], esp;
+ mov eax, [Label];
+ mov [Context.Eip], eax;
+ }
+ Context.ContextFlags = CONTEXT_CONTROL;
+ pContext = &Context;
+ }
+
+ memset( &sf64, '\0', sizeof sf64 );
+ sf64.AddrPC.Offset = Context.Eip;
+ sf64.AddrPC.Mode = AddrModeFlat;
+ sf64.AddrFrame.Offset = Context.Ebp;
+ sf64.AddrFrame.Mode = AddrModeFlat;
+ sf64.AddrStack.Offset = Context.Esp;
+ sf64.AddrStack.Segment = AddrModeFlat;
+#else
+ MachineType = IMAGE_FILE_MACHINE_AMD64;
+ memset( &sf64, '\0', sizeof sf64 );
+ sf64.AddrPC.Offset = Context.Rip;
+ sf64.AddrPC.Mode = AddrModeFlat;
+ sf64.AddrFrame.Offset = Context.Rsp;
+ sf64.AddrFrame.Mode = AddrModeFlat;
+ sf64.AddrStack.Offset = Context.Rsp;
+ sf64.AddrStack.Segment = AddrModeFlat;
+#endif
+ while( 1 )
+ {
+ int ret;
+ SetLastError( 0 );
+ ret = StackWalk64( MachineType, hProcess, hThread, &sf64, pContext, 0,
+ SymFunctionTableAccess64, SymGetModuleBase64, 0 );
+
+ if( !ret )
+ {
+ break;
+ }
+
+ if( sf64.AddrPC.Offset != 0)
+ *buf = (void*)sf64.AddrPC.Offset;
+ else
+ *buf = (void*)-1;
+ buf++;
+ count++;
+ if( count + 1 >= size ) break;
+ }
+ }
+ SetLastError( 0 );
+ *buf = 0;
+
+ return 0;
+}
+
+int GetBTName( const void * ptr, char * str, int maxlen, struct BacktraceContext * ctx )
+{
+ char lsymbol[1024], lfile[1024];
+ IMAGEHLP_LINE64 Line;
+ PSYMBOL_INFO Symbol;
+ HANDLE hProcess;
+ int i, pwd = 0;
+
+ Symbol = malloc( sizeof( SYMBOL_INFO ) + 501 );
+ Line.SizeOfStruct = sizeof( IMAGEHLP_LINE64 );
+
+ Symbol->MaxNameLen = 500;
+
+ if( ctx )
+ hProcess = ctx->hProcess;
+ else
+ hProcess = GetCurrentProcess();
+
+ i = SymFromAddr( hProcess, (DWORD64)ptr, 0, Symbol );
+ if( !i )
+ {
+ return _snprintf( str, maxlen, "%p (unknown)", ptr );
+ }
+ i = SymGetLineFromAddr64( hProcess, (DWORD64)ptr, &pwd, &Line );
+
+ if( i == 0)
+ {
+ Line.FileName = 0;
+ Line.LineNumber = 0;
+ }
+
+ for( i = 0; i < 1023; i++ )
+ {
+ TCHAR c = Symbol->Name[i];
+ lsymbol[i] = (char)c;
+ if( c < 28 ) break;
+ }
+ lsymbol[i] = 0;
+
+ if( Line.FileName )
+ {
+ for( i = 0; i < 1023; i++ )
+ {
+ TCHAR c = Line.FileName[i];
+ lfile[i] = (char)c;
+ if( c < 28 ) break;
+ }
+ lfile[i] = 0;
+ }
+
+ if( Line.FileName )
+ return _snprintf( str, maxlen, "%p %s (%s:%d)", ptr, lsymbol, lfile, Line.LineNumber );
+ else
+ return _snprintf( str, maxlen, "%p %s", ptr, lsymbol );
+}
+
+//Base off of example from http://www.debuginfo.com/example
+
+void SetupDBGHelp()
+{
+ int bRet = 0;
+ static int already_set_up = 0;
+ DWORD Options;
+
+ if (already_set_up) return;
+ already_set_up = 1;
+
+ Options = SymGetOptions();
+ Options |= SYMOPT_DEBUG;
+ Options |= SYMOPT_LOAD_LINES;
+ SymSetOptions( Options );
+
+ bRet = SymInitialize (
+ GetCurrentProcess(), // Process handle of the current process
+ NULL, // No user-defined search path -> use default
+ TRUE // Load symbols for all modules in the current process
+ );
+
+ if( !bRet )
+ {
+ printf("Error: SymInitialize() failed. Error code: %u \n", GetLastError());
+ return;
+ }
+
+ {
+ TCHAR pFileName[2048];
+
+ DWORD64 ModBase;
+ DWORD64 BaseAddr = 0x10000000;
+ DWORD FileSize = 0;
+
+ GetModuleFileName( 0, pFileName, 2048 );
+
+ if( !GetFileSize( pFileName, &FileSize ) )
+ return;
+
+ ModBase = SymLoadModule64 (
+ GetCurrentProcess(),
+ NULL,
+ (PSTR)pFileName,
+ NULL,
+ BaseAddr,
+ FileSize
+ );
+
+ if( ModBase == 0 )
+ {
+ printf( "Error: SymLoadModule64() failed. Error code: %u \n" , GetLastError());
+ return;
+ }
+ }
+
+
+ return;
+}
+
+#else
+#error Neither _CWINDOWS, _CMAC OR _CLINUX are defined!
+#endif
+
+
+/*
+ * (c) 2003-2008 Glenn Maynard, Steve Checkoway, Avery Lee, Charles Lohr
+ * All rights reserved.
+ *
+ * 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, and/or sell copies of the Software, and to permit persons to
+ * whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * 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 OF
+ * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+ * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
Added: Mercury2/src/MercuryBacktrace.h
===================================================================
--- Mercury2/src/MercuryBacktrace.h (rev 0)
+++ Mercury2/src/MercuryBacktrace.h 2008-12-30 22:10:30 UTC (rev 113)
@@ -0,0 +1,39 @@
+#ifndef _HGBACKTRACE_H
+#define _HGBACKTRACE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int cnget_backtrace( int SkipFirst, char * buffer, int max_size );
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
+
+/*
+ * (c) 2003-2008 Glenn Maynard, Steve Checkoway, Avery Lee, Charles Lohr
+ * All rights reserved.
+ *
+ * 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, and/or sell copies of the Software, and to permit persons to
+ * whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * 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 OF
+ * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+ * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
Added: Mercury2/src/MercuryCrash.c
===================================================================
--- Mercury2/src/MercuryCrash.c (rev 0)
+++ Mercury2/src/MercuryCrash.c 2008-12-30 22:10:30 UTC (rev 113)
@@ -0,0 +1,214 @@
+#include "MercuryCrash.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+#ifdef WIN32
+#define _CWINDOWS
+#else
+#if defined( MACOSX ) || defined( __APPLE__ )
+#define _CMAC
+#else
+#define _CLINUX
+#endif
+#endif
+
+
+
+#if defined( _CLINUX ) || defined( _CMAC )
+
+#ifdef _CLINUX
+
+#ifndef __USE_POSIX
+#define __USE_POSIX
+#include <signal.h>
+#undef__USE_POSIX
+#else
+#include <signal.h>
+#endif
+
+#include <bits/siginfo.h>
+
+#else
+
+#include <signal.h>
+
+#endif
+
+int inCrashHandler = 0;
+
+static int msignals[] =
+{
+ SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGABRT,
+ SIGQUIT, SIGSEGV, SIGTRAP, SIGTERM, SIGVTALRM, SIGXCPU, SIGXFSZ,
+#if defined(HAVE_DECL_SIGPWR) && HAVE_DECL_SIGPWR
+ SIGPWR,
+#endif
+#if defined(HAVE_DECL_SIGUSR1) && HAVE_DECL_SIGUSR1
+ SIGUSR1,
+#endif
+ -1
+};
+
+static const struct ExceptionLookup {
+ int code;
+ const char *name;
+} exceptions[]={
+ { SIGALRM, "SIGALRM" },
+ { SIGBUS, "SIGBUS" },
+ { SIGFPE, "SIGFPE" },
+ { SIGINT, "SIGINT" },
+ { SIGABRT, "SIGABRT" },
+ { SIGQUIT, "SIGQUIT" },
+ { SIGSEGV, "Segmentation Fault", },
+ { SIGTRAP, "SIGTRAP", },
+ { SIGTERM, "SIGTERM", },
+ { SIGXCPU, "SIGXCPU", },
+ { SIGXFSZ, "SIGXFSZ", },
+ { 0, "Unknown Exception", },
+ { 0 },
+};
+
+FNType chHandler;
+
+static void SigHandler( int signal, siginfo_t *si, void *ucp )
+{
+ if( inCrashHandler )
+ exit( -1 );
+
+ inCrashHandler = 1;
+
+ if( chHandler( signal ) == 0x12121212 )
+ return;
+
+ inCrashHandler = 0;
+ if( signal == SIGINT || signal == SIGQUIT )
+ {
+ printf( "Ctrl+Break Hit, Exit.\n" );
+ exit( 1 );
+ return;
+ }
+
+ if( signal == SIGTERM || signal == SIGHUP )
+ return;
+
+ struct sigaction sa;
+ sa.sa_flags = 0;
+ sigemptyset( &sa.sa_mask );
+ sa.sa_handler = SIG_DFL;
+
+ struct sigaction old;
+ sigaction( signal, &sa, &old );
+ raise( signal );
+ sigaction( signal, &old, NULL );
+}
+
+
+int cnset_execute_on_crash( FNType fn )
+{
+ int i;
+ struct sigaction sa;
+ chHandler = fn;
+
+ sa.sa_flags = 0;
+ sa.sa_flags |= SA_NODEFER;
+ sa.sa_flags |= SA_SIGINFO;
+ sigemptyset(&sa.sa_mask);
+
+ // Set up our signal handlers.
+ sa.sa_sigaction = SigHandler;
+ for( i = 0; msignals[i] != -1; ++i )
+ sigaction( msignals[i], &sa, NULL );
+
+ // Block SIGPIPE, so we get EPIPE.
+ sa.sa_handler = SIG_IGN;
+ sigaction( SIGPIPE, &sa, NULL );
+ return 0;
+}
+
+#elif defined( _CWINDOWS )
+#include <windows.h>
+
+FNType top;
+
+long __stdcall cnException(
+ struct _EXCEPTION_POINTERS * filter)
+{
+ int ret = 0;
+ ret = top( filter->ExceptionRecord->ExceptionCode );
+ if( ret == 0x12121212 )
+ return EXCEPTION_CONTINUE_EXECUTION;
+ else
+ return EXCEPTION_EXECUTE_HANDLER;
+}
+
+int cnset_execute_on_crash( FNType fn )
+{
+ top = fn;
+ SetUnhandledExceptionFilter(cnException);
+ return 0;
+}
+
+static const struct ExceptionLookup {
+ DWORD code;
+ const char *name;
+} exceptions[]={
+ { EXCEPTION_ACCESS_VIOLATION, "Access Violation" },
+ { EXCEPTION_BREAKPOINT, "Breakpoint" },
+ { EXCEPTION_FLT_DENORMAL_OPERAND, "FP Denormal Operand" },
+ { EXCEPTION_FLT_DIVIDE_BY_ZERO, "FP Divide-by-Zero" },
+ { EXCEPTION_FLT_INEXACT_RESULT, "FP Inexact Result" },
+ { EXCEPTION_FLT_INVALID_OPERATION, "FP Invalid Operation" },
+ { EXCEPTION_FLT_OVERFLOW, "FP Overflow", },
+ { EXCEPTION_FLT_STACK_CHECK, "FP Stack Check", },
+ { EXCEPTION_FLT_UNDERFLOW, "FP Underflow", },
+ { EXCEPTION_INT_DIVIDE_BY_ZERO, "Integer Divide-by-Zero", },
+ { EXCEPTION_INT_OVERFLOW, "Integer Overflow", },
+ { EXCEPTION_PRIV_INSTRUCTION, "Privileged Instruction", },
+ { EXCEPTION_ILLEGAL_INSTRUCTION, "Illegal instruction" },
+ { EXCEPTION_INVALID_HANDLE, "Invalid handle" },
+ { EXCEPTION_STACK_OVERFLOW, "Stack overflow" },
+ { 0xe06d7363, "Unhandled Microsoft C++ Exception", },
+ { 0, "UNKNOWN EXCEPTION", },
+ { 0 },
+};
+
+
+#endif
+
+
+const char * cn_get_crash_description( int code )
+{
+ int i;
+
+ for( i = 0; exceptions[i].code; ++i )
+ if( exceptions[i].code == code )
+ return exceptions[i].name;
+
+ return exceptions[i].name;
+}
+
+
+/*
+ * (c) 2003-2008 Glenn Maynard, Steve Checkoway, Avery Lee, Charles Lohr
+ * All rights reserved.
+ *
+ * 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, and/or sell copies of the Software, and to permit persons to
+ * whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * 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 OF
+ * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+ * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
Added: Mercury2/src/MercuryCrash.h
===================================================================
--- Mercury2/src/MercuryCrash.h (rev 0)
+++ Mercury2/src/MercuryCrash.h 2008-12-30 22:10:30 UTC (rev 113)
@@ -0,0 +1,44 @@
+#ifndef _HGCRASH_H
+#define _HGCRASH_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//If you return 0x12121212, it will attempt not to crash. Otherwise, it will just do whatever it feels it should.
+typedef int (*FNType)( int signal );
+
+int cnset_execute_on_crash( FNType fn );
+const char * cn_get_crash_description( int code );
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
+
+
+/*
+ * (c) 2003-2008 Glenn Maynard, Steve Checkoway, Avery Lee, Charles Lohr
+ * All rights reserved.
+ *
+ * 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, and/or sell copies of the Software, and to permit persons to
+ * whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * 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 OF
+ * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+ * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 21:26:50
|
Revision: 110
http://hgengine.svn.sourceforge.net/hgengine/?rev=110&view=rev
Author: cnlohr
Date: 2008-12-30 21:26:46 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
updated cnconfigure
Modified Paths:
--------------
Mercury2/adv_set.c
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2008-12-30 21:25:50 UTC (rev 109)
+++ Mercury2/adv_set.c 2008-12-30 21:26:46 UTC (rev 110)
@@ -13,7 +13,7 @@
src/PNGLoader.cpp src/ImageLoader.cpp \
src/MercuryVBO.cpp src/MSemaphore.cpp \
src/UpdateThreader.cpp src/HGMDLMesh.cpp \
- src/HGMDLModel.cpp"
+ src/HGMDLModel.cpp src/MercuryString.cpp"
#ifdef USE_LIBXML
SOURCES="$SOURCES src/XMLParser.cpp"
@@ -24,7 +24,7 @@
#endif
PROJ="mercury"
-CFLAGS="$CFLAGS -DHAVE_CONFIG -fno-exceptions -fPIC -Isrc"
+CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc"
LDFLAGS="$LDFLAGS -rdynamic -g -fPIC"
/*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 21:25:59
|
Revision: 109
http://hgengine.svn.sourceforge.net/hgengine/?rev=109&view=rev
Author: cnlohr
Date: 2008-12-30 21:25:50 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
switch to MString
Modified Paths:
--------------
Mercury2/src/BMPLoader.cpp
Mercury2/src/HGMDLMesh.h
Mercury2/src/HGMDLModel.cpp
Mercury2/src/ImageLoader.cpp
Mercury2/src/ImageLoader.h
Mercury2/src/MAutoPtr.h
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryAsset.h
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Mercury2/src/MercuryThreads.cpp
Mercury2/src/MercuryThreads.h
Mercury2/src/MercuryUtil.cpp
Mercury2/src/MercuryUtil.h
Mercury2/src/MercuryWindow.cpp
Mercury2/src/MercuryWindow.h
Mercury2/src/Win32Window.cpp
Mercury2/src/Win32Window.h
Mercury2/src/X11Window.cpp
Mercury2/src/X11Window.h
Modified: Mercury2/src/BMPLoader.cpp
===================================================================
--- Mercury2/src/BMPLoader.cpp 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/BMPLoader.cpp 2008-12-30 21:25:50 UTC (rev 109)
@@ -28,7 +28,7 @@
memset(tmp, 0, 4);
// file->Read(tmp, sizeof(char) * 2);
fread(tmp, sizeof(char) * 2, 1, file);
- string type(tmp);
+ MString type(tmp);
if (type != "BM")
{
Modified: Mercury2/src/HGMDLMesh.h
===================================================================
--- Mercury2/src/HGMDLMesh.h 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/HGMDLMesh.h 2008-12-30 21:25:50 UTC (rev 109)
@@ -8,7 +8,7 @@
public:
void LoadFromFile(FILE* hgmdl);
private:
- string m_name;
+ MString m_name;
bool m_cachable;
};
Modified: Mercury2/src/HGMDLModel.cpp
===================================================================
--- Mercury2/src/HGMDLModel.cpp 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/HGMDLModel.cpp 2008-12-30 21:25:50 UTC (rev 109)
@@ -18,7 +18,8 @@
fingerPrint[4] = 0;
fread(fingerPrint, 4, 1, hgmdl);
- if (string(fingerPrint) != "MBMF")
+ MString p(fingerPrint);
+ if (p != "MBMF")
{
printf("Not a HGMDL file.\n");
return;
Modified: Mercury2/src/ImageLoader.cpp
===================================================================
--- Mercury2/src/ImageLoader.cpp 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/ImageLoader.cpp 2008-12-30 21:25:50 UTC (rev 109)
@@ -1,5 +1,4 @@
#include <ImageLoader.h>
-#include <string>
#include <MercuryUtil.h>
using namespace std;
@@ -12,15 +11,15 @@
return *instance;
}
-bool ImageLoader::RegisterFactoryCallback(const std::string& type, Callback1R< FILE*, RawImageData* > functor)
+bool ImageLoader::RegisterFactoryCallback(const MString& type, Callback1R< FILE*, RawImageData* > functor)
{
- string t = ToUpper( type );
- std::pair<std::string, Callback1R< FILE*, RawImageData* > > pp(t, functor);
+ MString t = ToUpper( type );
+ std::pair<MString, Callback1R< FILE*, RawImageData* > > pp(t, functor);
m_factoryCallbacks.push_back( pp );
return true;
}
-RawImageData* ImageLoader::LoadImage(const std::string& filename)
+RawImageData* ImageLoader::LoadImage(const MString& filename)
{
FILE* f = fopen(filename.c_str(), "rb");
char fingerprint[4];
@@ -29,8 +28,8 @@
fread(fingerprint, sizeof(char)*3, 1, f);
fseek(f, 0, SEEK_SET);
- string t(fingerprint);// = ToUpper( type );
- std::list< std::pair< std::string, Callback1R< FILE*, RawImageData* > > >::iterator i;
+ MString t(fingerprint);// = ToUpper( type );
+ std::list< std::pair< MString, Callback1R< FILE*, RawImageData* > > >::iterator i;
for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i)
{
if (i->first == t)
Modified: Mercury2/src/ImageLoader.h
===================================================================
--- Mercury2/src/ImageLoader.h 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/ImageLoader.h 2008-12-30 21:25:50 UTC (rev 109)
@@ -1,7 +1,6 @@
#ifndef IMAGELOADER_H
#define IMAGELOADER_H
-#include <string>
#include <RawImageData.h>
#include <Callback.h>
#include <list>
@@ -11,11 +10,11 @@
{
public:
static ImageLoader& GetInstance();
- bool RegisterFactoryCallback(const std::string& type, Callback1R< FILE*, RawImageData* >);
- RawImageData* LoadImage(const std::string& filename);
+ bool RegisterFactoryCallback(const MString& type, Callback1R< FILE*, RawImageData* >);
+ RawImageData* LoadImage(const MString& filename);
private:
- std::list< std::pair< std::string, Callback1R< FILE*, RawImageData* > > > m_factoryCallbacks;
+ std::list< std::pair< MString, Callback1R< FILE*, RawImageData* > > > m_factoryCallbacks;
};
static InstanceCounter<ImageLoader> ILcounter("ImageLoader");
Modified: Mercury2/src/MAutoPtr.h
===================================================================
--- Mercury2/src/MAutoPtr.h 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MAutoPtr.h 2008-12-30 21:25:50 UTC (rev 109)
@@ -1,9 +1,6 @@
#ifndef MAUTOPTR_H
#define MAUTOPTR_H
-//#include <util.h>
-//#include <stdlib.h>
-//#include <stdio.h>
#include <MercuryThreads.h>
class RefBase
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MercuryAsset.cpp 2008-12-30 21:25:50 UTC (rev 109)
@@ -16,18 +16,18 @@
return *instance;
}
-bool AssetFactory::RegisterFactoryCallback(const std::string& type, Callback0R< MAutoPtr<MercuryAsset> > functor)
+bool AssetFactory::RegisterFactoryCallback(const MString & type, Callback0R< MAutoPtr<MercuryAsset> > functor)
{
- string t = ToUpper( type );
- std::pair<std::string, Callback0R< MAutoPtr<MercuryAsset> > > pp(t, functor);
+ MString t = ToUpper( type );
+ std::pair<MString , Callback0R< MAutoPtr<MercuryAsset> > > pp(t, functor);
m_factoryCallbacks.push_back( pp );
return true;
}
-MAutoPtr<MercuryAsset> AssetFactory::Generate(const std::string& type)
+MAutoPtr<MercuryAsset> AssetFactory::Generate(const MString& type)
{
- string t = ToUpper( type );
- std::list< std::pair< std::string, Callback0R< MAutoPtr<MercuryAsset> > > >::iterator i;
+ MString t = ToUpper( type );
+ std::list< std::pair< MString, Callback0R< MAutoPtr<MercuryAsset> > > >::iterator i;
for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i)
if (i->first == t) return i->second();
printf("WARNING: Asset type %s not found.\n", type.c_str());
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MercuryAsset.h 2008-12-30 21:25:50 UTC (rev 109)
@@ -23,11 +23,11 @@
{
public:
static AssetFactory& GetInstance();
- bool RegisterFactoryCallback(const std::string& type, Callback0R< MAutoPtr<MercuryAsset> >);
- MAutoPtr<MercuryAsset> Generate(const std::string& type);
+ bool RegisterFactoryCallback(const MString& type, Callback0R< MAutoPtr<MercuryAsset> >);
+ MAutoPtr<MercuryAsset> Generate(const MString& type);
private:
- std::list< std::pair< std::string, Callback0R< MAutoPtr<MercuryAsset> > > > m_factoryCallbacks;
+ std::list< std::pair< MString, Callback0R< MAutoPtr<MercuryAsset> > > > m_factoryCallbacks;
};
static InstanceCounter<AssetFactory> AFcounter("AssetFactory");
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MercuryNode.cpp 2008-12-30 21:25:50 UTC (rev 109)
@@ -123,18 +123,18 @@
}
-bool NodeFactory::RegisterFactoryCallback(const std::string& type, Callback0R<MercuryNode*> functor)
+bool NodeFactory::RegisterFactoryCallback(const MString& type, Callback0R<MercuryNode*> functor)
{
- string t = ToUpper( type );
- std::pair<std::string, Callback0R<MercuryNode*> > pp(t, functor);
+ MString t = ToUpper( type );
+ std::pair<MString, Callback0R<MercuryNode*> > pp(t, functor);
m_factoryCallbacks.push_back( pp );
return true;
}
-MercuryNode* NodeFactory::Generate(const std::string& type)
+MercuryNode* NodeFactory::Generate(const MString& type)
{
- string t = ToUpper( type );
- std::list< std::pair< std::string, Callback0R<MercuryNode*> > >::iterator i;
+ MString t = ToUpper( type );
+ std::list< std::pair< MString, Callback0R<MercuryNode*> > >::iterator i;
for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i)
if (i->first == t) return i->second();
return NULL;
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MercuryNode.h 2008-12-30 21:25:50 UTC (rev 109)
@@ -5,6 +5,7 @@
#include <Callback.h>
#include <typeinfo>
#include <XMLParser.h>
+#include <MercuryUtil.h>
/** This is the basic node of the scene graph. It is not intended to be instanced.
Each node exists as a single entity in the scene graph.
@@ -67,11 +68,11 @@
{
public:
static NodeFactory& GetInstance();
- bool RegisterFactoryCallback(const std::string& type, Callback0R<MercuryNode*>);
- MercuryNode* Generate(const std::string& type);
+ bool RegisterFactoryCallback(const MString& type, Callback0R<MercuryNode*>);
+ MercuryNode* Generate(const MString& type);
private:
- std::list< std::pair< std::string, Callback0R<MercuryNode*> > > m_factoryCallbacks;
+ std::list< std::pair< MString, Callback0R<MercuryNode*> > > m_factoryCallbacks;
};
static InstanceCounter<NodeFactory> NFcounter("NodeFactory");
Modified: Mercury2/src/MercuryThreads.cpp
===================================================================
--- Mercury2/src/MercuryThreads.cpp 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MercuryThreads.cpp 2008-12-30 21:25:50 UTC (rev 109)
@@ -14,7 +14,7 @@
#endif
}
-MercuryThread::MercuryThread( const string &name )
+MercuryThread::MercuryThread( const MString &name )
:m_name(name), m_haltOnDestroy(true), m_thread(0)
{
#if defined( WIN32 )
@@ -128,7 +128,7 @@
UnLock();
}
-MercuryMutex::MercuryMutex( const string &name )
+MercuryMutex::MercuryMutex( const MString &name )
:m_name(name)
{
iLockCount = 0;
Modified: Mercury2/src/MercuryThreads.h
===================================================================
--- Mercury2/src/MercuryThreads.h 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MercuryThreads.h 2008-12-30 21:25:50 UTC (rev 109)
@@ -1,9 +1,13 @@
#ifndef _MERCURY_THREADS_H
#define _MERCURY_THREADS_H
+#ifdef HGENGINE
+#include <MercuryString.h>
+#else
#include <string>
+typedef std::string MString;
+#endif
-using namespace std;
#if !defined(WIN32)
#if !defined(_EE)
@@ -20,7 +24,7 @@
{
public:
MercuryThread();
- MercuryThread( const string &name );
+ MercuryThread( const MString &name );
~MercuryThread();
///Create a thread of function fn and pass it data *data.
@@ -41,7 +45,7 @@
// inline void Exit() { pthread_exit(NULL); }
inline void HaltOnDestroy(bool t) { m_haltOnDestroy = t; }
private:
- string m_name;
+ MString m_name;
bool m_haltOnDestroy;
#if defined(WIN32)
@@ -62,7 +66,7 @@
{
public:
MercuryMutex( );
- MercuryMutex( const string &name );
+ MercuryMutex( const MString &name );
~MercuryMutex();
///Wait for a mutex to unlock (0xFFFFFF is infinate on windows)
@@ -77,7 +81,7 @@
///Clean up a mutex. This is done automatically on destruction of mutex.
int Close( );
private:
- string m_name;
+ MString m_name;
int iLockCount;
#if defined( WIN32 )
Modified: Mercury2/src/MercuryUtil.cpp
===================================================================
--- Mercury2/src/MercuryUtil.cpp 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MercuryUtil.cpp 2008-12-30 21:25:50 UTC (rev 109)
@@ -1,16 +1,19 @@
#include <MercuryUtil.h>
+#include <stdint.h>
-std::string ToUpper(const std::string& s)
+MString ToUpper(const MString& s)
{
- std::string t = s;
+ MString t = s;
+ char * ti = (char*)t.c_str();
for (unsigned long i = 0; i < s.length(); ++i)
{
- t[i] = toupper(t[i]);
+ if( ti[i] >= 'a' && ti[i] <= 'z' )
+ ti[i] -= ( 'a' - 'A' );
}
return t;
}
-float StrToFloat(const std::string& s)
+float StrToFloat(const MString & s)
{
float x;
sscanf(s.c_str(), "%f", &x);
Modified: Mercury2/src/MercuryUtil.h
===================================================================
--- Mercury2/src/MercuryUtil.h 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MercuryUtil.h 2008-12-30 21:25:50 UTC (rev 109)
@@ -2,7 +2,8 @@
#define MERCURYUTIL_H
#include <stdlib.h>
-#include <string>
+#include <MercuryString.h>
+
/*#ifndef NULL
#define NULL 0
#endif*/
@@ -24,9 +25,9 @@
#define M_ALIGN(n)
#endif
-std::string ToUpper(const std::string& s);
+MString ToUpper(const MString & s);
-float StrToFloat(const std::string& s);
+float StrToFloat(const MString & s);
//This counter is used with singletons to
//ensure proper destruction order of the
@@ -36,7 +37,7 @@
class InstanceCounter
{
public:
- InstanceCounter(const std::string& name)
+ InstanceCounter(const MString & name)
:m_name(name)
{
if (m_count == 0)
@@ -57,7 +58,7 @@
}
private:
static unsigned long m_count;
- std::string m_name;
+ MString m_name;
T* m_instance;
};
Modified: Mercury2/src/MercuryWindow.cpp
===================================================================
--- Mercury2/src/MercuryWindow.cpp 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MercuryWindow.cpp 2008-12-30 21:25:50 UTC (rev 109)
@@ -1,7 +1,6 @@
-#include <string.h>
#include "MercuryWindow.h"
-MercuryWindow::MercuryWindow(const string& title, int width, int height, int bits, int depthBits, bool fullscreen)
+MercuryWindow::MercuryWindow(const MString& title, int width, int height, int bits, int depthBits, bool fullscreen)
:m_title(title), m_width(width), m_height(height), m_bits(bits), m_depthBits(depthBits), m_fullscreen(fullscreen)
{
}
Modified: Mercury2/src/MercuryWindow.h
===================================================================
--- Mercury2/src/MercuryWindow.h 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/MercuryWindow.h 2008-12-30 21:25:50 UTC (rev 109)
@@ -1,17 +1,14 @@
#ifndef MERCURYWINDOW_H
#define MERCURYWINDOW_H
-#include <string>
#include <MercuryUtil.h>
#include <list>
#include <Callback.h>
-using namespace std;
-
class MercuryWindow
{
public:
- MercuryWindow(const string& title, int width, int height, int bits, int depthBits, bool fullscreen);
+ MercuryWindow(const MString& title, int width, int height, int bits, int depthBits, bool fullscreen);
virtual ~MercuryWindow();
inline static MercuryWindow* MakeWindow() {
@@ -27,13 +24,13 @@
return MercuryWindow::m_windowInstance;
}
- virtual void* GetProcAddress(const string& x) = 0;
+ virtual void* GetProcAddress(const MString& x) = 0;
protected:
static Callback0R< MercuryWindow* > genWindowClbk;
static MercuryWindow* m_windowInstance;
- string m_title;
+ MString m_title;
int m_width, m_height, m_bits, m_depthBits;
bool m_fullscreen;
};
Modified: Mercury2/src/Win32Window.cpp
===================================================================
--- Mercury2/src/Win32Window.cpp 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/Win32Window.cpp 2008-12-30 21:25:50 UTC (rev 109)
@@ -8,7 +8,7 @@
return new Win32Window("Mercury2 Tests", 640, 480, 24, 16, false);
}
-LPCTSTR StringToLPCTSTR(const string& s)
+LPCTSTR StringToLPCTSTR(const MString & s)
{
size_t length = s.length();
LPCTSTR str = new WCHAR[length+1];
@@ -17,7 +17,7 @@
return str;
}
-Win32Window::Win32Window(const string& title, int width, int height, int bits, int depthBits, bool fullscreen)
+Win32Window::Win32Window(const MString& title, int width, int height, int bits, int depthBits, bool fullscreen)
:m_hwnd(NULL), m_hdc(NULL), m_hglrc(NULL), m_hInstance(NULL), m_className(NULL), m_windowAtom(NULL), m_winTitle(NULL),
MercuryWindow(title, width, height, bits, depthBits, fullscreen)
{
Modified: Mercury2/src/Win32Window.h
===================================================================
--- Mercury2/src/Win32Window.h 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/Win32Window.h 2008-12-30 21:25:50 UTC (rev 109)
@@ -2,7 +2,6 @@
#define WIN32WINDOW_H
#include <windows.h>
-#include <string>
#include <MercuryWindow.h>
#include <MScopedArray.h>
@@ -10,7 +9,7 @@
class Win32Window : public MercuryWindow
{
public:
- Win32Window(const string& title, int width, int height, int bits, int depthBits, bool fullscreen);
+ Win32Window(const MString& title, int width, int height, int bits, int depthBits, bool fullscreen);
virtual ~Win32Window();
virtual bool SwapBuffers();
virtual bool PumpMessages();
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/X11Window.cpp 2008-12-30 21:25:50 UTC (rev 109)
@@ -2,7 +2,7 @@
Callback0R< MercuryWindow* > MercuryWindow::genWindowClbk(X11Window::GenX11Window); //Register window generation callback
-X11Window::X11Window(const string& title, int width, int height, int bits, int depthBits, bool fullscreen)
+X11Window::X11Window(const MString& title, int width, int height, int bits, int depthBits, bool fullscreen)
:MercuryWindow(title, width, height, bits, depthBits, fullscreen), m_display(NULL)
{
m_display = XOpenDisplay(NULL);
@@ -148,7 +148,7 @@
return true;
}
-void* X11Window::GetProcAddress(const string& x)
+void* X11Window::GetProcAddress(const MString& x)
{
return NULL;
}
Modified: Mercury2/src/X11Window.h
===================================================================
--- Mercury2/src/X11Window.h 2008-12-30 21:25:22 UTC (rev 108)
+++ Mercury2/src/X11Window.h 2008-12-30 21:25:50 UTC (rev 109)
@@ -9,7 +9,7 @@
class X11Window : public MercuryWindow
{
public:
- X11Window(const string& title, int width, int height, int bits, int depthBits, bool fullscreen);
+ X11Window(const MString& title, int width, int height, int bits, int depthBits, bool fullscreen);
virtual ~X11Window();
static MercuryWindow* GenX11Window();
@@ -17,7 +17,7 @@
virtual bool SwapBuffers();
virtual bool PumpMessages();
- virtual void* GetProcAddress(const string& x);
+ virtual void* GetProcAddress(const MString& x);
private:
Display* m_display;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|