All Blog Entries

All blog entries, ordered from most recent. Entry count: 1198.

Warning! Some information on this page is older than 6 years now. I keep it for reference, but it probably doesn't reflect my current knowledge and beliefs.

Pages: > 1 ... 51 52 53 54 55 ... 150 >

# Deeper Look Inside Windows

Thu
01
Jul 2010

Typically Linux users spend much time dealing with details of their system while Windows users blame all errors on bad Microsoft and Bill Gates, especially nowadays as for more and more people computer usage shrinks only to a web browser. But sometimes it's nice and useful to look into the system, deeper than to the list of files on disk or installed programs in Control Panel / Add or remove programs. Here are some Windows applications that may help with that (use Google to find them by name):

Starting with tools that ship with Windows itself, we have:

More information about the system can be revealed with free programs, like:

Do you know any other tools like these or other types of system information that are worth seeing?

Comments | #windows Share

# Timespan from/to String Conversion

Tue
29
Jun 2010

Today I'd like to show a piece of code I've written today. These are functions for converting between a timespan, stored in a int64 as number of milliseconds and string in for of "HH:MM:SS.MMM" (hours, minutes, seconds, milliseconds). That's IMHO a convenient way of presenting timespan to the user. I'll include these functions in the next version of my CommonLib library, to work with raw millisecond number as well as TIMESPAN and/or GameTime types.

The code is in C++, uses STL string and my own StrToUint and UintToStr functions. All suggestions about how these algorithms could be optimized are welcome.

 

 

 

Comments | #algorithms #c++ Share

# Programmer Incompetence?

Fri
18
Jun 2010

Today I'll be a little more philosophical, of course in terms of programming philosophy ;) I manage a long list of Web addresses I'd like to visit in my free time (which I gather mostly from Twitter) and today I've visited these two places:

They reminded me of my old thought that on the way of mastering the art of programming there is no such thing as diversity - no place for personal preferences that would be only a matter of taste, like favorite music. There is usually only one correct path. All the good practices and solutions are just a function of what do you want to do and what technologies do you use. I constantly learn stuff, interact with programmers better than me as well as observe and talk to these who just start their adventure in the programming world. From all these experiences I can see that there usually is a single, correct solution or the way of thinking about simply anything. The one who doesn't agree with it is just not "mature" enough to be able to see that. Another sad truth is that this "maturing" process cannot be accelerated - one can read about the "correct" way but just rejects it until he will come to it by himself.

I especially like the 5 Stages of Programmer Incompetence entry. Here is my self-diagnosis against its points:

Comments | #software engineering #philosophy Share

# DirectX SDK Size History

Wed
09
Jun 2010

I've just done something of questionable usefulness, but anyway, here it is: a sphreadsheet showing how the size of a setup file changed in each version of DirectX SDK, from Summer 2004 until freshly released June 2010.

DirectX SDK Size History @ Google docs

It's not suprising that generally the size is growing, from about 150 MB in 2005 until 571 MB in the most recent version. And it's just the size of the setup file. After installation, my DXSDK_Jun2010 directory has 1.22 GB. Here is more detailed analysis of what exactly takes some much space, done with great and free program called WinDirStat. As you can see, Samples subdirectory is the biggest part of it.

Comments | #directx Share

# Smarty Cheatsheet

Fri
04
Jun 2010

I knew about this before, but today I've found some time to deeply study Smarty - a free template engine for PHP. Templates in webdev (not to confuse with templates in C++) look like an interesting concept, because they separate PHP code from HTML code. I wish I used them from the start during coding my homepage and the www.gamedev.pl website instead of print()-ing HTML tags directly...

Anyway, I've written a small Smarty Cheatseet. Of course it makes sense only after studying the original library documentation, it cannot replace it.

By the way, I was also looking for some PHP library for creating RSS or ATOM feeds and I've found Feedcreator. Now I'm going to make something useful with it...

NEW: This "something" is an RSS feed for newest screenshots uploaded into www.gamedev.pl website: Feed Warsztat - Screeny, as well as for projects: Feed Warsztat - Projekty.

Comments | #webdev #php #libraries Share

# New Font Style

Thu
03
Jun 2010

Just as a reminder: I manage quite long and frequently updated list of links to websites related to game programming and graphics programming, especially blogs of professionals in these fields. If you share my interests, I strongly recommend regular visiting them, because there (as well as on Twitter, however strange it may sound) you can find most recent, interesting, important and professional information.

Visiting various websites and reading what people say is good for many reasons. For example, I've just changed the style of my website, inspired by the font used on Blobs in Games page. How do you like this new looks?

NEW: Thanks for comments. I went back to the old font.

Comments | #web Share

# Calculating AABB of a Rotated 2D Rectangle

Wed
02
Jun 2010

Today I've solved an interesting geometrical problem of calculating an AABB rectangle (Axis-Aligned Bounding Box) around an oriented rectangle (rotated by an angle) in 2D.

AABB of a rotated 2D rectangle

It seems simple but it's easy to come up with suboptimal solution like calculating all 4 corners of the rotated rectangle or calling sin and cos functions multiple times. So I've coded a simple demonstration in ActionScript 3 (Flash). Here is my algorithm:

Input data:

// Center position of the rectangle.
private const m_PosX : Number, m_PosY : Number;
// Half-width and half-height of the rectangle.
private const m_HalfSizeX : Number, m_HalfSizeY : Number;
// Rectangle orientation, in radians.
private var m_Orientation : Number;

Algorithm:

// corner_1 is right-top corner of unrotated rectangle, relative to m_Pos.
// corner_2 is right-bottom corner of unrotated rectangle, relative to m_Pos.
var corner_1_x : Number = m_HalfSizeX;
var corner_2_x : Number = m_HalfSizeX;
var corner_1_y : Number = -m_HalfSizeY;
var corner_2_y : Number =  m_HalfSizeY;

var sin_o : Number = Math.sin(m_Orientation);
var cos_o : Number = Math.cos(m_Orientation);

// xformed_corner_1, xformed_corner_2 are points corner_1, corner_2 rotated by angle m_Orientation.
var xformed_corner_1_x : Number = corner_1_x * cos_o - corner_1_y * sin_o;
var xformed_corner_1_y : Number = corner_1_x * sin_o + corner_1_y * cos_o;
var xformed_corner_2_x : Number = corner_2_x * cos_o - corner_2_y * sin_o;
var xformed_corner_2_y : Number = corner_2_x * sin_o + corner_2_y * cos_o;

// ex, ey are extents (half-sizes) of the final AABB.
var ex : Number = Math.max(Math.abs(xformed_corner_1_x), Math.abs(xformed_corner_2_x));
var ey : Number = Math.max(Math.abs(xformed_corner_1_y), Math.abs(xformed_corner_2_y));

var aabb_min_x : Number = m_PosX - ex;
var aabb_max_x : Number = m_PosX + ex;
var aabb_min_y : Number = m_PosY - ey;
var aabb_max_y : Number = m_PosY + ey;

Files to download:
AabbTest01.swf - online Flash demo
AabbTest01.zip - full project source code

I believe it can be optimized further (not only by rewriting it in C++ :) Anyone knows how?

Comments | #math #flash Share

# Problem with Object Names

Sun
30
May 2010

At least I've started coding my new reflection system which I hope to use for all the stuff I do at home. I'll write about all the assumptions and decisions behind it another time, but today I'd only like to share my thoughts about a little problem I have with object names. I want my abstract base class for all objects to return its name/title to be shown as the name of a tree node in the editor. But interface should theoretically be separate from implementation, so I want an object to be able to simply store its name in some string field or alternatively to build it each time from some internal parameters. Now the question arises how should the interface for fetching this name look like? It turns out to be nontrivial problem in C++, even if I use STL strings instead of char*. Two solutions are possible:

virtual GetName1(std::string &out) = 0;
virtual const std::string & GetName2() = 0;

If some object type stores its name in a std::string Name; field, solution (2) is better because it just returns a reference to its name.

std::string Name;
virtual const std::string & GetName2() { return Name; }

Solution (1) would involve unnecessary copying of the string each time it is fetched:

std::string Name;
virtual GetName1(std::string &out) { out = Name; }

But if an object wants to build its title from some parameters, solution (1) is better:

unsigned Param1, Param2;
virtual GetName1(std::string &out) {
  out = "Params: " + UintToStr(Param1) + ", " + UintToStr(Param2);
}

Using solution (2) here is possible only if we cache built string in a field. Lazy evaluation could be done here. It's not very bad idea, but involves more coding.

unsigned Param1, Param2;
std::string CachedName;
virtual const std::string & GetName2() {
  CachedName = "Params: " + UintToStr(Param1) + ", " + UintToStr(Param2);
  return CachedName;
}

Obviously the simplest and most "universal" solution with just returning std::string by value is inefficient in each case because it involves lots of copying.

virtual std::string GetName3() = 0; // Boo!

Finally I've decided to use (1), but I don't like the thought that such problem exists. In C# we wouldn’t have to make a compromise, because there strings are immutable, passed by reference and automatically freed by the garbage collector. We can just do this and the implementation is efficient in every situation:

abstract class Base {
  public abstract string GetName();
}

class Derived1 : Base {
  private string Name;
  public override string GetName() { return Name; }
}

class Derived2 : Base {
  private uint Param1, Param2;
  public override string GetName() {
    return string.Format("Params: {0}, {1}", Param1, Param2);
  }
}

Comments | #c++ Share

Pages: > 1 ... 51 52 53 54 55 ... 150 >

[Download] [Dropbox] [pub] [Mirror] [Privacy policy]
Copyright © 2004-2026