Results 1 to 7 of 7

Thread: questions about dealing with non power of two textures

  1. #1

    questions about dealing with non power of two textures

    Hi all.
    i'm aware that textures in opengl es 1.x need to be POT in size.
    Now i'm working on an app where you can load a picture (from user albums) and insert
    that pic on a scene with other objs/textures etc. so i need to find a way for dealing with
    those images which size i can't control.
    my first thought was that i would have to open the file, adjust its size, annotate the offsets and then load the modified version.
    but i have the impression this is brute force. what can we do on a case like this??

    Thanks for any suggestions.

  2. #2
    Senior Member
    Join Date
    May 2010
    Posts
    207

    Re: questions about dealing with non power of two textures

    You can use subTexLoad to place the image into one corner of a larger map - then adjust your texture coordinates to render only that part of the map.

  3. #3

    Re: questions about dealing with non power of two textures

    you mean glTexSubImage2D? i see it says "redefines a contiguous subregion of an existing two-dimensional texture image".
    so i can say that if we get an 260x260 image, then its possible to take the 256x256 part for texturing. is this correct?. what about expand to 512 and prevent cutting (of course this will cause waste of space.)

  4. #4
    Senior Member
    Join Date
    May 2010
    Posts
    207

    Re: questions about dealing with non power of two textures

    glTexSubImage2D - yeah, I always forget the name of that darned function!

    Anyway - it won't let you write a 260x260 into a 256x256 map - but it will let you load it into the bottom-left corner of a 512x512 map (and, yes, you'd have a gigantic amount of wasted space). Then, when you use that to texture a polygon, instead of your texture coordinates going from 0..1, they'd have to go from 0 to (260.0/512.0).

  5. #5

    Re: questions about dealing with non power of two textures

    Thanks, its more clear now what i can do.

    it will be just one pic that is going to pass through this process so i guess i'll sacrifice that space.

  6. #6
    Senior Member
    Join Date
    May 2008
    Posts
    104

    Re: questions about dealing with non power of two textures

    You can also use a texture atlas, you can place several images into a single pot texture using the function Steve mentioned. It might allow you to save some memory, however you'll need some algorithm to manage possibly various sized images.

  7. #7
    Junior Member
    Join Date
    Nov 2011
    Posts
    1

    Re: questions about dealing with non power of two textures

    Hi, guys, registered to thank you for the great advice provided in here. You've saved tones of my nerves and time

Similar Threads

  1. Actual power-consumption data?
    By DaveS in forum OpenVG and VGU
    Replies: 0
    Last Post: 09-12-2010, 11:04 PM
  2. Non-power of 2 vector types
    By PaulS in forum Suggestions for next release
    Replies: 2
    Last Post: 02-01-2010, 12:15 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
  •