[OpenGL] Texture size

This is a discussion on [OpenGL] Texture size within the Game Programming forums, part of the General Programming Boards category; I was wondering how you guys deal with the fact that the width and height of textures have to be ...

  1. #1
    return 0;
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    89

    [OpenGL] Texture size

    I was wondering how you guys deal with the fact that the width and height of textures have to be a power of 2.

    For example: I have a window of 640x480. Should I stretch the background image for my window to 1024x512 or is there another way to have OpenGL accept my image?

    I'm using DevIL to import my images. Here it says under "How ILUT Handles Textures":

    Quote Originally Posted by Tutorial
    DevIL allows the use of arbitrarily-sized images, but OpenGL only works with images that have dimensions that are powers of 2, for optimization purposes. If an image has dimensions that are not powers of 2, DevIL will resize the image before sending it to OpenGL
    But this doesn't seem to happen. If I use an image with size 640x480, it doesn't show up when used as a texture. Any ideas?
    Last edited by Snip; 08-24-2005 at 01:22 PM.

  2. #2
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    I might be wrong about the request, but according to NeHe you can use any size when for mitmapped textures:

    http://nehe.gamedev.net/data/lessons....asp?lesson=07

    I had said in tutorial six there was a way around the 64,128,256,etc limit that OpenGL puts on texture width and height. gluBuild2DMipmaps is it. From what I've found, you can use any bitmap image you want (any width and height) when building mipmapped textures. OpenGL will automatically size it to the proper width and height.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    Even so, you can still load the entire texture and just apply a section of that texture to your quad

  4. #4
    return 0;
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    89
    Ah thanks, the mipmapping thing works wonderful. I have another question though: is it right to use a texture as a background? Because it loads really slow. If a part of the window has been covered and is uncovered, it takes about half a second before the background shows up. Before then, the window is simply white.

  5. #5
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    640 = 512 + 128

    You could split it up in parts (to conserve memory). One 512x512 then one 128x512 to the right. I know Warcraft 3 does this sometimes.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 02:55 AM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  4. An exercise in optimization
    By Prelude in forum Contests Board
    Replies: 10
    Last Post: 04-29-2005, 03:06 PM
  5. Using texture stage states for shadows
    By VirtualAce in forum Game Programming
    Replies: 3
    Last Post: 06-17-2002, 01:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21