2007-01-17 Gwenole Beauchesne * 64-bit fixes. --- nucleo-20061224/nucleo/gl/scenegraph/sgNode.H.64bit-fixes 2006-11-29 12:37:37.000000000 +0100 +++ nucleo-20061224/nucleo/gl/scenegraph/sgNode.H 2007-01-17 16:18:29.000000000 +0100 @@ -24,6 +24,8 @@ namespace nucleo { class sgNode { + GLuint _id ; + public: typedef enum {NODL, USE, CREATE} dlPolicy ; @@ -65,7 +67,17 @@ namespace nucleo { void debug(std::ostream& out, int curdepth=0) const ; - // -------------------------------------------------------- + // ------------------------------------------------------- + + GLuint getId() const { + return _id ; + } + + static GLuint createId(sgNode * const node); + static sgNode * const lookupId(GLuint id); + static void destroyId(GLuint id); + + // ------------------------------------------------------- std::string &getName() { return _name ; --- nucleo-20061224/nucleo/gl/scenegraph/sgNode.cxx.64bit-fixes 2006-11-29 12:37:37.000000000 +0100 +++ nucleo-20061224/nucleo/gl/scenegraph/sgNode.cxx 2007-01-18 16:04:53.000000000 +0100 @@ -15,6 +15,17 @@ #include +#if defined __GNUC__ +#include +typedef __gnu_cxx::hash_map sgNodeMap; +#endif + +#if defined __LP64__ +/* 64-bit Linux platforms may be able to set this to 0 assuming there + is no memory leak and/or brk() can grow reasonably (2^31 nowadays?). */ +#define USE_SG_NODE_MAP 1 +#endif + static GLfloat Identity[16] = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, @@ -173,6 +184,46 @@ namespace nucleo { // ------------------------------------------------------------------------ + static sgNodeMap sgNodes; + + GLuint + sgNode::createId(sgNode * const node) { +#if USE_SG_NODE_MAP + static GLuint id = 0x66600000; /* FIXME: set to 0 when debugged! */ + sgNodes[++id] = (void *)node; + if (debugMode) + std::cout << "sgNode::createId: node " << std::hex << node << ", id " << id << std::endl; + return id; +#else + if ((((uintptr_t)node) >> 32) != 0) + std::cout << "sgNode::createId: got a 64-bit addressed node " << std::hex << node << std::endl; + return (uintptr_t)node; +#endif + } + + sgNode * const + sgNode::lookupId(GLuint id) { +#if USE_SG_NODE_MAP + sgNodeMap::const_iterator it = sgNodes.find(id); + if (it != sgNodes.end()) + return (sgNode *)(*it).second; + if (debugMode) + std::cout << "sgNode::lookupId: id " << std::hex << id << " not found" << std::endl; + return NULL; +#else + return (sgNode *)(uintptr_t)id; +#endif + } + + void + sgNode::destroyId(GLuint id) { +#if USE_SG_NODE_MAP + sgNodes.erase(id); +#endif + } + + // ------------------------------------------------------------------------ + void sgNode::debug(std::ostream& out, int curdepth) const { for (int i=0; i=1 std::cerr << o->getName() << " < " << std::flush ; #endif @@ -174,7 +174,7 @@ namespace nucleo { for (int i=0; iapplyTransformations() ; } --- nucleo-20061224/nucleo/gl/window/glWindow_GLX.cxx.64bit-fixes 2006-11-29 23:34:31.000000000 +0100 +++ nucleo-20061224/nucleo/gl/window/glWindow_GLX.cxx 2007-01-18 16:07:00.000000000 +0100 @@ -1378,7 +1382,8 @@ namespace nucleo { e->time = CurrentTime; break; case ClientMessage: - if ((unsigned)xe.xclient.data.l[0] == wmDeleteWindow) { + if (xe.xclient.format == 32 && + (unsigned long)xe.xclient.data.l[0] == wmDeleteWindow) { e->type = glWindow::event::destroy; } e->time = CurrentTime;