Jump to content

  • Log In with Google      Sign In   
  • Create Account

nfactorial

Member Since 10 May 2002
Offline Last Active Sep 02 2014 09:48 AM

#5158315 What's a quick way to get a database going for a .net text-based game?

Posted by nfactorial on 05 June 2014 - 01:41 AM

I wouldn't do it that way at all, it'll be full of security holes if you're accessing the database directly from the client.

 

However, mysql (www.mysql.com) would be the immediate replacement for sqllite. There are other options, but mysql is a reasonable first step up from sqllite.

 

As I said, I wouldn't recommend doing it this way. Instead write a simple server application that performs the necessary database queries in response to messages from the client, so that people don't have direct access to the database.

 

n!




#5154754 Trying to load objects one at a time

Posted by nfactorial on 20 May 2014 - 12:59 AM

The first thing that jumps at me is that your class cLoadStreamDataMenuSystem is not aligned. And the address it's complaining about is also not aligned. Try ensuring your cLoadStreamDataMenuSystem begins on an aligned memory address.

 

[edit] Reading back, your class holds a pointer to a matrix rather than an instance. So that's probably not the direct issue, but make sure the OrthographicProjection matrix is aligned. It does seem to be complaining about alignment to me (due to the address ending in F8, which is not 16byte aligned. The typical alignment for vectors and matrices)..

 

n!




#5150917 RefCount and Manager

Posted by nfactorial on 02 May 2014 - 08:19 AM

[Except that upon decreasing a count you may also need to delete/release the resource, and during that whole process you need to maintain a lock.

 

No, you don't need to maintain a lock at all. If it has 0 references, then there is nothing referencing it, so nothing else could actually gain access to it for the lock to protect against.

 

In an atomic operation, you can indeed correctly enter an “if” when it reaches 0 and begin a segment of code to delete the OpenGL ID or Direct3D handle/pointer, except that suddenly another thread is free to raise that reference count back to 1 and then use that deleted resource.

This logic doesn't work sorry, another thread cannot suddenly raise the reference back to 1. Because there is nothing else referencing it for that to be possible.

 

n!




#5150499 c# assigning new int to void*?

Posted by nfactorial on 30 April 2014 - 01:18 AM

The simple answer is you don't, and you shouldn't. Even in C++ you shouldn't do it this way, though you can.

 

There are many alternatives:

 

As someone else mentioned you can make your class a generic, and have the type declared as part of your class. One issue you will get then is that you can't simply make a collection of your objects. To solve that you can use inheritance, by having an ObjectVariableBase which has everything but the value. Then derive a generic from that with the actual variable type. If you want methods specific to the type, then deriving a specialised implementation is also an option (ObjecVariableInt, ObjectVariableString etc).

 

Another option in C# is to use a dynamic method to access the value. However, I feel that's a little advanced for what you're trying to do here.

 

You shouldn't give single letter variable names in the constructor, give them proper names. As ChaosEngine shows in his code, call them 'name', 'description', 'value' or whatever your preference is, just not 'a', 'b' and 'c'.

 

n!




#5148932 Your most valuable debugging techniques for Networked games?

Posted by nfactorial on 23 April 2014 - 06:13 AM

You should have unit tests for all the issues you list. That would eliminate packing/unpacking/applying from your list immediately at the very least.

 

n!




#5148339 Tips on FileLoader code

Posted by nfactorial on 20 April 2014 - 05:37 AM

I wouldn't, in any way, have a file loader class allocate it's buffer the way your code is doing it.

 

1) Code may not want the entire file in memory.

2) Code cannot control where the memory is allocated from.

 

You could, of-course, change the code to take an allocator object of some description. But I personally prefer the buffer pointer to be handed to the read operation.

 

For similar reasons I wouldn't try to hide the Read method away, but also wouldn't provide async and non-async operations into the same object, which confuses the API and can lead to incorrect usage. You could make the read* functions protected, give the object a protected constructor and derive 'AsyncFileReader' from it or take another route.

 

I personally prefer the route of obtaining a stream object and the user creates operations using that object. Allowing them to wait on that particular operation.

For example (pseudo code):

InputStream *stream = OpenInputStream( uri );
if ( NULL != stream )
{
      StreamOp *op = stream->Read( myBuffer, dataLength );
      if ( NULL == op )
      {
          // Error
      }
      else
      {
          // Move into wait state
      }
}
else
{
     // Unable to open stream
}

I actually don't think non-async operations are necessary at all, if someone wants to stall they can just call the operation->Wait() method for development purposes though nothing should be loaded like that in the end, and even then it should be frowned on as it's much harder to patch code to be async down the line.

 

[edit] I can think of many, many different ways of implementing the above code, so please don't take it that I'm suggesting it should be done exactly like that.

n!




#5146883 Paul Nettle's memory tracker mmgr and C++11

Posted by nfactorial on 14 April 2014 - 06:08 AM

As Hodgman says, every engine I've worked with does not use new and delete directly. Instead they define their own macro. Such as MY_NEW (using Hodgmans example).

 

So code then becomes:

MyObject *myObject = MY_NEW MyObject();

Where MY_NEW would be defined something like:

#if defined( _DEBUG )
    #define MY_NEW    new( __FILE__, __LINE__ )
#else
    #define MY_NEW    new

#endif //defined( _DEBUG )



#5136072 What if a client can't run at desired fixed time step?

Posted by nfactorial on 03 March 2014 - 07:06 AM

You pick a time step that can be managed on your lowest spec target machine, if someone runs the app on a machine with a lower spec then it isn't supported. So, it comes down to the developer choosing what spec they are targeting at and writing the game code so that it fits.

 

Options available include reducing or completely disabling non-essential systems based on machine spec. etc.

 

n!




#5123934 Continuous Asset Data Streaming - issues/problems with

Posted by nfactorial on 15 January 2014 - 12:42 PM

WHILE the game is running (NOT some in between splash screen 'level' data loading,

 

Yes, I understand that is what you meant. The streaming technology you mention is fairly common among games these days.

 

What isn't so common is streaming data over the network, but that is more a data and bandwidth issue rather than a software implementation problem. Large amounts of data over the network means your bandwidth requirement goes up by an order of magnitude and thus reduces the size of your target audience, which is the main reason it isn't done rather than any technical limitation.

 

n!




#5123668 shader like graphics programming - ugly

Posted by nfactorial on 14 January 2014 - 02:55 PM

What you are suggesting (drawing lines using custom code) is fun, however the reason graphics cards don't work like that these days is because doing it in such a way is very very slow due to the random access to the display surface required. To get the sheer performance required for the graphics expected (and desired) by games these days, the hardware pipeline must be insanely optimised and being able to freely access pixels as you suggest just isn't practical.

 

However, in some ways it is much simpler to achieve the drawing of a line that you give as an example. Rather than draw the individual pixels yourself, you can ask the hardware to draw the line for you and you simply have to implement how each pixel is coloured. This actually separates the shading from the drawing logic and allows you to write specific shading logic independent of the geometry.

 

Rather than 'ugly' I think the current graphics architecture is fairly elegant. Especially when you take into account the amount of design that has gone into making the pipeline so optimised, far beyond what could be accomplished with the arbitrary writes that you seem to wish for (and, I'd wager, you'd like reads to go with those writes? It just isn't efficient for the hardware).

 

n!




#5123263 Help on a Light pre pass renderer

Posted by nfactorial on 13 January 2014 - 06:50 AM

You shouldn't have AlphaToCoverage enabled. Change to:

 

desc.AlphaToCoverageEnable = false;

 

n!




#5123156 Confusion over model-view matrices

Posted by nfactorial on 12 January 2014 - 05:20 PM

The model matrix transforms coordinates from object space to world space as you say.

 

However, the *view* matrix is generally the inverse of the camera transform. So if your camera had no orientation but existed at 10,10,10 the *view* transform would be a -10,-10,-10 translation. You can visualize it as transforming the coordinate space such that the camera is located at the origin (0,0,0).

 

The code you posted is just concatenating the model and view transforms together, so that the matrix represents a combined transform that results in a point in object space being transformed into view space (and it doesn't bother multiplying them together if the object-to-world transform is an identity transform (personally, I wouldn't bother with the test)).

 

n!




#5121841 Filmic Tone Mapping Questions

Posted by nfactorial on 07 January 2014 - 01:36 AM

Hey,

  I use Hables tone-map operator in my own engine.

 

Just to begin with, I'd suggest using a constant luminance rather than a calculated luminance. You can add the calculated luminance back in once you're happy with the results of the tone-map. This will just help you concentrate on the tone-mapping without the luminance confusing things further.

 

Looking at your shader, I'm curious as to the line:

vec3 curr = Uncharted2Tonemap(texColor.rgb*2.0);

And wondering why you're multiplying your colour by 2? As it seems odd, especially as this is after you have calculated the pixel luminance and applied the exposure, but maybe there is a reason I'm missing.

 

Also, the constants in your luminance calculation seems incorrect, in my code it looks:

float L = max( dot( texColor, float3( 0.299f, 0.587f, 0.114f ) ), 0.0001f );

Those are the major differences I see, but they could be the result of something else your renderer is doing that I don't know about

 

n!




#5120619 Making 23040000 linecasts per second might be too taxing for the CPU

Posted by nfactorial on 01 January 2014 - 11:09 PM

I would just pre-calculate which cells are visible from each cell and store it as a bitmap representation in the level file and RLE encode it Then you wouldn't need to do any raycasts at all.

 

I can think of a lot of alternatives actually, but that one jumped out at me immediately :)

 

n!




#5119085 Node based shader graph system for a deferred renderer

Posted by nfactorial on 24 December 2013 - 02:15 PM

No, I didn't say what you've just said.

 

Shader graphs do not (in general, they can if that's how you implement it) spit out an uber-shader. You have different graphs for different things, and so you have different shaders.

 

I'm also not understanding about your query on deferred shading, they can be used fine for any rendering approach. And you don't really use 'multi-pass' in deferred rendering so I'm not sure what you're querying there sorry, perhaps you mean something else?

 

As for the U4 shading system, it's nice but they have a lot of experienced developers working on it. The best you can do is look through their documentation, they aren't doing anything particularly special there (which I don't mean any offence to U4. I mean, it's just a [nice] shader graph!). Perhaps if you ask something specific you're interested in?

 

As for implementation details, it's quite a big system for such a broad query. You would have a 'graph node' object with inputs and outputs, and the ability to connect them together. Then you run through the graph and say 'Ahh, this node warps the xy coords' and spit out the code for doing that. You'd also need code to manage the variables used in the shader, and inputs (such as textures) etc. This would always be done in the editor, with the final game just having the final generated shaders.

 

n!






PARTNERS