Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Slig Commando

Member Since 01 Sep 2010
Offline Last Active Yesterday, 01:37 PM
-----

Posts I've Made

In Topic: My ever-evolving coding style

19 May 2013 - 05:30 PM

Honestly I like returning pointers for most cases. Using the pointer you dont have to make a thousand function calls. Especially in parallel programming this is very useful when you want to avoid static variables. Sometimes its not a good idea, or not even possible depending on the use, but I believe this is a perfectly valid programming habit. IMO

You do realize that that method destroys your ability to enforce class invariants? And that it has no advantage over simply making your members public (and has the disadvantage of being clunky and a really non-obvious and non-idiomatic way of modifying an object)?And that this doesn't do anything to help avoid static variables (how is this even related to static variables?)?

 

There might be a few exceptional cases where it's a decent idea, but it should be just that, exceptional cases. If it's your preferred/common method... something is wrong.

 

It is all dependent on what it is you are programming and what the expectations of that program are. To say their are only a few exceptional cases where you would return a pointer and that it has no advantages is purely based on ones own perspective.

 

My current, long term project is a game engine I have been working on for some time now. The overall goal is parallelism. Being able to pass off a single object pointer to multiple subsystems so that each can do its work at the same time, to me, is an intelligent design. Whether it is the object itself, or maybe just the draw location of a game entity being passed to the physics engine and to the player for keyboard input(gravity must be applied, force from other physics objects may be applied, and the player keyboard input all effect the final draw location of an in-game object). Of course their are cases where placing locks on certain members of that object are necessary, but the overall advantage I feel outweighs any syntax or non-obvious issues that may be encountered.


In Topic: My ever-evolving coding style

15 May 2013 - 08:22 PM

void frobnicate()
{
    CFoobar *foo = new CFoobar();
    
    //Fixed
    int* var = foo->GetFoo();
    *var += 7;

    double thing = *foo->GetBaz();
    // etc...
    
    delete foo;
}

 

Honestly I like returning pointers for most cases. Using the pointer you dont have to make a thousand function calls. Especially in parallel programming this is very useful when you want to avoid static variables. Sometimes its not a good idea, or not even possible depending on the use, but I believe this is a perfectly valid programming habit. IMO


In Topic: Programming RPG's 2nd Edition SOURCE CODE?

22 March 2013 - 09:58 AM

Having VC++ express has nothing to do with it. You might be getting hundreds of compilation errors, but all of those could be caused by only one actual error. Make sure you are linking to all your required libraries. Also, just start down the error list. If one error doesnt make sense when looking at the source, more than likely that error is not your root problem.


In Topic: Making UI text look good with ID3DXFont?

28 November 2012 - 02:42 PM

I am not sure because I have never worked with ID3DXFont, but if you could run the draw call through a shader program you could apply anti aliasing, color adjustments and other effects to make the text look better, but I think generally you are going to be better off rolling your own font/text engine.

In Topic: How to implement the blurring/fading effect to the rendered content

28 November 2012 - 02:35 PM

Google "Percentage closer filtering"

PARTNERS