|
From: <cn...@us...> - 2010-04-25 20:16:58
|
Revision: 699
http://hgengine.svn.sourceforge.net/hgengine/?rev=699&view=rev
Author: cnlohr
Date: 2010-04-25 20:16:49 +0000 (Sun, 25 Apr 2010)
Log Message:
-----------
Fix Mercury, Win32.
Modified Paths:
--------------
Mercury2/Mercury2.vcproj
Mercury2/src/FullscreenQuad.cpp
Mercury2/src/GLHelpers.cpp
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryFBO.cpp
Mercury2/src/MercurySound.h
Mercury2/src/Win32Window.cpp
Mercury2/src/Win32Window.h
Modified: Mercury2/Mercury2.vcproj
===================================================================
--- Mercury2/Mercury2.vcproj 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/Mercury2.vcproj 2010-04-25 20:16:49 UTC (rev 699)
@@ -42,7 +42,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="modules;.;src;src/include;src/include/png;src/include/zlib;src/DataStructures;src/DataTypes"
- PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS"
+ PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS;_HAVE_LIB_GL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -115,7 +115,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=".;src;src/include;src/include/png;src/include/zlib"
- PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS"
+ PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS;_HAVE_LIB_GL"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Modified: Mercury2/src/FullscreenQuad.cpp
===================================================================
--- Mercury2/src/FullscreenQuad.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/FullscreenQuad.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -7,7 +7,7 @@
: Quad( key, bInstanced )
{
m_matrix = MercuryMatrix::Identity();
- m_matrix.Transotale(0,0,-1,0,0,0,2,2,0.01);
+ m_matrix.Transotale(0,0,-1,0,0,0,2,2,0.01f);
// m_matrix.Scale(2,2,1);
m_matrix.Transpose();
}
Modified: Mercury2/src/GLHelpers.cpp
===================================================================
--- Mercury2/src/GLHelpers.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/GLHelpers.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -111,13 +111,13 @@
modelview, projection, viewport,
&dox, &doy, &doz);
- p = MercuryVertex( dox, doy, doz );
+ p = MercuryVertex( (float)dox, (float)doy, (float)doz );
gluUnProject(
winX, winY, 1,
modelview, projection, viewport,
&dox, &doy, &doz );
- r = MercuryVertex( dox, doy, doz ) - p;
+ r = MercuryVertex( (float)dox, (float)doy, (float)doz ) - p;
r.NormalizeSelf();
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/Mercury2.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -15,9 +15,9 @@
#include <MercuryTimer.h>
#include <RenderGraph.h>
#include <Texture.h>
-#ifdef _HAVE_LIB_GL
+#ifdef _HAVE_LIB_GL
#include <GLHeaders.h>
-#endif
+#endif
#include <ModuleManager.h>
#include <MercuryFile.h>
@@ -202,10 +202,10 @@
//uncomment the next 2 lines to use threads
// UpdateLoopGo.Increment();
// updateThread.Wait();
-
+
#ifdef _HAVE_LIB_GL
PrintGLFunctionCalls();
-#endif
+#endif
SAFE_DELETE(root);
SAFE_DELETE(w);
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/MercuryAsset.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -55,7 +55,7 @@
void MercuryAsset::PreRender(const MercuryNode* node)
{
- uint32_t t = time(0);
+ uint32_t t = (uint32_t)time(0);
if ( m_lastNewerCheck < t )
{
m_lastNewerCheck = t;
Modified: Mercury2/src/MercuryFBO.cpp
===================================================================
--- Mercury2/src/MercuryFBO.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/MercuryFBO.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -95,7 +95,7 @@
int h = MercuryWindow::GetCurrentWindow()->Height();
if ((m_width != w) || (m_height != h))
{
- m_width = w; m_height = h;
+ m_width = (unsigned short) w; m_height = (unsigned short)h;
for (uint8_t i = 0; i < m_numTextures; ++i)
{
MString n = ssprintf("%s_%d", m_name.c_str(), i);
@@ -153,16 +153,16 @@
void MercuryFBO::LoadFromXML(const XMLNode& node)
{
if ( !node.Attribute("width").empty() )
- SetWidth( StrToInt(node.Attribute("width")) );
+ SetWidth( (unsigned short) StrToInt(node.Attribute("width")) );
if ( !node.Attribute("height").empty() )
- SetHeight( StrToInt(node.Attribute("height")) );
+ SetHeight( (unsigned short) StrToInt(node.Attribute("height")) );
if ( !node.Attribute("depth").empty() )
SetUseDepth( node.Attribute("depth") == "true"?true:false );
if ( !node.Attribute("tnum").empty() )
- SetNumTextures( StrToInt(node.Attribute("tnum")) );
+ SetNumTextures( (unsigned char)StrToInt(node.Attribute("tnum")) );
if ( !node.Attribute("usescreensize").empty() )
m_useScreenSize = node.Attribute("usescreensize") == "true"?true:false;
Modified: Mercury2/src/MercurySound.h
===================================================================
--- Mercury2/src/MercurySound.h 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/MercurySound.h 2010-04-25 20:16:49 UTC (rev 699)
@@ -70,8 +70,8 @@
//Useful tools
- inline float GetSecondsSinceLastFrame() { float tr = m_tLastTrip.Age(); return (tr>1.)?1.:tr; }
- inline unsigned int SamplesSinceLastFrame() { float tr = m_tLastTrip.Age(); return (tr>1.)?fSPS:(tr*fSPS); }
+ inline float GetSecondsSinceLastFrame() { float tr = m_tLastTrip.Age(); return (tr>1.f)?1.f:tr; }
+ inline unsigned int SamplesSinceLastFrame() { float tr = m_tLastTrip.Age(); return (unsigned int)(tr>1.)?fSPS:(tr*fSPS); }
//For registering and creation of new sound sources...
MAutoPtr< MercurySoundSource > LoadSoundSource( const MString & sSourceType, MAutoPtr< MercurySoundSource > Chain = 0 );
Modified: Mercury2/src/Win32Window.cpp
===================================================================
--- Mercury2/src/Win32Window.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/Win32Window.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -2,7 +2,10 @@
//#include <Windowsx.h>
#include <GLHeaders.h>
#include <MercuryInput.h>
+#include <MercuryMessageManager.h>
+MVRefBool GlobalMouseGrabbed_Set( "Input.CursorGrabbed" );
+
LRESULT CALLBACK WindowCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); //Window callback
Callback0R< MercuryWindow* > MercuryWindow::genWindowClbk(Win32Window::GenWin32Window); //Register window generation callback
bool ACTIVE = false;
@@ -120,7 +123,11 @@
SetForegroundWindow(m_hwnd); // Slightly Higher Priority
SetFocus(m_hwnd); // Sets Keyboard Focus To The Window
-
+ //Resize windows so it's actually as big as we want, not minus borders.s
+ GetClientRect( m_hwnd, &rect );
+ int diffx = m_width - rect.right;
+ int diffy = m_height - rect.bottom;
+ SetWindowPos( m_hwnd, HWND_TOP, 0, 0, diffx + m_width, diffy + m_height, 0 );
}
void Win32Window::SetPixelType()
@@ -191,17 +198,29 @@
bool Win32Window::PumpMessages()
{
+ static int lastx, lasty;
+ static bool bWasCursorVisible;
MSG message;
if ( InFocus() != ACTIVE )
{
m_inFocus = ACTIVE;
ShowCursor(!m_inFocus);
- PointerToCenter();
+ if( GlobalMouseGrabbed_Set.Get() )
+ {
+ RECT rect;
+ GetWindowRect(m_hwnd, &rect);
+ SetCursorPos( rect.left + m_width/2, rect.top + m_height/2 );
+ }
}
while (PeekMessage(&message, NULL, 0, 0, PM_REMOVE))
{
+ RECT rect;
+ GetClientRect( m_hwnd, &rect );
+ m_width = rect.right;
+ m_height = rect.bottom;
+
if ( InFocus() )
{
switch( message.message )
@@ -221,33 +240,74 @@
case WM_MOUSEMOVE:
{
POINT pos;
+ RECT rect;
+ GetWindowRect(m_hwnd, &rect);
GetCursorPos(&pos);
- if (pos.x!=m_cX || pos.y!=m_cY) //ignore the resets to center
+ ScreenToClient(m_hwnd, &pos );
+ bool left = message.wParam&MK_LBUTTON;
+ bool right = message.wParam&MK_RBUTTON;
+ bool center = message.wParam&MK_MBUTTON;
+ bool su = 0;
+ bool sd = 0;
+ int px = pos.x;// - rect.left - borderx;
+ int py = pos.y;// - rect.top - bordery;
+
+ if( GlobalMouseGrabbed_Set.Get() )
{
- int dx = m_cX - pos.x;
- int dy = m_cY - pos.y;
- m_iLastMouseX += dx;
- m_iLastMouseY += dy;
- MouseInput::ProcessMouseInput(dx, dy, message.wParam&MK_LBUTTON, message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0);
- PointerToCenter();
+ int x, y;
+ x = m_width/2 - px;
+ y = m_height/2 - py;
+ if (x!=0 || y!=0) //prevent recursive XWarp
+ {
+ m_iLastMouseX = x;
+ m_iLastMouseY = y;
+ MouseInput::ProcessMouseInput(x, y, left, right, center, su, sd, true);
+ lastx = x; lasty = y;
+
+ pos.x = m_width/2;
+ pos.y = m_height/2;
+ ClientToScreen(m_hwnd, &pos );
+ SetCursorPos( pos.x, pos.y);
+ if( bWasCursorVisible )
+ {
+ bWasCursorVisible = false;
+ ShowCursor( false );
+ }
+ }
}
+ else
+ {
+ m_iLastMouseX = px;
+ m_iLastMouseY = py;
+ lastx = px; lasty = py;
+ MouseInput::ProcessMouseInput(px, py, left, right, center, su, sd, true);
+ if( !bWasCursorVisible )
+ {
+ ShowCursor( true );
+ bWasCursorVisible = true;
+ }
+ }
}
break;
case WM_LBUTTONDOWN:
- break;
case WM_LBUTTONUP:
- break;
case WM_RBUTTONDOWN:
- break;
case WM_RBUTTONUP:
- break;
case WM_MBUTTONDOWN:
- break;
case WM_MBUTTONUP:
+ MouseInput::ProcessMouseInput( lastx, lasty, message.wParam&MK_LBUTTON,
+ message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0, false);
break;
- case 0x020A: //Do nothing (at least now) It's a mouse wheel!
+ case 0x020A: //Not-too-well-documented mouse wheel.
+ {
+ short cx = short(message.wParam>>16);
+ MouseInput::ProcessMouseInput( lastx, lasty, message.wParam&MK_LBUTTON,
+ message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, (cx>0), (cx<0), false);
+ MouseInput::ProcessMouseInput( lastx, lasty, message.wParam&MK_LBUTTON,
+ message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0, false);
break;
}
+ }
}
TranslateMessage(&message); // Translate The Message
DispatchMessage(&message); // Dispatch The Message
@@ -272,15 +332,6 @@
return (c&65535) > 1;
}
-void Win32Window::PointerToCenter()
-{
- RECT rect;
- GetWindowRect(m_hwnd, &rect);
- m_cX = rect.left+m_width/2;
- m_cY = rect.top+m_height/2;
- SetCursorPos(m_cX, m_cY);
-}
-
short Win32Window::ConvertScancode( uint32_t scanin )
{
// Specifies the scan code. The value depends on the OEM.
Modified: Mercury2/src/Win32Window.h
===================================================================
--- Mercury2/src/Win32Window.h 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/Win32Window.h 2010-04-25 20:16:49 UTC (rev 699)
@@ -28,8 +28,6 @@
void CreateRenderingContext();
void GenPixelType();
- void PointerToCenter();
-
HWND m_hwnd; //window handle
HDC m_hdc; //device handle
PIXELFORMATDESCRIPTOR m_pfd; //pixel format descriptor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|