Texture management strategies?

Discussion in 'Ruby' started by Ilmari Heikkinen, Apr 15, 2005.

  1. Hello, I'm writing this OpenGL engine thing, and am currently wondering
    about a good way to manage loading, replacing and disposing of
    textures.

    It's doable to preload 20 images as rgba data into system memory, but
    trying to preload them into GL textures gets very slow. So there's a
    need to load textures into GL on the fly and delete unused textures.

    This is roughly what I'm currently doing every three seconds in a
    slideshow program:

    tex_id = renderer.textures[image.texture.object_id]
    if tex_id
    image_filename = images[counter]
    GL.PushAttrib(GL::TEXTURE_BIT)
    GL.BindTexture(TEXTURE_2D, tex_id)
    bitmap = load_image(image_filename)
    GL.TexImage2D(TEXTURE_2D,
    0, 4,
    bitmap.width, bitmap.height,
    0, color_mode, pixel_format,
    bitmap.pixels)
    GL.PopAttrib()
    end

    It's not very pretty... Instead of the whole
    bindtexture-texsubimage2d-exposing-graphics-API-blah, I'd like to do
    this:

    image.texture = images[counter]

    And have the texture manager take care of disposing unused textures.


    image.replace_texture( images[counter] )

    Would be an alternative for cases where the texture size stays the same
    but the contents change (like with video.)


    But I haven't really done this sort of stuff before. Any pointers on
    where to start or what would be a good way to do this? Books on the
    subject ?:)


    Grateful for any help
    - Ilmari
    Ilmari Heikkinen, Apr 15, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    5,393
    Andrew Thompson
    Sep 2, 2005
  2. Xpyder
    Replies:
    3
    Views:
    378
    Victor Bazarov
    Mar 5, 2005
  3. jacob navia

    Memory management strategies in C. (long)

    jacob navia, Aug 20, 2003, in forum: C Programming
    Replies:
    7
    Views:
    863
    Chris Torek
    Aug 23, 2003
  4. stacey

    Problem with texture of UI

    stacey, Jan 21, 2007, in forum: Java
    Replies:
    3
    Views:
    347
    Larry Barowski
    Jan 23, 2007
  5. =?ISO-8859-2?Q?Rafa=B3?= Maj

    Model and Texture but with children

    =?ISO-8859-2?Q?Rafa=B3?= Maj, May 23, 2007, in forum: C++
    Replies:
    2
    Views:
    299
    Howard
    May 24, 2007
Loading...

Share This Page