SDL 2 - Power of Two Textures Still?

SDL 2 - Power of Two Textures Still ?

Hi,

Preparing to make a game using SDL 2 soon.

With SDL 1.2+OpenGL, textures had to be a power of 2 horizontally/vertically.
Does SDL 2 still have this restriction or SDL 2 textures can be any resolution?

Thanks!------------------------
JeZ+Lee
JessePalser <AT> Gmail <DOT> com
16BitSoft®
Video Game Design Studio
www.16BitSoft.com

SDL 1.2 didn’t use textures at all as far as I know, you were bound by
OpenGL there (support for non-power of two textures depends on the
OpenGL version).

I think SDL 2 lets you use any texture size and if the hardware
doesn’t support non-powers of two it will try to add padding. I’m not
100% sure (nor I can confirm given my hardware supports non-power of
two textures) but I think this is the case.

Non-power of two textures were made core in OpenGL 2.0 (and some
earlier hardware also supports them). That’s really old. I think you
probably shouldn’t worry at this point, unless you’re aiming at
extremely outdated low-end hardware for some reason.

2013/4/23, JeZ-l-Lee :> SDL 2 - Power of Two Textures Still ?

Hi,

Preparing to make a game using SDL 2 soon.

With SDL 1.2+OpenGL, textures had to be a power of 2
horizontally/vertically.
Does SDL 2 still have this restriction or SDL 2 textures can be any
resolution?

Thanks!


JeZ+Lee
JessePalser <AT> Gmail <DOT> com
16BitSoft®
Video Game Design Studio
www.16BitSoft.com


From: jessepalsermailinglists@gmail.com (Jesse Palser)
To: sdl at lists.libsdl.org
Sent: Tue, April 23, 2013 1:47:57 PM
Subject: [SDL] SDL 2 - Power of Two Textures Still ?

SDL 2 - Power of Two Textures Still ?

Hi,

Preparing to make a game using SDL 2 soon.

With SDL 1.2+OpenGL, textures had to be a power of 2 horizontally/vertically.
Does SDL 2 still have this restriction or SDL 2 textures can be any resolution?

Thanks!


NPOT should be supported by most modern GPU hardware:
http://www.opengl.org/wiki/NPOT_Texture
It was only restricted for ES profiles.

Ive looked at your code before and if your intending to use SDL2 like you used
SDL 1.2 i.e window management then nothing has changed since the opengl API has
not changed.

Typically you want to use POT textures since they are a better format for the
hardware. Plus 1.X ES doesnt support NPOT. 2.0 ES does through extensions.
Using POT makes you compatible with any standard and hardware.
Another alternative is pad your texture to POT and then use glSubTexImage to use
the portions you need.

This was never a limitation of SDL, it was a limitation of OpenGL.

If the system is using OpenGL 2.0 or later, you’re guaranteed support of
non-power-of-two texture sizes. There are extensions that allow older
OpenGL implementations to use them, too, but in 2013: screw it, just
quit immediately and throw up a message box if the user doesn’t have
OpenGL 2.0 or later.

(SDL2 has message boxes, too, btw. :slight_smile: )

–ryan.On 4/23/13 1:47 PM, JeZ-l-Lee wrote:

SDL 2 - Power of Two Textures Still ?

Support for NPOT was officially specified many years ago, but slow to be
implemented. Desktop systems support it either in hardware or trigger a fallback
to software (SLOW) for NPOT textures. Either way, you can expect it to be
supported. But NPOT has only been implemented in mobile hardware in recent years.

So it really depends on whether you want to support Android 2.x/3.x devices like
Kindle Fire, Galaxy Tabs, and previous generations of iPhones, which do not
fully support NPOT.

(Btw, there are actually shades of support for NPOT. It’s not all-or-nothing.)On 04/24/2013 12:24 PM, Ryan C. Gordon wrote:

On 4/23/13 1:47 PM, JeZ-l-Lee wrote:

SDL 2 - Power of Two Textures Still ?

This was never a limitation of SDL, it was a limitation of OpenGL.

If the system is using OpenGL 2.0 or later, you’re guaranteed support of
non-power-of-two texture sizes. There are extensions that allow older OpenGL
implementations to use them, too, but in 2013: screw it, just quit immediately
and throw up a message box if the user doesn’t have OpenGL 2.0 or later.

(SDL2 has message boxes, too, btw. :slight_smile: )

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

There’s also the fact that when they were first implemented in
hardware POT textures were still faster than NPOT ones, which mattered
if performance was critical (i.e. if you pushed the hardware to its
limits).

2013/4/24, John :> Support for NPOT was officially specified many years ago, but slow to be

implemented. Desktop systems support it either in hardware or trigger a
fallback
to software (SLOW) for NPOT textures. Either way, you can expect it to be
supported. But NPOT has only been implemented in mobile hardware in recent
years.

So it really depends on whether you want to support Android 2.x/3.x devices
like
Kindle Fire, Galaxy Tabs, and previous generations of iPhones, which do not

fully support NPOT.

(Btw, there are actually shades of support for NPOT. It’s not
all-or-nothing.)

On 04/24/2013 12:24 PM, Ryan C. Gordon wrote:

On 4/23/13 1:47 PM, JeZ-l-Lee wrote:

SDL 2 - Power of Two Textures Still ?

This was never a limitation of SDL, it was a limitation of OpenGL.

If the system is using OpenGL 2.0 or later, you’re guaranteed support of
non-power-of-two texture sizes. There are extensions that allow older
OpenGL
implementations to use them, too, but in 2013: screw it, just quit
immediately
and throw up a message box if the user doesn’t have OpenGL 2.0 or later.

(SDL2 has message boxes, too, btw. :slight_smile: )

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

When I wrote my first OpenGL project, I happened to be on that “old low-end” hardware that didn’t support NPOT, so I just padded each NPOT texture with zero alpha channel, but remembered the NPOT dimensions of the texture for drawing. This worked well.------------------------
Nate Fries