Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


NightCreature83

Member Since 21 Feb 2008
Offline Last Active Today, 07:14 AM

#5215471 Returning a true in a function that has a bool return type

Posted by NightCreature83 on 09 March 2015 - 01:14 PM

How about you print a  seperator in between consecutive executions of the if statement that should help too.




#5215384 Returning a true in a function that has a bool return type

Posted by NightCreature83 on 09 March 2015 - 02:41 AM

Depending on your environment another possibility is that you have a situation where the source code doesn't actually match the object code you're debugging. In that case a full rebuild may eliminate some weirdness. 

This is usually the first thing you should do when you encounter something that doesn't make sense. The other thing you can do is look at the assembly code that is being executed and see if it doesn't jump to the wrong location.




#5214932 When and how do I start graphics? (C++)

Posted by NightCreature83 on 06 March 2015 - 05:56 AM

I took the jump in at the deep end path of learning GL and DX, and just did an internship for a company where I ported a OpenGL renderer to D3D9c. The benefit of doing this was that I didn't have to deal with setting up a pipeline to be able to render stuff that all existed, I could just focus on learning D3D and GL




#5211132 Modern game development/programming for a not-quite beginner?

Posted by NightCreature83 on 17 February 2015 - 02:16 AM

If you are doing C/C++ I would start with writing 64 bit code, this is not inherently different from 32 bit code with the exception that you don't expect data types to have specific sizes. If you start to think that data types have specific sizes like a pointer being 4 bytes you are in for some surprises in 64 bits where this length doubles. Not doing this means your code is easier to port between 32 bit and 64 bit, as in mostly recompile and fix minor issues.

 

If you go with a managed language this generally doesn't matter, specially with Java or C# as they compile into byte code, and its up to the VM to deal with 32/64 bit issues mostly.

 

IDE wise on Windows and C#, C/C++ stick with Visual Studio, the 2013 CE version is Pro version so you get everything most professional devs have. On OSx I would go with Xcode, *nix you have eclipse or netbeans (there are probably others too), I prefer the latter one but thats a GUI thing mostly. I know of several coders that actually never use an IDE and just use Sublime, Vim, Emacs or your own preferred text editor and command line tools for the compiler and debugger which is an other option to go.




#5210906 Disassociate mouse with its position

Posted by NightCreature83 on 15 February 2015 - 07:19 PM

You have to listen to raw input for this too work, Raw input will just give you the absolute movement or relative movement from the previous position. From what I have seen from my clickpad and logitech mouse is that it will give you relative position updates and these have no border. So you can actually move your mouse indefinitely and you will get updates from that direction.

 

Dont inmplement Direct Input, MS tells you not to use direct input for mouse or keyboard input and use instead use Raw input.




#5210438 best and fastest way to understand a code written by some one else

Posted by NightCreature83 on 13 February 2015 - 02:55 AM

First thing I would do is actually install doxgen or another code documentation generation tool, and graphviz dot package and generate me a documentation well that contains inheritance and composition graphs. From there you will get an overall view of how the classes and code is connected, so the overall architecture.




#5210243 Modern game development/programming for a not-quite beginner?

Posted by NightCreature83 on 12 February 2015 - 05:33 AM

I would stay away from snake (python) the duck typing of the language and the interpreter teach a few bad behaviours that you are better of not picking up. Seeing you already have programming experience I would go with C# or C/C++ the major difference between the two is that you do not have to do everything yourself in C#. Everything you know about C/C++ pretty much directly translates to C#, with maybe the only real exception that a struct in C# is a value type like an int.

 

If you worked with C++98 not that much has changed in the language, it just become a bit more standardized STL now pretty much behaves the same on the 3 major implementations (MSVC, GCC, Clang). C++11 added some handy features like nullptr instead of 0, functions to create smart pointers and such, you pick this up fast enough and there are a million resources out there online. http://www.cplusplus.com is a good one and it will show you the differences between 98 and 11 on most of its references.

 

If you are purely looking into writing a game I would advice you to use a game framework so you dont have to deal with all the boiler plate code and can just start writing your game. Anything from a full game engine like UE4 to helper frameworks like SFML, SDL, SlimDX, monogame will do for this stuff and will speed up your work. The major difference between the engines and the frameworks is that you will still have to deal with connecting up the frameworks yourself, were in the engines you can just start creating content and gameplay code.

 

If you are more interested in doing all of this yourself just grab the latest windows SDK which will contain the DirectX sdk and start writing that boilerplate code yourself.




#5209984 What's the point of obfuscating managed code?

Posted by NightCreature83 on 11 February 2015 - 04:50 AM

The act of obfuscation is not done on the original code in the source control section only done on the final build machine and never gets checked into your source control. The reasons behind it are that it is hard to find proprietary solutions to problems.

 

I dont think you should have any problems debugging because if you sync to the release label of your source code and just attach to the remote symbols, it should be able to match up with your actual source. It should in theory compile down into the same IL as nothing more than variable renaming has happened.




#5209686 Code written inside a Render() loop

Posted by NightCreature83 on 09 February 2015 - 04:07 PM

 


What I am asking is don't these non changing definitions inside a running loop consume extra cpu time? Or does the computer somehow know it only needs to deal with them once even though they are declared in this constantly running body of code?

 

Actually you should clear the render target everytime before you draw something on its buffer, but that doesn't mean that's the only way do that it is to create a bgColor variable inside the function.

 

This is simply not true, if you know that all the geometry in your scene is going to cover the whole back buffer than not clearing the back buffer saves quite a bit of time, and this is general practice in games. In debug builds its often a good idea to actually use alternating colors, and clearing in generally, this will catch not covering the whole buffer fast.

 

Generally the compiler will optimise this stuff away anyway in a release build, it will most likely see that it can directly pass the arguments to the Clear call. These things are micro optimisations to start writing this different. Its a lot clearer if the code is written like you have presented it and letting the compiler figure out how it can do those 3-4 lines faster.




#5209683 Enemy Bullets

Posted by NightCreature83 on 09 February 2015 - 04:03 PM

I would use a sprite or solid circle/rectangle and make that move in the directions the enemy would be shooting in.




#5209598 Calling virtual abstract class function

Posted by NightCreature83 on 09 February 2015 - 08:41 AM

If you are on a C++11 compliant function its a good idea to add the "override" key word to any virtual function in a derived class, this will make the compiler check whether you are actually overriding a base class function and not just be accident adding another virtual function to the chain.

 

Can you actually post the exception message you get in the output. I am suspecrting that the pointer you are trying to call this function on is a null pointer, and that is the cause of the crash.




#5208362 Render To Texture

Posted by NightCreature83 on 03 February 2015 - 04:07 AM

The backbuffer is nothing special its just a texture as long as one is bound the present call will present the content of it to the front buffer and display.




#5207570 Profiling tools

Posted by NightCreature83 on 29 January 2015 - 06:08 PM

Well, Visual Studio comes with one built in that you could start with.

This one sadly does only whole timeline sampling and I would like to get those samples ordered a bit different, specially on a per frame basis not sure the VS filters allow this sort of profiling. The documentation for the VS profiler seems geared towards managed application profiling, I am more interested in native profiling, if you have better documentation for the VS Profilier that info is more than welcome.

 

Ok finally found this stuff in VS its a bit hidden but the info can be found here: https://msdn.microsoft.com/en-us/library/windows/desktop/jj585574%28v=vs.85%29.aspx

The trick is to tell VS to do a CPU and GPU sample based profile at the same time, and then setting the time frame to the time it took to render one frame. Sadly this is not ideal, specially since you have no control over how many samples the profiler will do per second.




#5207113 Confused about XMFLOAT2 and D3DXVECTOR2

Posted by NightCreature83 on 28 January 2015 - 03:22 AM

The reason behind this change is that the DirectMath, XM* stuff, supports SIMD instructions which allow you to add 2 vector4 together in one operation. SIMD liberaries are constructed in such a way that they keep all of the data in XMM registers on the CPU. This means that the operations like +, -, * and / are implemented as standalone functions that return a XMVector and takes two XMVector arguments.

 

https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.arithmetic.xmvectoradd%28v=vs.85%29.aspx




#5206563 Is it a very bad idea for a class to pass (*this) into a function? Strange bu...

Posted by NightCreature83 on 25 January 2015 - 11:16 AM

There is something else going on.  C++ programs use *this all the time.

Vector2d& Vector2d::operator= (const Vector2d& param)
{
  x=param.x;
  y=param.y;
  return *this;
}

There should be no problem pass a (this*) to a function.  

 

 


Also, I know that "this" is a pointer... and since * is used to dereference a pointer, does that mean passing (*this) is pass-by-value?

 

As far as this part goes, it can be confusing.  C++ function arguments are always "pass-by-value".  Everything that goes into a function is copied.  That's why you pass a pointer or reference instead of an object.  It can be a lot cheaper to copy a 32bit pointer than a huge object.  For instance, when you pass a pointer and then access the thing it points to, you are using a copy of the pointer that points to the same object.

 

As an example, what does this do?

void func( int* intPointer ) {
   intPointer = new int{2};
}

void test() {
   int x = 4;
   int* intPointer = &x;
   func( intPointer );
   std::count << *intPointer << std::endl;
}

If the int* was passed by reference, then we have changed it to point to a different value.  Is that what happens?

Just as a point but a pointer is not necessarily 32 bits and you should never ever write code that actually relies on the exact size of a pointer. This is what causes a lot of bugs in software when switching from 32-bit to 64-bit.

 






PARTNERS