diff --git a/build3/premake4.lua b/build3/premake4.lua index 81150eaaf..01e7082cc 100644 --- a/build3/premake4.lua +++ b/build3/premake4.lua @@ -94,7 +94,7 @@ { 'ARCHS = "$(ARCHS_STANDARD_32_BIT) $(ARCHS_STANDARD_64_BIT)"', 'VALID_ARCHS = "x86_64 i386"', --- 'SDKROOT = "macosx10.9"', + 'SDKROOT = "macosx10.9"', } end @@ -145,4 +145,4 @@ include "../src/Bullet3Serialize/Bullet2FileLoader" - \ No newline at end of file + diff --git a/examples/CommonInterfaces/CommonGraphicsAppInterface.h b/examples/CommonInterfaces/CommonGraphicsAppInterface.h index 4851bbc36..257223ad8 100644 --- a/examples/CommonInterfaces/CommonGraphicsAppInterface.h +++ b/examples/CommonInterfaces/CommonGraphicsAppInterface.h @@ -29,7 +29,7 @@ struct DrawGridData struct CommonGraphicsApp { - class b3gWindowInterface* m_window; + class CommonWindowInterface* m_window; struct CommonRenderInterface* m_renderer; struct CommonParameterInterface* m_parameterInterface; struct Common2dCanvasInterface* m_2dCanvasInterface; @@ -94,8 +94,8 @@ struct CommonGraphicsApp { CommonCameraInterface* camera = m_renderer->getActiveCamera(); - bool isAltPressed = m_window->isModifiedKeyPressed(B3G_ALT); - bool isControlPressed = m_window->isModifiedKeyPressed(B3G_CONTROL); + bool isAltPressed = m_window->isModifierKeyPressed(B3G_ALT); + bool isControlPressed = m_window->isModifierKeyPressed(B3G_CONTROL); if (isAltPressed || isControlPressed) diff --git a/examples/CommonInterfaces/CommonMultiBodyBase.h b/examples/CommonInterfaces/CommonMultiBodyBase.h index 215f36f79..ab4531673 100644 --- a/examples/CommonInterfaces/CommonMultiBodyBase.h +++ b/examples/CommonInterfaces/CommonMultiBodyBase.h @@ -249,7 +249,6 @@ struct CommonMultiBodyBase : public ExampleInterface virtual bool mouseButtonCallback(int button, int state, float x, float y) { - CommonRenderInterface* renderer = m_guiHelper->getRenderInterface(); if (!renderer) @@ -257,12 +256,13 @@ struct CommonMultiBodyBase : public ExampleInterface btAssert(0); return false; } + + CommonWindowInterface* window = m_guiHelper->getAppInterface()->m_window; - b3gWindowInterface* window = m_guiHelper->getAppInterface()->m_window; - + if (state==1) { - if(button==0 && (!window->isModifiedKeyPressed(B3G_ALT) && !window->isModifiedKeyPressed(B3G_CONTROL) )) + if(button==0 && (!window->isModifierKeyPressed(B3G_ALT) && !window->isModifierKeyPressed(B3G_CONTROL) )) { btVector3 camPos; renderer->getActiveCamera()->getCameraPosition(camPos); diff --git a/examples/CommonInterfaces/CommonRigidBodyBase.h b/examples/CommonInterfaces/CommonRigidBodyBase.h index 38231906c..6e44e49e5 100644 --- a/examples/CommonInterfaces/CommonRigidBodyBase.h +++ b/examples/CommonInterfaces/CommonRigidBodyBase.h @@ -239,7 +239,6 @@ struct CommonRigidBodyBase : public ExampleInterface virtual bool mouseButtonCallback(int button, int state, float x, float y) { - CommonRenderInterface* renderer = m_guiHelper->getRenderInterface(); if (!renderer) @@ -247,12 +246,39 @@ struct CommonRigidBodyBase : public ExampleInterface btAssert(0); return false; } + + CommonWindowInterface* window = m_guiHelper->getAppInterface()->m_window; - b3gWindowInterface* window = m_guiHelper->getAppInterface()->m_window; - +#if 0 + if (window->isModifierKeyPressed(B3G_ALT)) + { + printf("ALT pressed\n"); + } else + { + printf("NO ALT pressed\n"); + } + + if (window->isModifierKeyPressed(B3G_SHIFT)) + { + printf("SHIFT pressed\n"); + } else + { + printf("NO SHIFT pressed\n"); + } + + if (window->isModifierKeyPressed(B3G_CONTROL)) + { + printf("CONTROL pressed\n"); + } else + { + printf("NO CONTROL pressed\n"); + } +#endif + + if (state==1) { - if(button==0 && (!window->isModifiedKeyPressed(B3G_ALT) && !window->isModifiedKeyPressed(B3G_CONTROL) )) + if(button==0 && (!window->isModifierKeyPressed(B3G_ALT) && !window->isModifierKeyPressed(B3G_CONTROL) )) { btVector3 camPos; renderer->getActiveCamera()->getCameraPosition(camPos); diff --git a/examples/CommonInterfaces/CommonWindowInterface.h b/examples/CommonInterfaces/CommonWindowInterface.h index 675a8da1b..f94189c00 100644 --- a/examples/CommonInterfaces/CommonWindowInterface.h +++ b/examples/CommonInterfaces/CommonWindowInterface.h @@ -67,11 +67,11 @@ struct b3gWindowConstructionInfo }; -class b3gWindowInterface +class CommonWindowInterface { public: - virtual ~b3gWindowInterface() + virtual ~CommonWindowInterface() { } @@ -96,7 +96,7 @@ class b3gWindowInterface virtual void endRendering()=0; - virtual bool isModifiedKeyPressed(int key) = 0; + virtual bool isModifierKeyPressed(int key) = 0; virtual void setMouseMoveCallback(b3MouseMoveCallback mouseCallback)=0; virtual b3MouseMoveCallback getMouseMoveCallback()=0; diff --git a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp index 2d3c93ccb..f5056ffb2 100644 --- a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp +++ b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp @@ -36,7 +36,7 @@ #include "LinearMath/btIDebugDraw.h" CommonGraphicsApp* s_app=0; -b3gWindowInterface* s_window = 0; +CommonWindowInterface* s_window = 0; CommonParameterInterface* s_parameterInterface=0; CommonRenderInterface* s_instancingRenderer=0; OpenGLGuiHelper* s_guiHelper=0; diff --git a/examples/ForkLift/ForkLiftDemo.cpp b/examples/ForkLift/ForkLiftDemo.cpp index 01ebf1c24..f4276b762 100644 --- a/examples/ForkLift/ForkLiftDemo.cpp +++ b/examples/ForkLift/ForkLiftDemo.cpp @@ -867,7 +867,7 @@ void ForkLiftDemo::resetForklift() bool ForkLiftDemo::keyboardCallback(int key, int state) { bool handled = false; - bool isShiftPressed = m_guiHelper->getAppInterface()->m_window->isModifiedKeyPressed(B3G_SHIFT); + bool isShiftPressed = m_guiHelper->getAppInterface()->m_window->isModifierKeyPressed(B3G_SHIFT); if (state) { diff --git a/examples/OpenGLWindow/MacOpenGLWindow.h b/examples/OpenGLWindow/MacOpenGLWindow.h index b267790f4..81bb935b1 100644 --- a/examples/OpenGLWindow/MacOpenGLWindow.h +++ b/examples/OpenGLWindow/MacOpenGLWindow.h @@ -5,7 +5,7 @@ #define b3gDefaultOpenGLWindow MacOpenGLWindow -class MacOpenGLWindow : public b3gWindowInterface +class MacOpenGLWindow : public CommonWindowInterface { struct MacOpenGLWindowInternalData* m_internalData; float m_mouseX; @@ -40,7 +40,7 @@ public: void runMainLoop(); - virtual bool isModifiedKeyPressed(int key); + virtual bool isModifierKeyPressed(int key); void setMouseButtonCallback(b3MouseButtonCallback mouseCallback) { diff --git a/examples/OpenGLWindow/MacOpenGLWindow.mm b/examples/OpenGLWindow/MacOpenGLWindow.mm index 66d42124e..b2c120db9 100644 --- a/examples/OpenGLWindow/MacOpenGLWindow.mm +++ b/examples/OpenGLWindow/MacOpenGLWindow.mm @@ -12,7 +12,12 @@ #include - +enum +{ + MY_MAC_ALTKEY=1, + MY_MAC_SHIFTKEY=2, + MY_MAC_CONTROL_KEY=4 +}; /* report GL errors, if any, to stderr */ static void checkError(const char *functionName) @@ -222,7 +227,7 @@ MacOpenGLWindow::~MacOpenGLWindow() } -bool MacOpenGLWindow::isModifiedKeyPressed(int key) +bool MacOpenGLWindow::isModifierKeyPressed(int key) { bool isPressed = false; @@ -230,17 +235,17 @@ bool MacOpenGLWindow::isModifiedKeyPressed(int key) { case B3G_ALT: { - isPressed = ((m_modifierFlags && NSAlternateKeyMask)!=0); + isPressed = ((m_modifierFlags & MY_MAC_ALTKEY)!=0); break; }; case B3G_SHIFT: { - isPressed = ((m_modifierFlags && NSShiftKeyMask)!=0); + isPressed = ((m_modifierFlags & MY_MAC_SHIFTKEY)!=0); break; }; case B3G_CONTROL: { - isPressed = ((m_modifierFlags && NSControlKeyMask )!=0); + isPressed = ((m_modifierFlags & MY_MAC_CONTROL_KEY )!=0); break; }; @@ -772,37 +777,43 @@ void MacOpenGLWindow::startRendering() if ((modifiers & NSShiftKeyMask)) { m_keyboardCallback(B3G_SHIFT,1); + m_modifierFlags |= MY_MAC_SHIFTKEY; }else { - if (m_modifierFlags&NSShiftKeyMask) + if (m_modifierFlags& MY_MAC_SHIFTKEY) { - m_keyboardCallback(B3G_SHIFT,0); + m_keyboardCallback(B3G_SHIFT,0); + m_modifierFlags &= ~MY_MAC_SHIFTKEY; } } if (modifiers & NSControlKeyMask) { m_keyboardCallback(B3G_CONTROL,1); + m_modifierFlags |= MY_MAC_CONTROL_KEY; } else { - if (m_modifierFlags&NSControlKeyMask) + if (m_modifierFlags&MY_MAC_CONTROL_KEY) { m_keyboardCallback(B3G_CONTROL,0); + m_modifierFlags &= ~MY_MAC_CONTROL_KEY; } } if (modifiers & NSAlternateKeyMask) - { - m_keyboardCallback(B3G_ALT,1); - } else - { - if (m_modifierFlags&NSAlternateKeyMask) - { - m_keyboardCallback(B3G_ALT,0); - } - } + { + m_keyboardCallback(B3G_ALT,1); + m_modifierFlags |= MY_MAC_ALTKEY; + } else + { + if (m_modifierFlags&MY_MAC_ALTKEY) + { + m_keyboardCallback(B3G_ALT,0); + m_modifierFlags &= ~MY_MAC_ALTKEY; + + } + } //handle NSCommandKeyMask } - m_modifierFlags=modifiers; } if ([event type] == NSKeyUp) { diff --git a/test/enet/client/main.cpp b/test/enet/client/main.cpp deleted file mode 100644 index a351c6d2d..000000000 --- a/test/enet/client/main.cpp +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - -#include -#include - - -int main(int argc, char* argv[]) -{ - printf("starting client (and server)\n"); - - if (enet_initialize () != 0) - { - fprintf (stderr, "An error occurred while initializing ENet.\n"); - return EXIT_FAILURE; - } - atexit (enet_deinitialize); - - ENetAddress selfaddress; - selfaddress.host = ENET_HOST_ANY; - /* Bind the server to port 1111. */ - selfaddress.port = 1111; - - ENetHost * client=0; - while (!client) - { - client = enet_host_create (&selfaddress/* create a client host */, - 32 /* only 32 connections */, - 2 /* allow up 2 channels to be used, 0 and 1 */, - 0/*57600 / 8 56K modem with 56 Kbps downstream bandwidth */, - 0 /* 14400 / 8 56K modem with 14 Kbps upstream bandwidth */); - if (client == NULL) - { - selfaddress.port++; - } - } - if (client == NULL) - { - fprintf (stderr, - "An error occurred while trying to create an ENet client host.\n"); - exit (EXIT_FAILURE); - } - - - - ENetAddress dedicatedserveraddress; - ENetEvent event; - ENetPeer* dedicatedpeer=0; - ENetPeer* natpeer=0; - - /* Connect to some.server.net:1234. */ - enet_address_set_host (& dedicatedserveraddress, "bulletphysics.org");//localhost"); - dedicatedserveraddress.port = 1234; - /* Initiate the connection, allocating the two channels 0 and 1. */ - dedicatedpeer = enet_host_connect (client, & dedicatedserveraddress, 2, 0); - if (dedicatedpeer == NULL) - { - fprintf (stderr, "No available peers for initiating an ENet connection.\n"); - exit (EXIT_FAILURE); - } - /* Wait up to 5 seconds for the connection attempt to succeed. */ - if (enet_host_service (client, & event, 5000) > 0 && - event.type == ENET_EVENT_TYPE_CONNECT) - { - char servername[1024]; - enet_address_get_host(&dedicatedserveraddress,servername, 1024); - char serverinfo[1024]; - - sprintf(serverinfo,"Connection to %s:%d succeeded", servername,dedicatedserveraddress.port); - puts (serverinfo); - - /////.... - - /* Wait up to 1000 milliseconds for an event. */ - while (enet_host_service (client, & event, 1000000000) > 0) - { - if (natpeer) - { - /* Create a reliable packet of size 7 containing "packet\0" */ - ENetPacket * packet = enet_packet_create ("packet", - strlen ("packet") + 1, - ENET_PACKET_FLAG_RELIABLE); - /* Extend the packet so and append the string "foo", so it now */ - /* contains "packetfoo\0" */ - enet_packet_resize (packet, strlen ("packetfoo") + 1); - strcpy ((char*)& packet -> data [strlen ("packet")], "foo"); - /* Send the packet to the peer over channel id 0. */ - /* One could also broadcast the packet by */ - /* enet_host_broadcast (host, 0, packet); */ - enet_peer_send (natpeer, 0, packet); - } - switch (event.type) - { - case ENET_EVENT_TYPE_CONNECT: - printf ("A new client connected from %x:%u.\n", - event.peer -> address.host, - event.peer -> address.port); - /* Store any relevant client information here. */ - event.peer -> data = "Client information"; - break; - case ENET_EVENT_TYPE_RECEIVE: - printf ("A packet of length %u containing %s was received from %s on channel %u.\n", - event.packet -> dataLength, - event.packet -> data, - event.peer -> data, - event.channelID); - /* Clean up the packet now that we're done using it. */ - - if (event.packet->dataLength==sizeof(ENetAddress)) - { - ENetAddress* address = (ENetAddress*)event.packet->data; - printf("received other client's address from server, connecting...\n"); - natpeer = enet_host_connect (client, address, 2, 0); - if (natpeer== NULL) - { - fprintf (stderr, "No available peers for initiating an ENet connection.\n"); - exit (EXIT_FAILURE); - } - /* Wait up to 5 seconds for the connection attempt to succeed. */ - if (enet_host_service (client, & event, 5000) > 0 && - event.type == ENET_EVENT_TYPE_CONNECT) - { - puts ("Connection to natpeer succeeded."); - } else - { - enet_peer_reset (natpeer); - puts ("Connection to natpeer failed."); - natpeer=0; - exit(0); - } - - } - - enet_packet_destroy (event.packet); - break; - - case ENET_EVENT_TYPE_DISCONNECT: - printf ("%s disconected.\n", event.peer -> data); - /* Reset the peer's client information. */ - event.peer -> data = NULL; - } - } - /* One could just use enet_host_service() instead. */ - enet_host_flush (client);//host); - } - else - { - /* Either the 5 seconds are up or a disconnect event was */ - /* received. Reset the peer in the event the 5 seconds */ - /* had run out without any significant event. */ - enet_peer_reset (dedicatedpeer); - puts ("Connection to some.server.net:1234 failed."); - } - - - - - - - enet_host_destroy(client); - - return 0; -} - - - - - - - - - - - - diff --git a/test/enet/client/premake4.lua b/test/enet/client/premake4.lua deleted file mode 100644 index b9eea8600..000000000 --- a/test/enet/client/premake4.lua +++ /dev/null @@ -1,25 +0,0 @@ - - -project ("Test_enet_client") - - language "C++" - - kind "ConsoleApp" - targetdir "../../../bin" - includedirs {"../../../btgui/enet/include"} - - if os.is("Windows") then - defines { "WIN32" } - links {"Ws2_32","Winmm"} - end - if os.is("Linux") then - end - if os.is("MacOSX") then - end - - links {"enet"} - - files { - "main.cpp", - } - diff --git a/test/enet/server/main.cpp b/test/enet/server/main.cpp deleted file mode 100644 index 31ea9cc46..000000000 --- a/test/enet/server/main.cpp +++ /dev/null @@ -1,111 +0,0 @@ - -#include -#include - - -ENetPeer* mypeers[2]={0,0}; -ENetAddress clientAddresses[2]; -int numpeers=0; - -int main(int argc, char* argv[]) -{ - fprintf(stderr,"starting enet dedicated server\n"); - - if (enet_initialize () != 0) - { - fprintf (stderr, "An error occurred while initializing ENet.\n"); - return EXIT_FAILURE; - } - atexit (enet_deinitialize); - - ENetAddress address; - ENetHost * server; - /* Bind the server to the default localhost. */ - /* A specific host address can be specified by */ - /* enet_address_set_host (& address, "x.x.x.x"); */ - address.host = ENET_HOST_ANY; - /* Bind the server to port 1234. */ - address.port = 1234; - server = enet_host_create (& address /* the address to bind the server host to */, - 32 /* allow up to 32 clients and/or outgoing connections */, - 2 /* allow up to 2 channels to be used, 0 and 1 */, - 0 /* assume any amount of incoming bandwidth */, - 0 /* assume any amount of outgoing bandwidth */); - if (server == NULL) - { - fprintf (stderr, - "An error occurred while trying to create an ENet server host.\n"); - exit (EXIT_FAILURE); - } - - - ENetEvent event; - - /* Wait up to 10000000 milliseconds for an event. */ - while (enet_host_service (server, & event, 10000000) > 0) - { - switch (event.type) - { - case ENET_EVENT_TYPE_CONNECT: - char clientname[1024]; - enet_address_get_host(&event.peer -> address,clientname, 1024); - printf ("A new client connected from %s:%u.\n", - clientname, - event.peer -> address.port); - /* Store any relevant client information here. */ - event.peer -> data = "Client information"; - if (numpeers<2) - { - clientAddresses[numpeers] = event.peer->address; - mypeers[numpeers] = event.peer; - } - numpeers++; - if (numpeers==2) - { - printf("exchanging addresses for NAT punchthrough\n"); - //exchange the address info - for (int i=0;i<2;i++) - { - int sz = sizeof(ENetAddress); - /* Create a reliable packet of size 7 containing "packet\0" */ - ENetPacket * packet = enet_packet_create (&clientAddresses[i], - sz, - ENET_PACKET_FLAG_RELIABLE); - enet_peer_send (mypeers[1-i], 0, packet); - - - } - //prepare for the next pair of clients to connect/NAT punchthrough - numpeers=0; - } - - break; - case ENET_EVENT_TYPE_RECEIVE: - printf ("A packet of length %u containing %s was received from %s on channel %u.\n", - event.packet -> dataLength, - event.packet -> data, - event.peer -> data, - event.channelID); - /* Clean up the packet now that we're done using it. */ - enet_packet_destroy (event.packet); - - break; - - case ENET_EVENT_TYPE_DISCONNECT: - printf ("%s disconected.\n", event.peer -> data); - /* Reset the peer's client information. */ - event.peer -> data = NULL; - } - } - - - - - - - enet_host_destroy(server); - printf("server exited, press key\n"); - getchar(); - - return 0; -} \ No newline at end of file diff --git a/test/enet/server/premake4.lua b/test/enet/server/premake4.lua deleted file mode 100644 index e5013324c..000000000 --- a/test/enet/server/premake4.lua +++ /dev/null @@ -1,26 +0,0 @@ - - -project ("Test_enet_server") - - language "C++" - - kind "ConsoleApp" - targetdir "../../../bin" - includedirs {"../../../btgui/enet/include"} - - if os.is("Windows") then - defines { "WIN32" } - - links {"Ws2_32","Winmm"} - end - if os.is("Linux") then - end - if os.is("MacOSX") then - end - - links {"enet"} - - files { - "main.cpp", - } - diff --git a/test/lua/main.cpp b/test/lua/main.cpp deleted file mode 100644 index 409f05bce..000000000 --- a/test/lua/main.cpp +++ /dev/null @@ -1,179 +0,0 @@ - -// Some quick experiments to use Lua and C (C++) together -// so Lua can be used to setup the Bullet demos -// See http://csl.name/lua/ -// and http://stackoverflow.com/questions/7298642/passing-c-struct-pointer-to-lua-script - - -#include -#include - -extern "C" { - #include "lua.h" - #include "lualib.h" -#include "lauxlib.h" -} - - - -struct MyTest -{ - int m_bla; - MyTest():m_bla(10) - { - - } - - void methodPrint() - { - printf("t->m_bla=%d\n",m_bla); - } - -}; - -std::vector gValidPointers; - -bool isValidPointer(MyTest* ptr) -{ - bool result = false; - - for (int i=0;imethodPrint(); - } else - { - std::cerr << "error my_printTest called with invalid argument "; - } - } - return 0; -} - -int my_createFunction(lua_State *L) -{ - int argc = lua_gettop(L); - - std::cerr << "-- my_function() called with " << argc - << " arguments:" << std::endl; - - for ( int n=1; n<=argc; ++n ) { - std::cerr << "-- argument " << n << ": " - << lua_tostring(L, n) << std::endl; - } - - - - MyTest* newTest = new MyTest(); - gValidPointers.push_back(newTest); - lua_pushlightuserdata (L, newTest); - - - - return 1; // number of return values -} - -int my_deleteFunction(lua_State *L) -{ - int argc = lua_gettop(L); - if (argc==1) - { - MyTest* tst = (MyTest*) lua_touserdata(L,1); - if (tst) - { - bool result = removeValidPointer(tst); - if (result) - { - delete tst; - } else - { - std::cerr << "error my_deleteFunction called with invalid pointer argument "; - } - } else - { - std::cerr << "error my_deleteFunction called with non-pointer argument "; - } - } - - return 0; // number of return values -} - - - -void report_errors(lua_State *L, int status) -{ - if ( status!=0 ) { - std::cerr << "-- " << lua_tostring(L, -1) << std::endl; - lua_pop(L, 1); // remove error message - } -} - -int main(int argc, char** argv) -{ - for ( int n=1; n