MDX driver doesn't load PNG image to surfaces in full screen mode
As a first AgateLib project, I decided to try expanding the "Getting Started" program to display an image, loaded from a PNG file, that tracks the mouse movement. I've included the code below. When using the MDX driver in windowed mode, the PNG image is loaded properly. But when using MDX in full screen mode, the PNG isn't loaded, and the surface shows a white rectangle instead of the expected image.
I've discovered through experimentation that the MDX driver seems to honor the image surface's color, alpha, and rotation properties regardless of mode; only the image loading itself seems to be affected. I've also discovered that the OTK driver loads the image correctly regardless of whether windowed or full screen mode is used. Finally, I tried a couple of different PNG images, some with transparency and some without, and all had the same issue.
So, am I doing something wrong, or is this a bug? (Or possibly an issue with my computer?)
Btw, this is a Vista system with a GeForce 9600 GT, and I'm using Visual C# 2008 Express Edition to compile.
- using System;
- using System.Collections.Generic;
- using AgateLib;
- using AgateLib.DisplayLib;
- using AgateLib.Geometry;
- using AgateLib.InputLib;
- namespace TestAgateLib
- {
- class HelloWorldProgram
- {
- [STAThread]
- static void Main(string[] args)
- {
- {
- setup.InitializeAll();
- if (setup.WasCanceled)
- return;
- DisplayWindow wind = DisplayWindow.CreateFullScreen("Hello World", 1152, 864);
- // Run the program while the window is open.
- while (!(Display.CurrentWindow.IsClosed || Keyboard.Keys[KeyCode.Escape]))
- {
- Display.BeginFrame();
- Display.Clear(Color.DarkGreen);
- mySurface.Draw(Mouse.X, Mouse.Y);
- Display.EndFrame();
- Core.KeepAlive();
- }
- }
- }
- }
- }
Update: After further experimentation, I found that if I call
Core.KeepAlive()before loading the surface, the image is correctly displayed. I'm not sure if this is the correct way to do things or not, but it seems to work. I just wanted to mention it here in case anybody else encountered the same problem.I have created an issue to track this problem here: http://www.agatelib.org/node/159
This is probably due to DirectX's neat ability to simply discard surface memory when you don't want it too. I've been meaning to fix that issue in a more serious way but that will take a bit more coding effort than I have had time for lately.