Detecting all available display modes and storing them in an array of structs?
-
Hi all, I would like to be able to detect all the display modes capable by my graphics card. I am using DirectDraw/Direct3D and have all the necessary enumeration callback procedures in place. However I have a problem: I want an array of custom mode structs that store the width, height and BitsPixel of a particular display mode (so I can reference it later), but don't know how many available display modes there are until they have all been cycled through in the enumeration function. This means I cannot initialise the array, and there for store the mode information as it goes along. Does this mean I have to use a vector of structs and make it grow as I find new modes? or is there a better way of getting this information before I convert into my custom struct? maybe using a different storage method? "When I left you I was but the learner, now I am the master" - Darth Vader
-
Hi all, I would like to be able to detect all the display modes capable by my graphics card. I am using DirectDraw/Direct3D and have all the necessary enumeration callback procedures in place. However I have a problem: I want an array of custom mode structs that store the width, height and BitsPixel of a particular display mode (so I can reference it later), but don't know how many available display modes there are until they have all been cycled through in the enumeration function. This means I cannot initialise the array, and there for store the mode information as it goes along. Does this mean I have to use a vector of structs and make it grow as I find new modes? or is there a better way of getting this information before I convert into my custom struct? maybe using a different storage method? "When I left you I was but the learner, now I am the master" - Darth Vader
There aren't a whole lot of modes, why not just use a static array of say 50 DEVMODE structs?
Jason Henderson
quasi-homepage
articles
"Like it or not, I'm right!" -
There aren't a whole lot of modes, why not just use a static array of say 50 DEVMODE structs?
Jason Henderson
quasi-homepage
articles
"Like it or not, I'm right!"Jason Henderson wrote: There aren't a whole lot of modes, why not just use a static array of say 50 DEVMODE structs? Because it's wrong and will fail. Actually, a program (game demo) I tested just the other day had exactly this hardcoded limit and failed miserably. You weren't involved in that code by any chance? :-> At this machine (a plain NT5 machine with a reasonably good monitor) I currently have 144 different display modes. If I swicth to a "hotter" Gfx card I'll surely get over 200 different modes. If you don't want your app to fail, don't use hard-coded limits for stuff like this.
-
Hi all, I would like to be able to detect all the display modes capable by my graphics card. I am using DirectDraw/Direct3D and have all the necessary enumeration callback procedures in place. However I have a problem: I want an array of custom mode structs that store the width, height and BitsPixel of a particular display mode (so I can reference it later), but don't know how many available display modes there are until they have all been cycled through in the enumeration function. This means I cannot initialise the array, and there for store the mode information as it goes along. Does this mean I have to use a vector of structs and make it grow as I find new modes? or is there a better way of getting this information before I convert into my custom struct? maybe using a different storage method? "When I left you I was but the learner, now I am the master" - Darth Vader
Why use a plain array when there are so many good collection classes already in C++. A plain std::vector seems to be the final storage type for this, but while enumerating you could use just about whatever collection type you like.
-
Jason Henderson wrote: There aren't a whole lot of modes, why not just use a static array of say 50 DEVMODE structs? Because it's wrong and will fail. Actually, a program (game demo) I tested just the other day had exactly this hardcoded limit and failed miserably. You weren't involved in that code by any chance? :-> At this machine (a plain NT5 machine with a reasonably good monitor) I currently have 144 different display modes. If I swicth to a "hotter" Gfx card I'll surely get over 200 different modes. If you don't want your app to fail, don't use hard-coded limits for stuff like this.
Mike Nordell wrote: You weren't involved in that code by any chance? No. I had no idea there would be that many modes. It was just a suggestion.
Jason Henderson
quasi-homepage
articles
"Like it or not, I'm right!" -
Why use a plain array when there are so many good collection classes already in C++. A plain std::vector seems to be the final storage type for this, but while enumerating you could use just about whatever collection type you like.
Thanks for the suggestions. After a little thought I decided to go with the std::vector method, because it is dynamic and will only take up the required amount of precious memory. I can always set a limit to the number of modes I want to read in, but at least the memory allocation will be efficient... Thanks for the suggestion guys, very much appreciated. Alan. "When I left you I was but the learner, now I am the master" - Darth Vader