Results 1 to 5 of 5

Thread: Texture management and textures affecting colours

  1. #1

    Texture management and textures affecting colours


    So, I've tried to find these answers in the red book, the superbible, and in a bazillion samples, I hope someone can help me out:

    1) How do you unload textures? I couldn't find a way, so I made a texture manager that keeps a record of how many times a texture is referenced, and when it tries to load a new texture, if it finds a record with no more references, it glBind's to that texture, and replaces it with the new one. Is this in any way correct?Or do I just keep generating textures and hope my card has the memory

    2) I set my glClear colour at the top of my render function, I draw a grid of light grey lines, and a blue cube on a dark gray background. Everything works fine until I texture map one triangle of the cube, then the lines and the block become black. What's weird is that when I change the texture, if eg: a colour on the border of the texture is red, everything becomes red. (and I haven't set a border value for the texture)

    3) Also, I've seen on this website that you mustn't use GL_DECAL when describing a texture, but GL_MODULATE instead. When I use GL_MODULATE, the colours of my texture seem to swap from RGB to BGR, but if I use GL_DECAL, the colours are fine.

    Thanks in advance, I know these are long questions, but I've really tried finding some of this myself, to no avail.


  2. #2
    Member Contributor
    Join Date
    Jan 2003

    Re: Texture management and textures affecting colours

    1. You should create all the textures that you will need to render the scene at an initialisation stage - if you need too many textures that they won't all fit into texture memory, you will experience performance issues, but let opengl worry about "fitting" them into memory. As you are drawing the scene, you will bind the texture you need for the upcoming object. Binding to the texture doesn't occupy more memory (the texture already exists in memory). If you have a texture that will not be needed anymore for the duration of the application, you can delete the texture which will free the memory.

    2. Are you remembering to disable texturing after you have finished drawing the textured object. If not, the next time through the render function will use texturing to draw the lines.

    3. The choice between DECAL or MODULATE depends on your needs - both have their uses.

  3. #3

    Re: Texture management and textures affecting colours

    Dear T: thank you muchly man.

    1) I am loading all the textures at initialisation, but say now I load a new level in my game, and I need to delete all the current textures, you say I just need to delete the texture... but using what gl* function? Because I delete the texture data I've read from file directly after I glTexImage2D, so what more should I be doing?

    2) Ohkaaay, so I thought that by calling glEnable at the beginning was the end all say all, I didn't know you could toggle it on or off during the rendering process. Thank you so much!

    3) Ok, agreed, but is the colour swapping all in my mind, or is it because GL_MODULATE is blending my texture and the colour of the polygon in the previous render even though I'm calling glClear?

    Thanks again, you've been the most help so far.

  4. #4
    Member Contributor
    Join Date
    Jan 2003

    Re: Texture management and textures affecting colours

    1. When you created the textures you would have used a glGenTextures to allocate a texture "name" and then uploaded your image to it. Using a glDeleteTextures will free the memory once more.

    3. The combination of colour and texture colour when modulating has perhaps created the illusion of the colour swapping - it should not *actually* be happening.

  5. #5

    Re: Texture management and textures affecting colours

    Hey again,

    1) Well duh. I don't know how I missed that one, geez, I swear I looked for it. Well, thank you for showing me how stupid I am. No seriously

    3) Ok, cool. Maybe after I've sorted out my other mistakes it'll come right.

    I know I'm sounding like an overkeen leg-attaching animal, but thanks a stack, 'cos no one else has yet helped me out anywhere else. Ta.

    Oh, and I didn't know you could texture map a line. Sweet...

Similar Threads

  1. Replies: 2
    Last Post: 05-12-2013, 12:00 AM
  2. 32bit colours=fast! 16bit colours=very slow??
    By Useless in forum OpenGL: Advanced Coding
    Replies: 14
    Last Post: 09-25-2004, 05:25 AM
  3. texture management
    By eixuery in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-17-2004, 09:46 AM
  4. texture management
    By MarsuGL in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-05-2002, 07:29 AM
  5. Texture Management
    By Mad Max in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 02-12-2000, 08:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean