Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Detecting all available display modes and storing them in an array of structs?

Detecting all available display modes and storing them in an array of structs?

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsdata-structureshelpquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alan Chambers
    wrote on last edited by
    #1

    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

    J M 2 Replies Last reply
    0
    • A Alan Chambers

      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

      J Offline
      J Offline
      Jason Henderson
      wrote on last edited by
      #2

      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!"

      M 1 Reply Last reply
      0
      • J Jason Henderson

        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!"

        M Offline
        M Offline
        Mike Nordell
        wrote on last edited by
        #3

        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.

        J 1 Reply Last reply
        0
        • A Alan Chambers

          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

          M Offline
          M Offline
          Mike Nordell
          wrote on last edited by
          #4

          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.

          A 1 Reply Last reply
          0
          • M Mike Nordell

            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.

            J Offline
            J Offline
            Jason Henderson
            wrote on last edited by
            #5

            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!"

            1 Reply Last reply
            0
            • M Mike Nordell

              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.

              A Offline
              A Offline
              Alan Chambers
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups