Jump to content
  • Advertisement

lochnator

Member
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

146 Neutral

About lochnator

  • Rank
    Member
  1. I keep reading confusing and conflicting views on the internet about how to create a swapchain with 1 back buffer and 1 front buffer.  Some people say the front buffer is implied and when you create a swapchain description you should set the bufferCount to 1 and others say you must set it to 2 if your want 1 front buffer and 1 back buffer.  Does anyone have any input on this?
  2. Does anyone have any recommendations/advice on decoupling game objects from directx?  For example my current game object looks like so   struct MyGameObject {   void CreateDeviceDependentResources(ComPtr<ID2D1DeviceContext> const & renderTarget)   {        // Create Device Specific stuff like brush my game object wants to use   }   void CreateDeviceIndependentResources(ComPtr<ID2D1Factory2> const & factory)   {     // Create Brush Stroke Style   }   void Render(ComPtr<ID2D1DeviceContext> const & renderTarget)   {       renderTarget->DrawLine(...)   } }  
  3. I was looking at how people handle mouse and keyboard input and came across a modern c++ library called the DirectXTK that contains helpers for writing games, specifically in direct x.  I was looking at the keyboard and mouse class and was wondering if anyone has any experience with it?  Does it have any limitations? Does it have any flaws that would fall flat on its face for handling a graphic/cpu intensive FPS?   https://github.com/Microsoft/DirectXTK/wiki/Keyboard https://github.com/Microsoft/DirectXTK/blob/master/Src/Keyboard.cpp    
  4. According to microsoft documentation on handling user input the advise to no longer use directinput and instead use the message loop to perform input handling/processing.  I'm confused because in most of my books it states that using the regular message processing for handling input..WM_* messages is to slow for commercial quality games.  It also recommends using GetKeyStateAsync() every frame to query the state of the keyboard and mouse.  Does anyone have any experience to when to use wm_* message handling vs GetKeyStateAsync().  What the are pros and the cons to each.
  5. lochnator

    Game loop sucking up CPU

      Ah okay this makes sense.  When i remove the sleep and let it spin as fast as it can it seems like the resize operation feels jittery/laggy.  Is this expected?
  6. I'm new to game programming and am wanting to get some advice about whats going on so far.   I have a single threaded game running the game loop.  It seems to be spinning so fast that the CPU gets pegged at 100%.  I tried to place a sleep in the thread to relieve the CPU pressure, which worked, except for the fact that i also but my UI thread to sleep and when you try to resize the application when it begins sleeping the app appears to not respond from the users perspective.     Does anyone have any examples/advice?  All i want is a simple game loop.  Below is the loop i currently have int Run() { MSG message{}; // Start Timer m_timer.Start(); while (true) { if (m_isVisible) { // Tick timer m_timer.Tick(); TRACE(L"Seconds Per Frame: %f", m_timer.m_delta); Update(); Render(); while (PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) { DispatchMessage(&message); } } else { if (BOOL result = GetMessage(&message, 0, 0, 0)) { if (-1 != result) { DispatchMessage(&message); } } } if (WM_QUIT == message.message) { break; } } return message.wParam; }
  7. Currently i am creating a window, with no background brush.  This is because i will be using directx to draw the background with black.  The issue is for a split second when the window is loaded and created, since it has no background brush, it's white.  Once directx kicks in and initializes it then clears the background with a black color that i want.  Does anyone have any advice/tips on how to prevent the quick white to black background flicker on initial load using only directx for background painting on the window.
  8. lochnator

    Event Aggregator in C++ - Need Help

      I don't believe this is possible, not while adhering to standards-compliant C++.  There are various ways to have an object's method's get a shared_ptr to itself, but for a variety of reasons, they're really not designed to be called from an object's own constructor.  There are a variety of pitfalls in trying to do that!   What about implementing a virtual init() function of sorts?  Construct your objects first, wrap them in a std::shared_ptr, then call their init() method.  Getting a std::shared_ptr to that method shouldn't be too-too hard.  For example, you could either:   - pass it in as a parameter, or - utilize std::enable_shared_from_this, which allows a struct's/class's member functions to get std::shared_ptrs to itself, *but only if that object is already owned by at least one std::shared_ptr* (This is mandated by the C++ standard!)   rCheers, and best of luck! -- David L.   i could do that but it seems to be a bit of error prone. It's easy to forgot to call unit. This is why i was hoping to use the ctor. Any other ideas :)?
  9. lochnator

    Event Aggregator in C++ - Need Help

    I'm new to all the c++11 stuff but a weak_ptr to the subscriber is held by the event aggregator to prevent it from keeping an object alive when its no longer used.   as for letting the aggregator store the subscribers in not sure what this means
  10. I was wanting to take a stab at creating an EventAggregator in c++.  It would work like so.  Each game object that wanted to be notified of specific game events would subscribe to the event using the event aggregator like so. struct SomeSubscriber : Subscriber { SomeSubscriber(std::shared_ptr<EventAggregator> ea) { ea->Subscribe(this, L"EnemySpotted"); } }; All Subscribers would derive from the following class struct Subscriber { virtual ~Subscriber() { } virtual void Handle(Event & e) = 0; }; The Event Aggregator would look something like this struct EventAggregator { std::map<std::wstring, std::vector<std::weak_ptr<Subscriber>>> m_subscriptions; void Publish(Event & e); void Subscribe(std::weak_ptr<Subscriber> subscriber, std::wstring eventType); }; The problem i have is i would like the gameobjects to subscribe to the event aggregator in their constructor but i'm not sure how to do this since the EventAggregator expects a shared_ptr<Subcriber>() in the Subscribe Method.  Does anyone have any advice/recommendations? 
  11. Is there any special handling that should be done when the user changes their monitor resolution and the WM_DISPLAYCHANGED messaged is raised?  
  12. With the introduction of direct2d1.1 you now must call Present() after enddraw() to actually present the back buffer to the screen.  I'm a little confused though because it seems that both EndDraw() and Present() can return Results indicating device lost.  I also see examples where people ignore the error checking of EndDraw and simply catch device lost at the call to present().  Is there any recommendation on this?  
  • 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!