# About Managed DX and Form components

## Recommended Posts

As part of an experiment in implementing user interfaces for a game, I've set up a graphics class that initializes stuff related to Direct3D and a ui class that sets up the user interface, with both classes making use of the same form object. My UI class is made of an array of random components such as a TextBox , panel, or ListBox. At the moment, the UI starts off with a single visible component, makes another component visible depending on which option is clicked, and makes a component disappear when the 'back' option is selected. I don't know if it's just me or my system specs (P4 1.3Ghz, 128MB DDRAM, GeForce4) or the Windows Forms API, but it seems that the program takes a bit long to initialize compared to a simple "hello world" Direct3D windows form. Another issue I've noticed is that when using methods like Graphics.FillRectangle, there is a noticeable flickering when used in a Direct3D application. Why is this, and what can be done to stop the flickering? Is it a good idea to use Windows Forms components with Direct3D, or would I be better off making my own UI from sprites / getting a 3rd-party UI?

First off, you're really scraping the bottom of the barrel specs-wise with only 128MB of RAM. It's been half a decade since that was a reasonable amount of memory for a development computer. Memory is dirt stinking cheap; save up $40 and get yourself 512MB, or as much as you can cram in your box. That'll help immensely. Pretty much no version of Windows since 98 can run comfortably in so little RAM. The rest of your specs are low, but RAM is certainly the killer. Also note that any .Net apps will have slightly longer startup times than others due to Just In Time compiling. This usually only makes a big difference the first (or maybe second) time you run the program, but keep in mind that every time you change your code you basically have a "new" program and thus incur the JIT expense again. On an older processor with so little RAM, it's thoroughly possible that this will produce noticeable delays. Mixing Direct3D and the Graphics routines is not advisable, since the Graphics stuff is basically a wrapper over the Windows GDI (Graphics Device Interface). The GDI uses a totally different set of routines to draw, and is in general a lot slower than DirectX. Note that this shouldn't cause problems if you are drawing outside the area that you are using to render in DirectX; you'll only see issues if they overlap. If your drawing code is drawing to a different area on the screen and still flickering, it's probably not connected to DirectX (try disabling your DX code and see). Look into double buffering to eliminate flickering in that particular case. As for blending WinForms and Direct3D - I had it in the back of my mind that there was an "official" way to do this that even supports skinning, but I wasn't able to find it quickly on Google, so I'm not sure what to say there. #### Share this post ##### Link to post ##### Share on other sites I know that my 128MB of RAM is very low for today's programs, but due to the replacement costs of this type of RAM, I'd have to spend at least$90 to upgrade to 256MB. It's expensive to replace, since it's some kind of RAM with a metal plate on the chip, has two gaps in the middle, and has to be installed in pairs. I'd have already upgraded if it was only \$50 to do so.

About the GDI+ calls in DX, I don't think setting the Form's double buffered property to true really helps that. I've tried it and still had noticeable flicker for graphics objects drawn on screen such as pens and filled primitives. At any rate, substituting a TextBox and placing text replaces a filled rectangle and drawn text without flicker, so unless it's just as slow or slower than GDI, I'll keep using Form controls for the UI.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628320
• Total Posts
2982072

• 21
• 9
• 9
• 13
• 11