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!


Member Since 20 Jul 2013
Offline Last Active Jun 24 2015 07:25 PM

#5230236 Sound Effect using SlimDX.Directsound

Posted by ericrrichards22 on 21 May 2015 - 05:36 AM

I haven't played with the DirectSound parts of SlimDX yet, but in general, SlimDX is just a thin wrapper over the underlying DirectX C++ APIs.  Get a .NET decompiler plugin, like JustDecompile or dotPeek, and you can peek into which DirectSound functions are being called by the SlimDX functions.


From there, you can find some C++ examples (usually far easier to turn up than C# SlimDX code samples), and convert it over.

#5225902 Why Does Everyone Tell Newbies To Make Games?

Posted by ericrrichards22 on 27 April 2015 - 01:44 PM

It's actually harder to jump in and get started writing games now than when I was learning.  My programming class had a bunch of even-then ancient 486 clones, and we did MSDOS with QBASIC.  We wrote lots of shit code, but when its as easy as doing SCREEN 13, LINE x1,y1,x2,y2 to get stuff up on the screen, it's easy to try stuff out and do crazy things.


Haha, makes me remember how I used to draw filled circles for a checkers game I wrote by drawing concentric circles using the parametric circle equation and going from r to 0...

So slow, and there were always aliasing issues that left uncolored pixels.

#5225407 Dx11, directxmath and d3dx

Posted by ericrrichards22 on 25 April 2015 - 04:51 AM

I would suggest learning Assimp for model loading.  Luna uses a custom plain-text format, from what I remember, which is not bad for showing the general idea of mesh formats, but doesn't match anything that you'll see out in the wild.  While you could write your own model loaders, and you might want to if you have full control over your art pipeline, the support that Assimp has for a wide variety of formats out of the box is pretty strong.

#5225306 Steam's compensated modding policy

Posted by ericrrichards22 on 24 April 2015 - 01:59 PM

I wonder how this will work with, for example, Total War games.  Many of the mods for the last couple of iterations of their games have been simple mods to enable content that shipped with the base game, but was disabled so that CA could release it in drips and drabs as DLC.


A lot of mods are also potentially in a grey area with respect to IP, particularly total conversions.  If Steam is going to be charging for those mods, I imagine the IP holders are going to come after their cut more aggressively than for something hosted for free on moddb.

#5224395 A brief discussion on design: handling visibility

Posted by ericrrichards22 on 19 April 2015 - 07:36 PM

What about something like the system of sailing directions or "Rutters" that were typically used in that era?


Say, you send a ship off to do some exploring.  They map out where they've been, reach whatever destination, and then head back to port.  Until they have successfully returned to port, the knowledge that that unit has gained about the world is limited to just that unit.  Once they get home, the knowledge that they have gained starts to disseminate, but, again, any ships that are already at sea shouldn't instantly receive the benefit of that information, they would have to return to port first and update their charts.


This could end up being a pretty big headache to keep track of...


It might make for some interesting mechanics though.  Say, you know your enemy has sent an exploration fleet out to scout out the New World.  Rather than having to do your own scouting, maybe you could ambush their fleet on the way back home, and steal their charts, denying them the benefit, and getting it for yourself.  Except maybe the sailing instructions are coded, and you need to do some espionage/research/coerce or bribe the enemy captain to get the full benefit out of them.

#5223445 Constant buffer for shaders in SharpDX

Posted by ericrrichards22 on 15 April 2015 - 09:52 AM

I usually use the Effects Framework support, which I prefer but its a slightly different way of doing things if you are using straight shaders.


Under the covers, I believe all that is really happening is that the bytes that make up whatever data you are sending to the GPU get marshalled to a native byte array and uploaded to the constant buffer.  Usually you define a C# struct with [StructLayout(LayoutKind.Sequential)] or LayoutKind.Explicit, and set that up to match the structure of your cbuffer.  Then you update your struct with any changes, do a UpdateSubresource, then set the Buffer to your shader.


I personally use SlimDX, but SharpDX is pretty much the same.


Another useful thing I often do when I'm having trouble is to install dotPeek and go look at the source of the method that I'm are currently using to get an idea how it works under the covers.  

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

Posted by ericrrichards22 on 13 February 2015 - 09:10 AM

+1 for the idea of using Doxygen.  Even when there are no doxygen-ish comments attached to functions or fields, it can extract a lot of very useful information from just the call signatures.  Also, generating the call-graphs can be an easy way to get a high-level view of how the code is organized - unless it is a real disaster, I would expect to see a number of more or less distinct subsystems that you could drill into.

#5210485 XML Serialization

Posted by ericrrichards22 on 13 February 2015 - 08:59 AM

Personally, I like to write explicit Parse() and ToXml() functions for the objects that I want to serialize, so that I can have more control over the structure of the XML and handle some things that are more difficult with the default xml serialization (I'm not a huge fan of the attribute magic you sometimes have to get into, serializing private members, things that don't have default constructors, fields that don't need to be serialized, etc).


Generally, I find the XDocument/XElement/XAttribute way of handling XML in C# (System.Xml.Linq) to be more friendly than the XmlDocument/XmlElement/XmlAttribute way (System.Xml), but your mileage may vary.

#5210114 Set/Get array of value using effects framework C#

Posted by ericrrichards22 on 11 February 2015 - 03:15 PM

Not sure about SharpDX, but in SlimDX, you can do something like this:

SlimDX.Direct3D11.Effect FX = ... // Create an effect from the device and shader bytecode

// Assuming gBoneTransforms is a float4x4 array and _boneTransformsArray is a SlimDX.Matrix array
_boneTransforms = FX.GetVariableByName("gBoneTransforms").AsMatrix();


#5207586 Some programmers actually hate OOP languages? WHAT?!

Posted by ericrrichards22 on 29 January 2015 - 07:32 PM

Still... what might "well-coded" games in C look like? Or would it be quite close to a game in C++ but mostly just without the encapsulation given by things like access modifiers, and semi-advanced concepts like templates?


You can download the source code for most of the older Id games on GitHub.  Prior to Doom 3, they used plain C (or C with assembly in the older titles).  I'm not a C jock, so I won't speak for how "well-coded" these are by modern standards, but its clear enough that I can read through and understand most of what is happening without struggling too hard.


From what I remember, at least the Quake engine is laid out in a sorta-vaguely object-oriented fashion, although it would probably be more correct to say it is component-oriented.  There are variables associated with the memory allocator, and functions that perform various actions operating on them, allocating chunks of memory, freeing chunks, getting the next available chunk, and so on.  Same for the renderer, or the resource loader, or the console, etc.  So you can still have separation of concerns, but you have to enforce them.  Again, IANACJ, but I believe you can also use static globals in a .c file to restrict visibility of a variable to just code within that file.


You can also do some templatey stuff if you use macros in C.  Whether that is a good idea, well...


EDIT: Ninja'd!

#5207346 Constant Buffer matrix array not updating.

Posted by ericrrichards22 on 28 January 2015 - 11:12 PM

Not pertinent to your question, but do you really have 96 influence bones?


96 turns up a lot, probably because it is the number of bones supported in the shader from the chapter on skeletal animation in Luna's DX11 book.

#5206866 Some programmers actually hate OOP languages? WHAT?!

Posted by ericrrichards22 on 27 January 2015 - 02:16 AM

Functional programming languages are the new hotness these days.  If you read HackerNews, every day you'll see somebody pimping their latest Haskell/Clojure/Lisp/Scala (not much love for F#, oddly) re-implementation of something that was written 30 years ago in C.  


On the other hand, OO has been tarred with the brush of twenty years of Enterprisey Java where AbstractFactoryAdapterFactoryFacadeFactories and other such abuse of the Gang of Four design patterns book have been allowed to run amok.  Also, I would agree that object-orient programming is taught in a really awful way, because they always want to fill your mind with the hairy bits that are not terribly useful in practice.  Class hierarchies more than two layers deep are, in my mind, a code smell, unless you are writing a big framework library.


C# is a nice language because it does give you the option of picking and choosing what paradigms you want to support. If you want, you can write straight procedural code, using static classes as pseudo namespaces to let you stick your procedures somewhere.  If you want, you can also write very functional C# code, and particularly LINQ is quite functionally-inspired.  You can also write very OO code.  Or you can do all three in various mixtures to match what you need.

#5206857 3D Box Texture Coordinates

Posted by ericrrichards22 on 27 January 2015 - 01:40 AM

There is a very good example of how to do this from Introduction to 3D Game Programming with Direct3D 11.0.  You can download the source code from there (it's the Source Code Set 1 link).  In the zipfile open up Common/GeometryGenerator.cpp and look at the CreateBox function.


This uses the 24-vertex approach that Buckeye mentions.  It also has functions for generating vertices and indices for spheres, cylinders and geospheres as well.  

#5205937 C#: leaving unused reference-types

Posted by ericrrichards22 on 22 January 2015 - 01:26 AM

Just go with the List for now, and profile later if you have problems.


I agree, do the simplest thing first.  If it turns out to be slow, you can profile and determine the bottlenecks later.


Beware of making preemptive micro-optimizations that sacrifice the simplicity of your code until it is necessary.

A fair amount of the advice that you will commonly come into contact with, particularly in game programming, is from the perspective of C/C++, and, as often as not, dates from a decade ago or earlier.  C++ and C# share curly braces and a lot of keywords, but they are not exactly apples-to-apples.

#5131515 Old school 3D engines

Posted by ericrrichards22 on 15 February 2014 - 05:23 AM

Fabian Sanglard (http://fabiensanglard.net/) has done a series of articles digging through various older now-open-source games and engines, including Wolfenstein, Duke Nukem, Second Reality, Another World, and Quake.