title: Data structure for quick access to glpyh textures via char
body: <p>I am attempting to create an edit box that allows users to input text.  I've been working on this for some time now and have tossed around different ideas.  Ultimately, the one I think that would offer the best performance is to load all the characters from the .ttf (I'm using SDL to manage events, windows, text, and images for openGL) onto their own surface, and then render those surfaces onto textures one time.  Then each frame, I can just bind an appropriate texture in the appropriate location.  </p>
  
  <p>However, now I'm thinking how to access these glyphs.  My limited bkg would say something like this:</p>
  
  <pre><code>struct CharTextures {
      char glpyh;
      GLuint TextureID;
      int Width;
      int Height;
      CharTextures* Next;
  }
  
  //Code
  
  CharTexture* FindGlyph(char Foo) {
      CharTextures* Poo = _FirstOne;
      while( Poo != NULL ) {
          if( Foo == Poo-&gt;glyph ) {
                return Poo;
          }
          Poo = Poo-&gt;Next;
       }
       return NULL;
  }
  </code></pre>
  
  <p>I know that will work.  However, it seems very wasteful to iterate the entire list each time.  My scripting experience has taught me some lua and they have tables in lua that allow for unordered indices of all sorts of types.  How could I mimic it in C++ such that instead of this iteration, I could do something like:</p>
  
  <pre><code>CharTexture* FindGlyph(char Foo) {
      return PooPointers[Foo]; //somehow use the character as a key to get pointer to glyph without iteration
  }
  </code></pre>
  
  <p>I was thinking I could try converting to the numerical value, but I don't know how to convert char to UTF8 values and if I could use those as keys.  I could convert to ascii but would that handle all the characters I would want to be able to type?  I am trying to get this application to run on mac and windows and am not sure about the machine specifics.  I've read about the differences of the different format (ascii v unicode v utf8 v utf16 etc)...  I understand it has to do with bit width and endianness but I understand relatively little about the interface differences between platforms and implications of said endianness on my code.  </p>
  
  <p>Thank you</p>