Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

116 Neutral

About fourth

  • Rank

Personal Information

  • Interests
  1. fourth

    Handling Mouse Movement

    My old code has mature handling of WM_MOUSEMOVE. The technique I used at the time was to turn off the cursor visibility, render a quad with a cursor texture on it for my home grown GUI. When the mouse moved from the centre (lets say 400, 300 on a 800, 600 window, I would capture the delta, set the position back to 400,300 and apply the delta to my internal mouse position. Usually something like 0, -1 if the mouse is moving downwards.    However, my code is literally windows 2000 era. My mouse at the time was not even USB. Over the intervening years it seems as though the OS has moved to a model of reporting mouse moves a LOT more than it did in the past. I recorded all the events in to a file and timestamped them to work out why my mouse would move a few pixels then slam to the screen edges.    Why? The logs indicates I would get a steady stream of delta's as expected(maybe a dozen a second), then BOOM, I'd get a few thousand in a very short period. When my engine applied the 1000 delta's it would move right to the boundary.    When I considered the problem. I could not work out a good way to see if an update was at normal speed or was a spam update. So... I needed a new system. Hence this post.   My current interim solution is to just set the internal mouse to the system mouse position whenever the WM_MOUSEMOVE comes in. The spam burst seem to not affect framerate so I can ignore it for now. When I get my old circa 2002 voxel engine back up and running. However in 3d model I'll have to start working out how to start doing deltas again. My current idea on how to handle this is to just to run two mouse handlers. Only use WM_MOVE for the GUI, then when no active forms are rendered to the screen I just poll a mouse api directly I'm sure there is something in DirectInput that can help me. Everyone else has worked this out so it;s just a matter of finding some open source and digging around I guess though I'm not sure how else people handle this other than locking the mouse in to a strict position.    I did try clip cursor btw, I got back success on the call but the mouse can easily wander out of the window anyway. 
  2. fourth

    Handling Mouse Movement

    Kind thanks frob, that's a much better solution. It funny that you of all people answered this question after all these years. I remember your account from back in 2002 when I was last here.
  3. I'm digging up some of my old code and found that the window message pump is collecting WM_MOVE events and passing them to an input handler. To prevent a mouse from leaving the window I was resetting the mouse to the centre of the window and just collecting the delta. This was then applied to my game cursor which maintains a non centre position.   Problem is, I'm occasionally seeing bursts of ~1000's of WM_MOVE events come in, as when they hit the 'distance from centre' code, it just repeats the same message 1000's of times, each one moving the cursor, which flies off to the window edges.    My tactical hack was to just ignore all messages after the first... but the mouse movement it now not tracking well.   I suspect I'm getting this all wrong. How do you guys handle mouse movement? (Note, I'm not using Direct Input)
  4. fourth

    Template not linking?

    "Because for some strange reason, managing things like gpu textures should be done with exactly the same tools as managing 3D models, sound clips, and level streams."   Incorrect, I was upfront about that: "Each game asset be created and in the constructor add itself to a template type manager." and even gave an example of calling the code that created the single new instance.    CResourceManager<CModel, CModelIO>::CreateInstance();   Each 'manager' is defined by a base type. Models, textures, samples, etc. That way I can have different types of models (static models, movable modesl, etc). Each can be loaded from a separate loader file, like a _lwo.cpp loader.    " Because you know those are all interchangable."   ?Bryan, and you giving me stick here? :) This is code untouched for over 10 years at least. Probably 12.    " A graphics resource needs to work closely with the GPU and rendering system."   It might. Or, it might just be a dumb data type that gets passed to something that knows what to do with it. The way I did it (in 2001, when I started writing this code) was that all GPU code live in a 'renderer' class in a plugin DLL. I mostly used OpenGL, but could swap in d3d, by swapping the subsystem at boot time. The CModel instances would get passed to the renderer. The downside is that the renderer had to know what to do with a 'model'.  This allows the culling to collect up whats in view then just chuck the data to the Renderer to draw. My model know nothing about how to be drawn. To be honest, the 'manager' is mostly there to prevent loading the same data from file twice. I think if I draw up a diagram of how it worked you'd agree it 'doesnt suck too much' compared to the other horrors you would have witnessed (like GL calls inside the model class). I'll agree it's over engineered, hence this corner I painted myself in to :).    Yes, singletons are not great. I had reservations at the time(and still remember being borderline on the whole idea of what amounts to little more than a C style global.). I started coding games after reading carmack's code when I worked on a Q2 mod. It was in C, but he used globals all over the place. I thought his code looked like crap, and thats from someone who had only ever programmed in basic prior to that point. (If you think this is baseless slander have a look at the code yourself, pay attention to the 'everything includes everything' problem too).    You know gamedev now better than me. I've been gone from here so long Flipcode (fourth.flipcode.com where I had a blog before the word blog was used) closed down, and then opened back up again..(and now I checked and it's gone again..). I can hold back on flamewars, I just want to understand this linker error. If people want to use goto's or singletons or whatever I really don't care. I've been all over google for days and the best I have is that somehow the linker thinks that this class was never instantiated in an object file. But it was, in createinstance().I recall having a similar problem once with partial template specialisation for my factory. To get around that one I have a file, with all my factory created types just created for no reason other than to keep the linker happy.    While I have been waiting I forked the code yesterday and am removing the resource manager. I estimate three evenings to get it all out, then another 2-3 for making sure the replacement code works.    frob, your name rings a bell. I'm sure you have been around here a long time. Here is my old account: http://www.gamedev.net/user/3998-gimp/   "Oh wow.  You have both a generic "manager" and Singleton at the same time.  "   Was that a frob jab? :P I'm pretty sure I implemented this singleton straight out of Design Patterns. I was always uncomfortable with templates, but in four cases I used them. The singleton, resource manager, 'handle'(really a class that simply adds itself to the resource manager, and the factory, derived from this : http://adtmag.com/articles/2000/09/25/industrial-strength-pluggable-factories.aspx . But, when they hit the compiler\linker some magic happens, and when they don't work I can rarely work out why. Like now. :|   I used the singleton as the alternative was to have the class hosted in a big fat yumcha class like CEngine. I always disliked the facade pattern. It always seemed like glue code to paper over bad design. In the end, these kinds of cerebral time wasters help us not finish the projects pondering. It's usually to forge on with something 'ok' then something perfect that will be ready 'sometime'...
  5. fourth

    Template not linking?

    I tried to attach the actual relevant source files but I couldn't. Yes, each resource manager template derives from a singleton pattern.,      /*----------------------------------------------------------------------------- Definitions needed for interface -----------------------------------------------------------------------------*/ #include "NonCopyable.h"     /*----------------------------------------------------------------------------- Class -----------------------------------------------------------------------------*/ template <typename T>  class Singleton : private CNonCopyable { public:   static void CreateInstance(void); static void SetInstance(T* a_NewInstance);   static T& GetInstance(void);   static void ReleaseInstance(void); static bool IsAssigned(void);   private:       static T* s_Instance;   };   template <typename T>  T* Singleton <T>::s_Instance = 0;     /*----------------------------------------------------------------------------- Inlined Functions -----------------------------------------------------------------------------*/ #include "Singleton.inl"     #endif //SINGLETON_H   I'll be honest, I don't understand that last line (it's been 12 years now since I even looked at this code.) :   template <typename T>  T* Singleton <T>::s_Instance = 0;   I'm also reading the 'Resource Manager' thread, where a bunch of you are suggesting that a singleton for a texture manager is a bit of a bad idea. I agree to an extent, I'm trading calling convenience for complexity (which is currently over my head)... :(
  6. Ok, so, I had to recreate my account as I hadn't logged on since ~2003ish. Thats how long my game was shelved for as the kids were born and grew up. Now the boy is aging dad to show him the game but of course it no longer compiles.    I 'was' a decent coder. Now I'm trying to piece together what I once knew. Most of my ~60,000 lines makes sence, but one section won't link, and I can barely follow what I was doing back then.   In essence, I had a pluggable factory class that would eat an data blob, lets say a LWO model, then it would create the model, textures, etc. Each game asset be created and in the constructor add itself to a template type manager.   Here is the linker failure:   Error 42 error LNK2019: unresolved external symbol "private: static class CResourceManager<class CModel,class CModelIO> * CResourceManager<class CModel,class CModelIO>::s_Instance" (?s_Instance@?$CResourceManager@VCModel@@VCModelIO@@@@0PAV1@A) referenced in function __ehhandler$?Insert@?$Octant@VCNode@@@@AAE_NPBVCNode@@I@Z C:\ZZZ\Source\c++\Game\Source\_Game\StaticEntity.obj _Game       This tells me I think that s_instance, the static that holds the singleton reference for this manager has no concrete implementation. However, in the mainline opening code I have this(and a bunch of the others that are similar)   CResourceManager<CModel, CModelIO>::CreateInstance();   So, that should have worked. For the curious, thats below.   I understand that I'm not pasting in great blobs of code. I thought that too presumptuous to expect you all to dive in. Perhaps I might ask... am I following that linker error correctly? If so, what would cause my createinstance to not be good enough for the linker?   Any ideas on how to get the old game up and running?  FWIW, The tail end of that error refers to 'insert','octant','node' all class names.    
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!