Jump to content

  • Log In with Google      Sign In   
  • Create Account


Jason Z

Member Since 04 Feb 2004
Offline Last Active Sep 14 2014 06:40 AM

#5177475 Game development for Oculus Rift, where to start?

Posted by Jason Z on 01 September 2014 - 01:04 PM

I actually integrated Rift support into Hieroglyph 3.  It wasn't too difficult, and took about two days worth of work.  I utilized their documentation and their sample programs to see how to interact with the SDK.  Admittedly, the documentation isn't fully descriptive, but there is enough content to get the idea.




#5177128 What is your development environment?

Posted by Jason Z on 30 August 2014 - 05:23 PM

1. Win7

2. Win7+

3. C++11 and Visual Studio 2012

4. DirectXTK and Lua

5. Rendering Framework

6. Nothing - I am content with the tools that I am using, which is why I chose them :P

 

I am using Direct3D 11, so my use case may not be what you are looking for.  But anyways, the entire tool chain is free, so it is at least an option for beginners or indies.




#5174814 Best way to traverse a 2d array to dertermine the winner in Tic-Tac-Toe

Posted by Jason Z on 19 August 2014 - 01:58 PM

 

While the solutions posted here are really interesting, is it really the best thing to tell a beginner to use low level bit operations to check if someone wins at tic-tac-toe?  I would recommend just iterating through the board, checking each of the possibilities (as already mentioned, 3 horizontal, 3 vertical, and two diagonal).  Once that is working, then you can start to try to optimize the solution (i.e. create separate functions for each type of check, build incremental lists of winning moves, or whatever). 
 
However, all of those are just for learning - I can't believe that a check that is done once for each of the 9 moves in a game is really a candidate for doing abstract optimizations...


I have written code for a lot of board games. The first thing I do is come up with a board representation, a move representation, and functions to make moves, undo moves, generate moves and check for end-of-game conditions.

If you are writing a GUI where these things will only be needed once per move in a game, you normally don't have to think about it too hard, and any naive implementation will do.

But if you are writing any type of AI, you are going to have to consider gazillions of moves internally, whether you are using minimax, MCTS or something else. The performance of those basic routines really does matter, and there are clever implementations to be found for pretty much every game I can think of.

Tic-tac-toe is a learning tool, and it's a good opportunity to learn how to think of these clever implementations as well.


EDIT: One more thing: This is not the "For Beginners" forum. The thread I linked to was in "For Beginners", and I was reluctant to describe the fancy bit-manipulation method there.

 

That is a completely valid point - I was just making an observation based on the nature of the question from the OP.  Like I said, you solutions are really interesting, and they may just be what the OP was asking for.  I just thought for the game at hand it was slightly more than what was required.




#5174681 D3D11DeviceContext::DrawIndexed Does'nt Draw anything

Posted by Jason Z on 19 August 2014 - 05:14 AM

Just  a follow up, if you pass an integer to the std::vector constructor, it will create a vector with that many elements in it that are default constructed if you don't pass a second value.  This is called the 'fill' constructor.  Since UINT doesn't have a default constructor mechanism, you end up with the contents of memory in your vector.

 

See #2 here: http://www.cplusplus.com/reference/vector/vector/vector/




#5174102 D3D11DeviceContext::DrawIndexed Does'nt Draw anything

Posted by Jason Z on 16 August 2014 - 10:04 AM

Some common things to check are:

 

1. Your geometry is being transformed out of the viewport (possibly due to matrices being incorrect).

2. Your geometry is being culled by the back face culling check in the rasterizer (test this by disabling back face culling).

3. Your pixels are being discarded by the depth test (are you clearing the depth buffer each frame?).

 

Most of these cases can be found quickly with the graphics debugger (on Win8) or perhaps PIX (on some Win7 systems without the platform update).




#5174097 Best way to traverse a 2d array to dertermine the winner in Tic-Tac-Toe

Posted by Jason Z on 16 August 2014 - 09:53 AM

While the solutions posted here are really interesting, is it really the best thing to tell a beginner to use low level bit operations to check if someone wins at tic-tac-toe?  I would recommend just iterating through the board, checking each of the possibilities (as already mentioned, 3 horizontal, 3 vertical, and two diagonal).  Once that is working, then you can start to try to optimize the solution (i.e. create separate functions for each type of check, build incremental lists of winning moves, or whatever). 

 

However, all of those are just for learning - I can't believe that a check that is done once for each of the 9 moves in a game is really a candidate for doing abstract optimizations...




#5172443 Creating resources in D3D11 with alignment constraints

Posted by Jason Z on 09 August 2014 - 06:22 AM

There is no way to do this through the Direct3D 11 API - the actual memory location and alignment of the resource is up to the driver / runtime to determine, and you don't have access to it directly.  I assume that slide is talking about the use of CUDA, rather than D3D11.

 

This is likely to change with Direct3D 12, which is supposed to give you significantly more robust control over the memory resources used by the API.




#5172442 Thread-safe weak pointers

Posted by Jason Z on 09 August 2014 - 06:17 AM

It's good that you found a solution to your problem, but I also agree with Andy.  When you say that you have to handle when a resource may or may not be available, then that means you need to check if it is there every time you use it.  In the case of a weak_ptr, you are just wrapping the checking part into the smart pointer - but you are still checking *every time you use it*.

 

Is that what you really want?  If you just put a simple resource manager layer in between your client code and your renderer, then you can easily maintain the lifetime of the resources for the duration that they are actually used.  The resource manager can pass out index based references to resources, with a method called getResource.  That can contain a simple count of the number of times the method has been called for each resource.  When code says it is done with the resource, it can let the resource manager know with releaseResource, which decrements the count.  Once you know that all outstanding references have been released, then you can actually delete the resource. 

 

This follows the advice above to make it easy to use right, but you have to try to do it wrong.  It makes the references simple objects (just integers) which are lightweight, reduces the need to constantly check for resource existence, and nobody can directly delete the resource.  That seems like a pretty good way to achieve what you are trying to do!




#5172439 Particle "Engine"

Posted by Jason Z on 09 August 2014 - 05:52 AM

For an example (using D3D11, but still useful for you) of this type of particle system, check out the ParticleStorm demo from Hieroglyph3.  That will show you one way to use append/consume buffers and compute shaders to make a particle system.




#5172438 I know a good amount of C++ but what do i need to know about game programming?

Posted by Jason Z on 09 August 2014 - 05:49 AM

First of all, you should know that it is normal for being overwhelmed when you get started in a new area of programming.  Even if you know a particular language, it can be quite difficult to sit down and read the designs for a particular industry.  So don't stress out about it - just take it one piece at a time and make progress.

 

I think the other advice that was already given about learning how the main loop works is a good place to start.  Once you know that, then you can move on to the update method and all of the things that are done there - rendering, then audio, etc...  But make a concerted effort to only concentrate on one topic at a time, and you will be able to digest the information more easily.




#5169289 C++ avoiding pointers

Posted by Jason Z on 26 July 2014 - 07:33 AM

 

EXACTLYYYYY finally one man on earth understands programming. damn. why is it so hard to make people forget about those damned rule of 3/5 ?


Not knowing the rule of 3/5 is like not knowing for loops. You have a giant gaping hole in your knowledge just waiting to come along and bite you on the ass.

There are a great many situations where the "rule of zero" will not work conveniently without you implementing the appropriate containers or proxies (which need to obey the rule of 3/5, by the way) in order to have your "rule of zero." Two examples where you need non-trivial handling of objects where the standard library is lacking convenient containers: handle duplication and COM with proper reference handling, unlike most DirectX code.

 

This, plus the rule of zero depends on your compiler being able to automatically generate appropriate default equivalents for move ctor/assignment operator.  That isn't available everywhere just yet (although the situation seems to be improving).  Many people will be using older compilers, so you can't blindly forget about the rule of 3/5.




#5168384 How dangerous is returning a initialized pointer in C++?

Posted by Jason Z on 22 July 2014 - 09:21 AM


Second, and more importantly, on some systems (notably one major desktop operating system), shared libraries have (or may have) their own heap.
All the more reason for stack allocation!


#5168341 [Depth buffer] From linear -> non-linear depth values

Posted by Jason Z on 22 July 2014 - 04:52 AM


Retrieving the result via the original projection matrix is an option yes, but for educational purposes I was interested in the equation.
This is obtained by using the original projection matrix, and just taking the z component.  As long as you know how your projection matrix is constructed, then you would have the symbolic equivalent of your equation quickly and easily!


#5168288 How dangerous is returning a initialized pointer in C++?

Posted by Jason Z on 21 July 2014 - 08:55 PM


Actually, I think I'm starting to fall in love with smart pointers! I always loved the smart ones. At first it was confusing because I wanted to get the functions I made within that class or struct - you know? I never knew how until I read the tutorial about C++ 11 smart tutorials. I was a bit naive about the std::shared_ptr. So, I tried it on the graphics device struct and there was no worries about ever freeing up the initialized class - just had to dispose the COM objects created by DIrectX. Pretty sweet!
Smart pointers are a great tool, but remember what they are implying - they implement ownership semantics for the object they are wrapping.  If you have a shared pointer to your engine API object, then you are essentially saying that any object that has a reference to it is also an owner of it.  That means that if you have one outstanding reference, the object will not be destroyed.

 

That can be what you want in many cases, but the usage you point out above is not really one of those (at least in my humble opinion!).




#5168285 Converting STL heavy static library to shared

Posted by Jason Z on 21 July 2014 - 08:51 PM


If the STL usage is kept to the library's implementation and is only used internally for implementation, then would it still introduce problems?
If you are 100% certain that the STL usage of the shared library is only internal, then you are ok in theory.  In reality, that is usually pretty hard to isolate and it takes some serious dedication to make sure non of your interface exposes STL types in any way.  In addition, the types of bugs that can be produced with this include memory corruption which can be notoriously difficult to track down.

 

My advice is that unless you are absolutely certain that you need a shared library, stick with a static library.  If you must use a shared library, make sure that your projects are always compiled in tandem with the same settings.  If you are using Visual Studio, this is pretty easy to do with the configuration management system, but easy to mess up if you manually introduce compilation flags in one project but not in the others.






PARTNERS