Managed dx9 engine design

Started by
2 comments, last by Mykre 19 years, 1 month ago
In unmanaged code you'd write your TexturePools and such for your media to remove data duplication. Is anything of the sort already implemented in managed code, or will i still have to write those? (c# dx9) Are there any other design things i should keep in mind when writing an engine under C# dx9 or should i just stick with the same design as with c++ dx9?
Advertisement
Yea, you have to check it yourself. Managed DirectX is basically DirectX wrapped into DirectX, everything you can do in DX you can do in MDX and vice versa.
Ollie"It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]
x_o You don't have to tell me stuff i already know, i'm just asking as to how would i have to rethink an engine design when it comes to texture management, mesh management etc... and if mdx has any pool design already made. I found an object called Resource though and meshes seem to have meshmanagers etc.

I was just curious if the Texture object had builtin reference counting or such so i wouldn't have to worry about loading the same texture twice, hence not needing to write a TexturePool class.

I just need to know as to how far Tom Miller and his crew took the "management" part of C# dx9 concerning resource/memory management.

For example, if i had 100 models that needed to be loaded. All of these models share textures here and there and by just loading them in following the guidlines i'd have loaded 99 copies of the same blody texture if atleast one subset of each model shared the same texture. That's not acceptable, everyone knows that, that's why you write TexturePools and such. That's why i'm asking if those type of obvious things were made for the MDX to cut back on development time.

If i were to load a Texture a; and then pass Texture b = a; If i dispose/cleaned up b would a's data still be there? Will b reference a or make a copy of all the data?

[Edited by - Cybrosys on March 2, 2005 8:49:42 AM]
Try this,

using System;using System.IO;using System.Collections;using Microsoft.DirectX;using Microsoft.DirectX.Direct3D;namespace Tankers{    /// <summary>    /// The texture pool class    /// </summary>    class TexturePool    {        // Constant texture path        private const string TexturePath = "Textures\\";        // The hash table of valid textures        private static Hashtable textureTable = new Hashtable();        /// <summary>        /// Create a new texture, or return one from the pool        /// </summary>        /// <param name="file">Texture file to create</param>        /// <returns>A texture</returns>        public static Texture CreateTexture(Device renderDevice, string file)        {            // Make sure a texture was passed in            if ((file == null) || (file.Length == 0))            {                // No texutre                return null;            }            // Before we create a texture, return one from the             // pool if it exists            string lowerCaseFile = file.ToLower();            if (textureTable.ContainsKey(lowerCaseFile))            {                return textureTable[lowerCaseFile] as Texture;            }            // We've made it here, this is a new texture, Create the texture and add it to the pool            Texture t = TextureLoader.FromFile(renderDevice, GameEngine.MediaPath + TexturePath + file);                        System.Diagnostics.Debug.Assert(t != null, "Created Texture is null",                 "Textures being loaded by the pool should never be null");            // Add it to the pool            textureTable.Add(lowerCaseFile, t);            return t;        }        /// <summary>        /// Release all textures that have been created thus far        /// </summary>        public static void ReleaseAllTextures()        {            foreach(string s in textureTable.Keys)            {                // Simply dispose of each texture in the list                (textureTable as Texture).Dispose();<br>            }<br><br>            // Clear the texture list<br>            textureTable.Clear();<br>        }<br><br>    }<br>}<br></pre>
Mykre - BlogVirtual Realm :- XNA News and Resources from Down Under** For those Interested in an Australian XNA User Group Contact me though my site.

This topic is closed to new replies.

Advertisement