Jump to content

  • Log In with Google      Sign In   
  • Create Account

Bearhugger

Member Since 05 May 2007
Offline Last Active Yesterday, 07:23 PM

Topics I've Started

Using SQL for Templated Data

13 February 2016 - 08:30 PM

First, I want to say I'm not an SQL pro. Nested SELECT queries were new to me until mid-January.

 

Anyway, I'm looking to implement a system where I can create new objects by basing them on other ones and then change only the fields I want to change while maintaining the link to the parent for the other fields. That way, if I change something at the parent level, the changes automatically propagates to the children unless they have an explicit value for that field. Sort of like a prefab, but a prefab that can itself inherit another prefab, forming a sort of inheritance tree.

 

I've seen something like this being used in Blizzard's RTS map editors starting with Warcraft 3, and this is something I could use for my own projects since I deal with a lot of data.

 

I know how to implement this in C# and C++, but I'm not sure how to do it at the database level. I can see a table where a line having a NULL for a particular field means to look up the parent's properties (and if it's NULL for the parent, go see the parent's parent, and so on), but when I have things like a many-to-many or one-to-many relation, I'm not quite sure how to do it with a relational model. I want the children to be able to add items to a list of items, or to just replace the list.

 

Is a relational database suitable for storing this kind of data model, or should I use something else to serialize the data? I know that Blizzard uses XML to represent this so it half-answers this question.


CMake and OS X

15 May 2015 - 03:05 PM

I'm running into problems trying to setup my game for the Mac OS X platform. The game compiles just fine, but when I try to run it I get a dyld: Library not loaded error.

 

On Windows I can just copy the DLL in the binary directory and the app will happily load them, but OS X seems to be a lot pickier about how it links to dylib that are not preinstalled with OS X. I know that I can use the install_name command to manually set the library's absolute path, but that's obviously not portable and will only be useful for debugging purposes.

 

I suspect that the correct way to do that on OS X is to create an app bundle and put your dylibs in it along with your app, but what's the proper way to do that with CMake?


Handling shaders without D3DX

28 April 2014 - 12:55 AM

Hi, I have a graphic rendering engine in DirectX9. Since D3DX has been deprecated, I'm working on removing it from the engine.

 

I was previously using ID3DXEffects to handle shaders. Without effect, it looks like I have to handle vertex and pixel shaders separately. This is not a big deal since I'm not using vertex shaders much anyway (2D game).

 

My problem is that, looking at the D3D9 API, there doesn't seem to be a way to access the different variables I am using in my shader. There is the IDirect3DDevice9::SetPixelShaderConstant family of methods, but they identify the parameters by index instead of a string. I'm not sure how I'm supposed to get the table that maps a variable name with its index? Another problem is I'm not seeing a function to set a texture variable in my code. I assume it has to do with samplers, but there's still an index I'm not sure what to do with.

 

Should I just assume that D3D9 is old so it's okay to use a deprecated (old) library (D3DX) with it, and stop worrying about having D3DX? Quite frankly, it looks like D3D9 shaders were designed to be used with D3DX, and it's hard to find doc about how to not use it since DirectX9 is starting to get old.


Map Editor: XNA vs SlimDX vs SharpDX

24 September 2013 - 03:21 PM

My game editor uses Windows Forms's GDI+ to draw levels, but it is kind of slow and limited so I'm looking at using Direct3D to draw my maps.

 

Simple question. Which API between XNA, SlimDX or SharpDX would be best suited for a 2D game editor. XNA seems a little overkill but it was built by Microsoft and tons of games have been built on top of it so it seems stable, plus it has the audio built-in too. Then there are SlimDX and SharpDX that are basically thin wrappers around the DirectX API and seem much more lightweight. Both seem to do the same thing. (Is one better than the other?)


Need advice on TDD approach

06 September 2013 - 06:20 PM

I'm trying to apply the TDD approach to an I/O library that I'm writing to manage custom archive files that contain my game's resources and assets. This is a learning process so I'm trying to follow the rules of TDD rigorously, but I'm falling on a few issues for which I don't see an easy way out without breaking TDD. I'd like to have some advice on this.

 

 

TDD says "test behavior, not implementation", but when the whole point of a class is its implementation, how does TDD go about it? I'm asking this because in my game's I/O library, I have the OutputStream class which is the base class for all stream objects that write output somewhere, and then I have the BufferedOutputStream that implements buffering and flushes the buffer when it's full. (Into another OutputStream that may be a FileOutputStream, a MemoryOutputStream, a mock object for unit tests, etc.)

 

Basically, I'd like to test that the buffering works, but this is about implementation, not about behavior. It's easy to test that the Flush method works by using a mock object for the buffered stream's output and checking that its Write method is called, but how do I test that the actual buffering works correctly? The simplest method to make every tests pass is to just not bother with buffering and write the input directly in the output stream. Or more realistically, I could have a bugged buffering algorithm that flushes the buffer when it is not full, and I don't know how I could write a unit test that fails without breaking encapsulation and knowing volatile and private implementation details such as the size of the buffer. This is obviously private stuff, and if I add public method to change and access the buffer, I'm breaking encapsulation, bloating the API and potentially adding more ways to break the object's internal state.

 

 

 

Also, I'd like to know if I'm right to assume that classes and methods that interface directly with the operating system cannot be tested until integration tests, and thus should not be written until then? Again, in my I/O library, I have the FileOutputStream which is a specializtion of the OutputStream that writes to files. Sounds like I have to break TDD principles, otherwise I'll never write that class without unit tests.

 


PARTNERS