Jump to content
  • Advertisement
Sign in to follow this  
Captain Nuss

Direct3D GUI Implementation

This topic is 4862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently in the process of developing a 2D game engine using C# and Managed DirectX, as an OOP exercise and to learn about DirectX and graphics programming in general. Plus, there are some small games I'd like to program, so... Anyway, I have the engine up and running with DirectDraw. It's got a working implementation of a GUI. (screenshot) Games will be implemented by subclassing my Window2D class and thus providing a window where sprites will be drawn on. Thus, everything resolves around windows. Since DirectDraw doesn't allow me to do things like alpha-blending, I'm trying to provide an implementation using Direct3D. I spent the last two days trying to get up to speed with Direct3D and looking at other peoples' implementations of GUI subsystems. The DirectX SDK example didn't really help in this matter since the code is barely documented. Right now I'm thinking about going with the following approach: Use one texture per window. Draw the content of the window onto that texture and use the Sprite class to blit the textures onto the screen. The good thing about this approach is that I'll have to redraw a window only when it's marked as dirty. If it isn't, I can just leave its texture untouched and map it onto its set of vertices again, thus this approach will be very fast. The downside is that my textures will be 1024 pixels in width and height. There will never be more than 10 windows open at the same time (and even that is highly unlikely) and today's computers have enough video memory. So, what do you think? Is there a better way I'm missing? Or does this approach sound reasonable to you?

Share this post


Link to post
Share on other sites
Advertisement
That is a good idea, but I think you can do something about the textures. If each window has a maximum size, you can simply make the texture the size of the window. Then, just use the Sprite class to draw the texture on the screen at its current position. This will be much more effective than creating full-screen textures for every window.

Share this post


Link to post
Share on other sites
Thanks for the reply, circlesoft. The texture size actually is the thing I'm most worried about as well. I was worrying that I might have to use multiple smaller textures per window, which would have made the code a lot messier. Anyways, what you're proposing is a good idea. I'll just use the smallest possible texture size that my window will fit in.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!