Results 1 to 4 of 4

Thread: String to Texture ID... Possible?

  1. #1
    Senior Member crazyfool's Avatar
    Join Date
    Jan 2008
    Posts
    761
    Thanks
    77
    Thanked
    38 times in 38 posts
    • crazyfool's system
      • Motherboard:
      • Striker Extreme
      • CPU:
      • Q6600
      • Memory:
      • OCZ 6400 2 x 2GB
      • Storage:
      • Samsung Spinpoint 500GB
      • Graphics card(s):
      • BFG 8800 GT OC 512MB
      • PSU:
      • Coolermaster Real Power Pro 850w
      • Case:
      • Coolermaster CM-690
      • Operating System:
      • XP, Vista, Windows 7 & Ubuntu
      • Monitor(s):
      • Samsung 2232BW

    String to Texture ID... Possible?

    hey guys,
    I have a problem with a program I'm creating. Basically for every user input a string is created which is the name of the image. Now all of the images have already been loaded as textures (gltexture) with relevant names such as dog.jpg is loaded as a gltexture whose id is dog. I need to texture map these images to various shapes, for now we'll say a rectangle (GL_Quad). However all I have to identify the texture needed is the string. Therefore is there anyway to convert the string into a format which allows me to indentify the texture needed e.g.
    string = dog
    string to someformat
    glBindTexture(GL_TEXTURE_2D, someformat.TextureID);
    Right now I am using the string to create the filepath so string = dog is becoming string = c:/images/dog.jpg, I'm then using this path to load the texture each time and bind it. However as the image is redrawn all the time it is constantly loading the texture over and over which is killing cpu usage. I hope this all makes sense, if it isnt possible any ideas on alternative methods would be appreciated. Thanks.

  2. #2
    HEXUS webmaster Steve's Avatar
    Join Date
    Nov 2003
    Posts
    14,276
    Thanks
    292
    Thanked
    837 times in 473 posts

    Re: String to Texture ID... Possible?

    This C or C++?

    Perhaps you could have a struct containing the texture ID and its name, or maybe a Map/Vector?

    So you can load up your textures and then go through an array of your structs or Map or Vectors and have each texture and its name. You could store other info in there too.

    Have I understood the question?
    PHP Code:
    $s = new signature();
    $s->sarcasm()->intellect()->font('Courier New')->display(); 

  3. Received thanks from:

    crazyfool (01-02-2010)

  4. #3
    Senior Member crazyfool's Avatar
    Join Date
    Jan 2008
    Posts
    761
    Thanks
    77
    Thanked
    38 times in 38 posts
    • crazyfool's system
      • Motherboard:
      • Striker Extreme
      • CPU:
      • Q6600
      • Memory:
      • OCZ 6400 2 x 2GB
      • Storage:
      • Samsung Spinpoint 500GB
      • Graphics card(s):
      • BFG 8800 GT OC 512MB
      • PSU:
      • Coolermaster Real Power Pro 850w
      • Case:
      • Coolermaster CM-690
      • Operating System:
      • XP, Vista, Windows 7 & Ubuntu
      • Monitor(s):
      • Samsung 2232BW

    Re: String to Texture ID... Possible?

    yh mate you've understood, that is wot I was thinking next but I just didn't want to waste cycles going through the vector for the right texture, doesnt seem like another way tho so I'll give this a go, thanks.

  5. #4
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,230
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: String to Texture ID... Possible?

    Without seeing the rest of your code it's hard to be sure, but it sounds to me like you should be able to create a new struct / object that creates an instance of the texture itself (i.e. loads "C:\images\dog.jpg" once and persists it in memory as an instance of some kind of image object) and then bind that to the shape. If you need to keep them in some kind of list structure (and whatever language this is supports them) I'd suggest a hashmap / hashtable, which should be very fast at retrieving the data.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. C++ String Help
    By crazyfool in forum Software
    Replies: 12
    Last Post: 07-11-2008, 01:18 PM
  2. Problems with my new PC
    By isaacsr99 in forum Help! Quick Relief From Tech Headaches
    Replies: 23
    Last Post: 11-10-2008, 06:06 PM
  3. string out of bounds error
    By j.o.s.h.1408 in forum Software
    Replies: 1
    Last Post: 03-05-2007, 07:49 PM
  4. Zakky - Thanks for the string dude :)
    By Tumble in forum General Discussion
    Replies: 3
    Last Post: 03-06-2004, 03:01 PM
  5. String and rope......
    By Zak33 in forum General Discussion
    Replies: 17
    Last Post: 31-01-2004, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •