Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 24 Apr 2010
Offline Last Active Private

#5294709 [DirectInput] Get gamepad button name

Posted by Khatharr on 02 June 2016 - 04:00 PM

'Fraid not. One of the reasons DInput was deprecated is that gamepads and other HIDs are not standardized. If you're concerned about this kind of conflict the best thing to do is to offer custom key-binding support to the user. If you're exclusively concerned with gamepads then consider using XInput instead, as it has become something of a de-facto standard for gamepads on Windows.

#5293495 Do you usually prefix your classes with the letter 'C' or something e...

Posted by Khatharr on 25 May 2016 - 11:15 PM

Do you usually prefix your classes with the letter 'C' or something else?



#5293467 Can I write a browser game only using Java?

Posted by Khatharr on 25 May 2016 - 07:35 PM

Please don't. JRE (and plugins) is a huge annoyance for users. You may want to look into JS and the HTML5 canvas instead. There's plenty of material available for that. Just google HTML5 game development and see what comes up.

#5293436 responsiveness of main game loop designs

Posted by Khatharr on 25 May 2016 - 02:59 PM

Let me analogize this: You're suddenly asking if it's possible to make a car more efficient by removing the wheels.


You can play around with the loop, but there's no reason to. It's already possible to surpass human limitations for responsiveness. If you're handling input sanely and your frame rate is high enough that the player can see what's happening then the only really good way to screw up responsiveness is to render several frames behind or possibly to just have a crappy control layout. Control issues are usually related to poor game design or implementation issues with things like colliders not matching models or sprites. Networking tricks can also cause trouble if they're implemented incorrectly, but these are all cases where the output is not correctly representing the game state rather than cases where the rendering or input is not being handled fast enough.


At 60 FPS the game is presenting you information every 16ms or so.


Measure your reaction time here:



Even if you float a frame (so that the CPU and GPU can work better in tandem) you only lose a little temporal fidelity. Stretching beyond one frame becomes a timing issue, but 0.016 seconds is barely even detectable, especially for fast moving objects.


Moreover, you're talking about a 3-stage process that loops. Your options are limited here:


A input

B update

C render










But then when you consider that they're looping:




You've only got two options. Treating rendering as the divider you have input-update or update-input.


If you're polling then default to polling before updating because it makes sense to respond to input when you have it. If you're on an architecture that will delay on polling then you may consider moving it to after updating depending on how much time your GPU is taking compared to how much time the CPU takes.


On the other hand, if your input is handled by something similar to messaging then you don't even have to mess with it as updating includes processing queued inputs.


Regardless, even if you poll in the 'wrong' order you shouldn't be able to detect the difference without instrumentation.


tl;dr - If you want your game to feel responsive focus on precise collision and well designed character reactions instead.

#5293422 responsiveness of main game loop designs

Posted by Khatharr on 25 May 2016 - 01:19 PM

You're overthinking this.

#5293122 Mapping a loaded resource fails

Posted by Khatharr on 23 May 2016 - 04:35 PM



That matches one of the error codes in the documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476457%28v=vs.85%29.aspx


Looks like "invalid argument".


Is it possible that the texture does not have mappable usage? http://gamedev.stackexchange.com/questions/102530/how-to-access-raw-texture-data-in-directx-11

#5293113 c++: sprintf but return chars. Possible?

Posted by Khatharr on 23 May 2016 - 03:42 PM


What do you mean "if it fails"?
What i do now with sprintf could then also potentially fail no? I just want to compress the code i need to write. I end up in many such situations (must create a temporary char array that i inject floats and other stuff with %.2f etc and then pass it to a function that takes a "char *" parameter).

The best way to solve this is with a string class of some kind. Otherwise you're going to have a nightmare cleaning up all the heap-allocated temporary strings. Honestly, I think you're pushing the laziness lever a little too hard here. I'd be shocked if your actual coding bottleneck was declaring temporary char arrays.



My suspicion was that the "clutter" and DRY violation was the complaint.

#5292873 c++: sprintf but return chars. Possible?

Posted by Khatharr on 22 May 2016 - 10:25 AM

You could just overload doStuff() with varargs...


*grumble stdio grumble*

void doStuff(const char* formatString, ...) {
  va_list args;
  va_start(args, formatString);
  size_t strLen = vsnprintf(nullptr, 0, formatString, args);
  std::vector<char> buffer(strLen + 1);
  vsnprintf(buffer.data(), buffer.size(), formatString, args);

  //do stuff - your char* is now buffer.data()

or for more general usage

std::string stringf(const char* formatString, ...) {
  va_list args;
  va_start(args, formatString);
  size_t strLen = vsnprintf(nullptr, 0, formatString, args);
  std::string buffer(strLen + 1, 0);
  vsnprintf(&buffer[0], buffer.size(), formatString, args);
  return buffer;

doStuff(stringf("derp %d herp", 42).c_str());

#5291820 Best gaming platform in the future with marketing perspective.

Posted by Khatharr on 16 May 2016 - 06:14 AM

It would be impressive to accurately predict the shape of the market even 3 years from now.

This isn't a market where you go to one place and sit there. It's a market where you run to catch up and then either run to keep up or run faster and innovate.

If you want to know where the demand is at right now then what I've heard from several parties is, "People who can fucking program."

Also, it's a bit cheeky to ask for statistical research on your future career prospects. If you're serious then do your own research or hire someone to do it for you.

#5291739 Learning from Other's Code

Posted by Khatharr on 15 May 2016 - 05:08 PM

Ignorance is not a resource. If you want progress then inform yourself about the problem space and learn why others have done what they did to deal with it.


More to the point, why are you writing an engine if the features are things that you can get from other places? What is it that you actually want to accomplish and how is this the most effective way to get there?

#5291014 Quick help on const

Posted by Khatharr on 10 May 2016 - 01:58 PM


Do you really need a vector of pointers? What do you mean by, "popping in and out from the stack"?

Hmm, I was thinking that I'd rather have the child nodes in the heap instead of the stack so I can control them manually? I don't want them to be destroyed immediately unless I tell them so, which I guess that's what will happen if I put in the stack and they went out of scope or erased/removed? and there will hundreds of nodes allocated, and I don't want to mess with the stack memory for this one? Please correct this lost soul if he's mistaken.  :wacko:



It sounds like you're getting ahead of yourself a bit. Vector allocation is already on the heap, but I don't think this is a heap/stack issue. It sounds like you want to do something unusual with lifetime management. If the 'node' is a POD then just use vector without pointers. The indirection you're introducing here is going to make iterating the vector very costly for no reason. It sounds like these objects have destructors though? I kind of want to know what's going on here, but even in that case you'd probably be better off doing manual mark and sweep if you need delayed destruction (why?).

#5290871 Getting objects within a range (In order, fast)

Posted by Khatharr on 09 May 2016 - 02:45 PM

Well, right up front it sounds like you're just using the wrong container, but setting that aside it sounds like you're taking a naive approach to spatial sorting. What are "chunks" here? Do they move or change in any way?


Why is near-to-far sorting helpful? Do they really need to be in perfect near-to-far order, or can you just throw them in "really close", "close", "not so close", "far" buckets and go from there?

#5290869 How do I measure risk?

Posted by Khatharr on 09 May 2016 - 02:37 PM

Like Briandigitalis points out, a small or single person team can't afford to hire all specialists (business, Artists, Extra programmers) required. I wish I can hire all the business-risk analyst, but for obvious reasons I can't afford to do that. So the next thing to do is to improvise which is do most aspect - meant for specialist - on my own

You don't need to hire someone. You do need to have someone with the skills required to do what you're doing. I'm guessing that you have at least one programmer around the place, since you're doing programming. Well, if you're conducting business then someone needs to understand how business is conducted.

#5290712 How do I measure risk?

Posted by Khatharr on 08 May 2016 - 03:53 PM


n any case, this is work for a project manager and not necessarily a programmer

In a small team you are expected to wear many hats.


Yes. I just don't want to imagine an organization that has formed and operated with no one having any PM experience or training.

#5290570 How do I measure risk?

Posted by Khatharr on 07 May 2016 - 01:58 PM

Risk analysis is one of the major areas of study in the field of project management.


Commonly risk is measured systematically by breaking the project down and trying to list all of the potential setbacks and points of failure, along with a cost and probability for each. You then multiply those cost values by the probability of the risk. High values are risks that most need to be avoided and/or mitigated.


Unfortunately, getting accurate values can only be accomplished through experience. If your organization doesn't have a history to draw on for this then you have to look to similar organizations and try to get data that can be used to make reasonable estimates. This also applies to scheduling. You can make guesses, but they'll almost always be too short. The most reliable way is to base your estimates on data from previous projects. (This falls under the heading of "scope management".)


In any case, this is work for a project manager and not necessarily a programmer. If you're in a fully agile environment it's possible (though unlikely) that you don't have someone with these skills, so that's worth looking in to. If you're interested for your own sake then you may want to poke around for an introductory text on project management.