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

#5082164 Getting notified when fullscreen mode is interrupted

Posted by on 01 August 2013 - 04:59 AM

In your windows message loop, you can listen for events of type "WM_ACTIVATE" and "wParam == WA_INACTIVE".

See the msn documentation for details.


This will solve only part of your problem though, because it won't work for all the possible cases:

  • For alt-tab and windows-key, you will receive a WM_ACTIVATE event.
  • For ctrl+alt+del and lock screen (windows-key + L) you will not receive an event.


So, if you really want to catch all possible cases where your fullscreen mode is interrupted, you have to do what Medo3337 pointed out:

In regular time intervals, actively check the state of your window and/or your display device. This might seem inconvenient, but I have found no better way.

#4986836 Drawing in 2D with DirectX 9 - Sprites?

Posted by on 04 October 2012 - 12:50 PM

ID3DXSprite::Draw has a D3DCOLOR parameter and the default texture stage states are set for modulation, so you could use a 1x1 white texture and set this color appropriately for untextured drawing.

Thank you for this hint - I didn't realize I can do that.
Starting with a white texture is really a cool trick.

Now I'm using a white "blueprint" texture for primitive drawing, then add color via the "sprite.Draw" method. This makes life a lot easier indeed, because I don't need to create and manage multiple textures for the purpose of primitive drawing.

If anyone else has other / better ideas, I would be glad to read about it.

#4986835 Drawing in 2D with DirectX 9 - Sprites?

Posted by on 04 October 2012 - 12:42 PM

Are you strictly limiting yourself to 2d?
I ended up just drawing everything 2d as primitives in my engine I did and subverted LPD3DXSPRITE all together.

The graphics of my game are 2D, which means everything is drawn flat and there is no depth. I wouldn't mind using 3D functions for programming however, if they are suitable for my needs.

The problem I currenty have with 3D functions is that I couldn't find a way to render images. How did you handle that in your engine? Image I have an image of a red dragon, stored in a png file on disk - how can I print that to the screen?

#4986530 Drawing in 2D with DirectX 9 - Sprites?

Posted by on 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