Jump to content

  • Log In with Google      Sign In   
  • Create Account


SDL2 Texture


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Hanksha   Members   -  Reputation: 159

Like
0Likes
Like

Posted 06 January 2014 - 07:44 AM

Hi,

 

I've been trying to load large images (like 5000x2000, basically of map back ground) into an SDL_Texture*

 

Example:

SDL_Texture* image;

image = IMG_LoadTexture(renderer,"data/test.png");

But with a large resolution the image can't be load into the texture, with lower resolution like 1280x720 it works fine.

Is there a limit of size for an SDL_Texture?



Sponsor:

#2 Serapth   Crossbones+   -  Reputation: 5182

Like
0Likes
Like

Posted 06 January 2014 - 09:59 AM

Well, since SDL_Texture is a small veneer over OpenGL textures, it is most likely not an SDL issue.

 

The first an most likely issue is you are running < OpenGl 2.0.  In this case, you need to have your texture dimensions be Power of Two in size.  Meaning your width or height should be 2,4,8,16,32,64,128,256,512, etc...

 

The second most common reason is you are exceeding YOUR graphic cards maximum texture size.  This is device specific, so it will depend on the machine you run on.  5000 is probably two wide, depending on your card.  Try scaling down to 4096 width and see what happens ( A common size limit ).



#3 Hanksha   Members   -  Reputation: 159

Like
0Likes
Like

Posted 09 January 2014 - 04:20 AM

(Sorry for late answer)

Yes apparently after few test, the limit looks to be 4096x4096.

Is there any documentation about that? (I didn't see anything on wiki of SDL2)



#4 Serapth   Crossbones+   -  Reputation: 5182

Like
1Likes
Like

Posted 09 January 2014 - 09:54 AM

(Sorry for late answer)

Yes apparently after few test, the limit looks to be 4096x4096.

Is there any documentation about that? (I didn't see anything on wiki of SDL2)

 

The documentation is from the OpenGL spec.  Unfortunately all you will see is "driver dependant".  Basically meaning its up to the company implementing the drivers.

 

You may be able to get documentation on this from the device manufacturer, but that wouldn't be fun.  There is however a GL call that allows you to query the maximum texture size, SDL may implement it, i am not sure.



#5 Hanksha   Members   -  Reputation: 159

Like
0Likes
Like

Posted 10 January 2014 - 12:16 AM

So if I put a large background 4096x4096, I might encounter a case of a computer who could not load it? (I've done 5 or 6 test on computers but most of them were not old)



#6 Serapth   Crossbones+   -  Reputation: 5182

Like
2Likes
Like

Posted 10 January 2014 - 08:43 AM

So if I put a large background 4096x4096, I might encounter a case of a computer who could not load it? (I've done 5 or 6 test on computers but most of them were not old)

 

 

Yes this is true; you need to establish a baseline machine.

 

4096x4096 is a reasonable MODERN minimum.  If you want to support as many machines as possible, 2048x2048 is a better call.

 

Intel Integrated graphics are about the baseline of 3D GPUs and as you can see from the documentation some of the HD3000 models have a hard limit of 2048:

 

Max 2d texture

2K x 2K

4K x 4K

4K x 4K

2K x 2K

4K x 4K

Max 3d texture

2048 x 2048 x 256

8092 x 8092 x 256

8092 x 8092 x 256

2048 x 2048 x 256

8092 x 8092 x 256

 

That said, the last 2k x 2k GPU was in 2007.  

 

The HD3000 is a good choice of baseline chips, as it is used in a TON of laptops and is also the base chip for most iMacs created in the past 6 or so years.



#7 Hanksha   Members   -  Reputation: 159

Like
0Likes
Like

Posted 10 January 2014 - 05:47 PM

Interesting! I'll follow your advice. I'll make a function to detect the GPU of the user so it could send a message error if it can't load texture because of that.



#8 Aldacron   GDNet+   -  Reputation: 3065

Like
1Likes
Like

Posted 10 January 2014 - 09:52 PM

Interesting! I'll follow your advice. I'll make a function to detect the GPU of the user so it could send a message error if it can't load texture because of that.

No need for that. SDL_GetRendererInfo will return a pointer to a SDL_RendererInfo object. You can check the max_texture_width and max_texture_height fields to see if your texture will fit.



#9 Hanksha   Members   -  Reputation: 159

Like
0Likes
Like

Posted 12 January 2014 - 05:57 AM

By make a function I meant use an SDL one : )






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS