Jump to content

  • Log In with Google      Sign In   
  • Create Account


wisey

Member Since 21 Feb 2009
Offline Last Active Nov 23 2013 06:01 PM
-----

Topics I've Started

learning vc++/directx

22 July 2013 - 05:16 PM

I need some advice about reading material for learning vc++/directx programming. I am working on some prototypes in visual studio using DirectX. I am trying to demonstrate simple things like how to use c++ to do sprite animation in interesting ways. Specifically, I am working on a graph editor for building nav meshs for bots to use A* pathfinding to find a users own ship (simple sprite). The app checks for user input and re-draws the new position based upon the result. And the bots calculate the shortest path each time through the loop and the language moves the bot closer to the user’s ship.

 

Anyhoo. I am getting into difficulty with the language and specifically how to implement design patterns. The problem is obviously that I have never read any official tutorial style book about c++ before. I have Stroustrup’s book for reference. And I have followed tutorials, just clearly not enough of them to be able to turn concepts into code. I have also watched a lot of video tutorials.

 

What I have been told to do by the guru’s on freenode’s #c++ and here (GameDev.net) is to read a book. The guy’s on #c++ have a list of books (some of them are very dated). And one of my thoughts was since I am using vc++ to interact with DirectX that I should buy a book centred around that specifically. Rather than just command line c++ stuff. I am at a loss as to what I should read. And by read, I mean that I want something that I can read cover to cover, word for word. Just to absorb as many skills as I can.

 

At least if I do this then the guy’s on the forums and in chat can’t fob me off by telling me to go and read a book. I really don’t want to jump back into the code base I have been working on until I have completed a thorough treatment of a decent text book.

 

So my question is this. Can you recommend a book? I feel at this stage that just one book should be enough. The reason I am coming to you is that you are a professional vc++/DirectX coder amongst other things.

 

 

--

Steve Wiseman

 

 


Input

25 June 2012 - 02:29 PM

I’m trying to port some C#/xna code into vc++/direct. I’m struggling with keyboard and mouse input yet again. I hope you can offer some suggestions. I’m not going to write a test case because the problem pertains to how input is handled in WinAPI etc.

My problem is the way the C# code handles keyboard and mouse input. As you can see by the C# code below, KeyboardInput provides the functionality for handling key releases and mouse down, mouse up and mouse move.

http://ideone.com/TO4rl

It uses syntax like this:

MouseInput.MouseDown += new MouseClickHandler(MouseInput_MouseDown);

I’m not sure what’s happening with this code but I assume that when somebody clicks the Mouse Down then the MouseInput_MouseDown() function is being called.

If you compare this to how I’ve been laying it out in c++.

http://ideone.com/Cbjw5

http://ideone.com/VMGHd

As you can see, each down and up of a key or mouse button has its own bool. And then I’m performing logic depending on the state of these bools. But i’m finding that there is too many of them, and I never know where to reset the state of them. I’m posting the state of these bools from main here:

http://ideone.com/g3Q1B

My main issue is that my update method is going to become too cluttered. And using this method is very slow progress. One thing i’ve considered is separating out the triggering of each event into different methods but update is being called repeatedly and I only want certain functions to be called if a given set of conditions is met (if a key is pressed or released).

So where do you think i’m going wrong and how can I change it for the better. Oh, I realise that Logans XNA code has types for handling input (MouseInput and KeyboardInput). These are built into xna. I’m assuming it has overrides for the += but i’m reaching the limit of my understanding just saying that and have no idea what I’m doing.

So is there a library of code built into vc++/directx to help me handle this. Is there a lib I can install and use, or do I have to write something to handle this myself.

I’m kind of answering my own questions as I write this which is why it is good to post questions on forums. It helps you understand your own problem better.

--
Wisey

Keyboard and Mouse Input

13 June 2012 - 04:43 PM

http://ideone.com/gO3wy

I'm trying to extend how my app handles input and I don't know why I'm getting trouble with WM_LBUTTONDOWN. The compiler says this:

http://ideone.com/r3joy

Obviously I can't write a test case for a directx app so where do you think i'm going wrong with this?

Please let me know if you need more help, and I do appreciate that you don't have the ide with my project running to test things.

Do you think it could be problems elsewhere because i've updated code in other files too.

--
Wisey

WM_KEYDOWN and WM_KEYUP

20 May 2012 - 12:04 PM

I have some code that is supposed to detect when a key has been pressed and then released before it displays the correct text:

http://ideone.com/1j2Gk

I want both actions to be completed before it changes the text around.

http://ideone.com/XEulf

As you can see, i'm waiting for pressed and released bools to be set before it changes the text around. The problem is, is that it is changing the text as I press the key in, and not waiting until it has popped back out.

Its probably something really simple that i'm missing here so I thought I'd ask you guys.

--
Wisey

Keyboard and Mouse Input

18 May 2012 - 05:05 PM

So I need to experiment with mouse and keyboard input and i'm using DirectX to render sprites in this pathfinding app that i'm building. I checked out the latest DirectX SDK documentation and they say this:

"The use of DirectInput for keyboard and mouse input is not recommended, Windows messages should be used instead"

It links off to a doc on how to use Windows messages. Specifically it describes WM_MOUSEMOVE and this links to the msdn documentation.

I also read about the same stuff here:

http://www.toymaker....html/input.html

tbh, the raw input stuff looks more complicated than just straight keyboard input and mouse input. Am I right in thinking that Keyboard Input done with Windows Messages in this way is based off the Windows API. Because I don't think it is part of DirectX. XInput and DirectInput are part of DirectX.

I suppose the reason for my post is to ask if Windows messages is the usual way of tackling keyboard and mouseinput? And also, what is the best way of getting this information over to the rendering part of my code base. I have already started using Windows messages to pass x, y screen co-ordinates of the mouse over to some rendering code like this:

http://ideone.com/4Ho4F

But I imagine that with all of the input I need to process for my project, the WndProc() function is going to become quite crowded.

--
Wisey

PARTNERS