Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 09 Oct 2004
Offline Last Active Aug 04 2013 07:12 AM

Topics I've Started

Taskbar aero preview not working with DX9 fullscreen mode

01 August 2013 - 03:49 AM

Hi folks,

I've written a 2D game client in C++ using DirectX/D3D 9.
In case you want to try, you can get it here: http://darkfire-rpg.com/download.html

By default, the game runs in fullscreen mode, at a resolution of 800x600.

When the user leaves the application while running, for example using the alt-tab keys, the application is reduced to the taskbar.

In this state, when the user hovers with the cursor over the taskbar icon, a thumbnail and preview image of the application should be displayed. That's a feature of the "windows desktop manager", also known as "aero effect". In my case, these preview images are always blank and I couldn't find a good way to fix that. (Please note that the problem is limited entirely to the fullscreen mode - in window mode the preview images work perfectly.)


Attached File  taskbar_preview_blank.jpg   31.91KB   3 downloads


When the application is moved to the background (while in fullscreen mode), the device object I am using (IDirect3DDevice9) goes into the state of a "lost device" (D3DERR_DEVICELOST). In that state I cannot execute any drawing operation. Only after the application is activated again by the user (returning into the foreground), the application is able to "reset" the device and continue drawing. I suspect this might be the root of the problem: As the application is unable to draw while in the background, the preview images which supposedly reflect the current "screen" state, are also blank.

If that was true, how to fix it? - the behaviour of the device cannot be changed in that regard. I experimented with a mechanism that would automatically switch the application to window mode while in the background. That produced lots of unwanted side effects however, leaving the impression of a bad hack.

I also experimented with the windows desktop manager api. Using it allows for example to set a static bitmap for the thumbnail preview in the taskbar. Unfortunately, the windows desktop manager api is not available on windows XP, so when using and linking it, the application won't run on XP anymore.


Did anyone else run into this problem?

What is the proper solution?

MORPG "Darkfire Legends" is now online

24 November 2012 - 09:25 AM

Hi everybody,

My MORPG "Darkfire RPG" is now online and waiting for players.

The graphics are 2D and retro-style - This has to do with my limited artistic skills, but also with inspirations from old games like final fantasy, secret of mana, diablo and crossfire.

There are plenty of options to customize you character and create a build that is truly unique:

  • stat point distribution system, bound to level-ups
  • an abundance of rare magical items to collect
  • skills to learn
  • runes can alter and improve skills
  • "alternative" character classes, like the mutant or robot

In order to play the game, please download and run the windows installer (msi):

The client "should" run on windows xp, vista, 7 and 8.
Fullscreen mode will attempt to use a resolution of 800x600 - which should be supported by most devices.
So far, it is tested only with windows vista and 7 - please report back when you have troubles installing or starting the game.

Any kind of feedback is most welcome!

Special thanks to the gamedev community for supporting me with technical knowledge in several occasions.

You will find many more infos on the website:



Drawing in 2D with DirectX 9 - Sprites?

03 October 2012 - 02:44 PM

I would like to develop a 2D game client in c++ and windows, with DirectX 9.

Most of the graphics are stored in png format, hence I found textures to be very useful (easy to load png files with "D3DXCreateTextureFromFile").

In order to be able to draw the textures on the screen in 2D, I used one sprite (LPD3DXSPRITE). This seemed like a simple solution and works perfectly fine for textures.

Now I would like to additionally draw some colored rectangles in between the drawing of images. Surprisingly for me, sprites in DirectX don't support any kind of primitive drawing. There is only one "Draw" method that will render a texture to the display device.

So far I've been pondering about the following solutions:

1. Create textures that contain a certain area of solid color. Then draw any kind of rectangle by aligning the small single-colored textures next to each other. I guess it will work but seems really cumbersome, as I will need to write lots of code to manage the color textures and do the drawing.

2. Find a better way to draw my images to the display device, so that i can mix the image-drawing with primitive drawing operations. So far I couldn't figure out how to do it. I suspect I will need some kind of intermediate "surface" object to draw my texture on.

3. Mix sprite drawing operations with device drawing operations. This would require to split up my drawing code to use many different sprites for different purposes. I will need to call sprite.Begin/End very often. On the whole I don't like this idea because it seems "messy".

Thank you for any kind of feedback that will point me in the right direction! Posted Image

winsock: is gethostbyaddr needed?

07 January 2006 - 02:26 AM

What I want to do is create a network socket connection from a client application to a server machine, with winsock. I used the following code, which is more or less taken from manuals (see msdn, winsock examples):
// on windows, initialize WSA first

// 'szServerName' is a char-string, containing either host name or IPv4 address
struct hostent *hp;
unsigned long addr;
struct sockaddr_in server;

if ((addr = inet_addr(szServerName)) != INADDR_NONE) {
    // get host by address
    hp = ::gethostbyaddr((char*)&addr, sizeof(addr), AF_INET);
else {
    // get host by name
    hp = ::gethostbyname(szServerName);

if (hp == NULL) {
    LOG("hostname '" << szServerName << "' is unknown");
    close(); // close connection
    return false;

// connect to server, using address in 'hp->h_addr'

The problem: I am running a DSL-router with two machines attached, forming a small LAN subnet. I'm trying to connect from one machine to the other, with above code, using IP-address. The target machine is firewalled by the standard windowsXP firewall. The connection fails because gethostbyaddr returns NULL. I think the target machine's firewall might be blocking the call to gethostbyaddr. The connection does work if I use gethostbyname, in spite of passing an IP-address. It also works if I take the address returned from inet_addr, and force-feed it into the server struct ('server.sin_addr.s_addr = addr'). Now I am wondering, why the heck should I even use gethostbyaddr if it's only giving me trouble? I don't actually care about the host name, all I want is a working connection. Is it wise to do it like this?:
// on windows, initialize WSA first

// 'szServerName' is a char-string, containing either host name or IPv4 address
struct hostent *hp;
unsigned long addr;
struct sockaddr_in server;

if ((addr = inet_addr(szServerName)) != INADDR_NONE) {
    // take specified IP address without questioning
    server.sin_addr.s_addr = addr;
else {
    // get host by name
    hp = ::gethostbyname(szServerName);
    if (hp == NULL) {
        LOG("hostname '" << szServerName << "' is unknown");
        close(); // close connection
        return false;
    server.sin_addr.s_addr = *((unsigned long *)hp->h_addr);

// connect to server, using address in 'server.sin_addr.s_addr'

Another alternative may be using gethostbyname ALL the time. The msdn site claims this wouldn't work with IP-addresses, but apparently it does. I have never seen anything like this in any socket tutorial I could find though. That makes me wonder wether I'm wrong after all, and should stick with gethostbyaddr for some reason I don't yet understand? Thank's for help! [smile]

problem with SDL_DisplayFormat

17 December 2005 - 01:53 AM

I'm fairly new with SDL. What I want to do is load an image and display it. For fast blitting, I convert it to the display format using SDL_DisplayFormat. Here's how I load my image:
// initialize SDL first...

SDL_Surface *image = IMG_Load("image.png"); // load image
if (image != NULL) {
    // convert to display-native pixel format, for fast blitting
    SDL_Surface *dfImage = SDL_DisplayFormat(image);
    if (dfImage != NULL) {
        LOG("with = " << dfImage->w << ", height = " << dfImage->h << ", pitch = " << dfImage->pitch);
        if (dfImage->pixels == NULL)
            LOG("pixels NULL!");
As I have indicated, I initialize SDL before executing this code. When I call SDL_SetVideoMode with flags SW_SURFACE, then everything works fine and the output appears to be correct:  with = 76, height = 67, pitch = 304 When I call it with flags SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN, then I get the following:  with = 76, height = 67, pitch = 320  pixels NULL! Why is the pixels data NULL in this case? The surface seems to be unusable that way. And why is pitch 320 instead of 304? (Note: 76 width * 4 depth = 304 pitch) Is it not possible to convert pixelformat to a hardware-surface? I thought it's just the same, converting to 4 byte color depth. I'm using WindowsXP, VisualStudio, Cpp, SDL for graphics and an NVIDIA GeForce FX 5200 graphics card, if it matters. Thanks for help! [smile]