Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 17 Jul 2007
Offline Last Active Feb 15 2012 01:02 PM

Posts I've Made

In Topic: Font drawing problem

15 February 2012 - 12:21 PM

The nHeight isn't really how tall the font should be if it is a positive value, it's how tall the cell of the font is, which is slightly different.
Mostly I guess people who use the Truetype fonts negate it to use the actual height in pixels of the font. The most common thing is to use other
methods to write text, I guess. If you want to use "flashier" Truetype fonts in your game you can include your own in your game and load it from memory
with a few calls, without bothering to have to install it on the target system. For that you can check out the "article" section on my site:


In Topic: PIX output not the same

08 May 2011 - 12:57 PM

Capture a replayable stream from your application for a short time and analyze that you're getting the expected results.

In Topic: Memory Leak Problem

08 May 2011 - 12:49 PM

Another good tool that may be useful to search for misc problems with your (or another) application is
Microsofts Application Verifier (AppVerifier). You can download it here:

A quick how to (for xp) can be found here (maybe not up to date):
I think there's a good help file included as well.

Start with basic tests, this app has some quite complex tests that can bring your computer to the cpu speed of a stone :-)
(If I remember correct the memory tests (at least heap) is included in basic tests)

In Topic: Page Faults in PIX

06 May 2011 - 08:43 AM

Yes, my opinion is that you should ignore it.

In Topic: Creating a Tile-Based Map

05 May 2011 - 01:56 PM

I'm going to stick out my nose and post some code here, I hope I won't regret it as I might have to try to explain it :-)

What the.......I have just released my first DirectX game and most game graphics (tiles) as public domain so I can post
some code as well :-) This is how I draw the tile map in my game, but there are some stuff declared outside this
function so you'll have to think a bit anyway....See it as some kind of pseudo code......Post if you need additional info.

From the beginning my intention was to post the source code as well, but it simply grew too big, and if I would start
over today with the experience I got after this game I'd change some stuff in the code for sure......Enough, lets jump
to the exiting part....

// The function below writes the tile map (if one exists) to
// the back buffer. There might be situations where no tile map
// is present, for example if only an animation is played.
// We only check for top and left tile clipping where we set
// negative display coordinates so they are partly or totally
// clipped by the viewport we set up. The right and bottom tiles
// are clipped automagically by our viewport.

void Gfx_PresentMap (void)
int iScreenX=0;                             	//Screen X offset for writing tile map
int iScreenY=0;                             	//Screen Y offset for writing tile map
UINT uiTileNumber;                          	//Tile number to write to screen
int iTileDivX, iTileDivY;                   	//X and Y divisions for tile map number calc
int iTileModX, iTileModY;                   	//X and Y modulo for rect calc within tile
int iScreenDivX, iScreenDivY;               	//Tile to write within screen position
int iTotalX, iTotalY;                       	//Calculate total tile offset
BOOL bFirstX=TRUE;                          	//TRUE if writing first tile row in X position
BOOL bFirstY=TRUE;                          	//TRUE if writing first tile row in Y position

// Return if no tile map exist for this level
if (g_LevelInfo.uiTileSizeX==0 && g_LevelInfo.uiTileSizeY==0) return;

iTileDivX=World.uiMinX/TILESIZE;            	//Calculate X offset within tile map
iTileModX=World.uiMinX%TILESIZE;            	//Calculate X modulo offset within tile map
iTileDivY=World.uiMinY/TILESIZE;            	//Calculate Y offset within tile map
iTileModY=World.uiMinY%TILESIZE;            	//Calculate Y modulo offset within tile map

while (iScreenX<HSIZE)                      	//Write all tiles in X position
   iScreenDivX=iScreenX/TILESIZE;           	//Calculate X offset within screen offset
   iTotalX=iTileDivX+iScreenDivX;           	//Calculate total X offset within tile map
   iScreenY=0;                              	//Reset Y screen offset
   bFirstY=TRUE;                            	//We are writing first tile row in Y position

   while (iScreenY<VSIZE)                   	//Write all tiles in Y position
  	iScreenDivY=iScreenY/TILESIZE;        	//Calculate Y offset within screen offset
  	iTotalY=iTileDivY+iScreenDivY;        	//Calculate total Y offset within tile map

  	uiTileNumber=(UINT)iTotalY+(g_LevelInfo.uiTileSizeY*(UINT)iTotalX); //Index within tile map

  	// Correct tile number if we have clipped the first tile in
  	// X or Y position.

  	if (iTileModX && !bFirstX) uiTileNumber+=g_LevelInfo.uiTileSizeY;
  	if (iTileModY && !bFirstY) uiTileNumber++;

  	// Calculate out of screen top tile clipping
  	if (iTileModY && bFirstY) iScreenY=0-iTileModY;
  	// Calculate out of screen left tile clipping
  	if (iTileModX && bFirstX) iScreenX=0-iTileModX;

  	// Write the tile on screen, skip space tile, which is hard-coded by
  	// design at tile map value == 0.

  	if (g_LevelInfo.byTileMap[uiTileNumber]!=0)
     	Gfx_WriteTile (iScreenX,iScreenY,g_LevelInfo.byTileMap[uiTileNumber],NULL);

  	iScreenY+=TILESIZE;                   	//Increase Y offset
  	bFirstY=FALSE;                        	//We are not writing clipped Y tile anymore 
   iScreenX+=TILESIZE;                      	//Increase X offset
   bFirstX=FALSE;                           	//We are not writing clipped X tile anymore