Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

display.setDefault( "textureWrapX", "repeat" ) breaks on some devices
Started by Rob... Mar 05 2015 11:57 AM

14 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Rob...

[GLOBAL: userInfoPane.html]
Rob...
  • Contributor

  • 330 posts
  • Corona SDK

I have just got hold of a new testing device, a common one called the Nexus 7. Well I tried one of my apps form the store and it failed. Just blank screen and one icon. So I tried some other apps and find 5 have the same problem. I have spent three hours trying to find out what it is and narrowed it down to these lines.

display.setDefault( "textureWrapX", "repeat" )
display.setDefault( "textureWrapY", "repeat" )
 
All the apps work with no problem on other devices form Fire Tv, Archos, Hudl , cheapo All winner devices etc. This is also now explaining why it failed on the Nook (all of them) as they sent me a screenshot which now matches what i see.
 
So those lines above break on certain devices like Nook and Nexus 7 and not others? How come? Is it a limitation to the graphics chip. 
 
The texture is 512x512.  
Maybe iy was a combination of things and this was the tipping point. I had removed graphics first to see. There were no errors so as far as the app was concerned it was functioning.


[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hello,

Can you post some additional code where you set up these textures and the fill? And perhaps some screenshots from device(s) where it's failing?

 

Thanks,

Brent



[TOPIC: post.html]
#3

Rob...

[GLOBAL: userInfoPane.html]
Rob...
  • Contributor

  • 330 posts
  • Corona SDK

Sure heres the code. height and width are set to fill screen

 

display.setDefault( "textureWrapX", "repeat" )
display.setDefault( "textureWrapY", "repeat" )
 
parallax=display.newRect(frameSettings.width,frameSettings.height,frameSettings.width,frameSettings.height);
parallax.x=WX/2;
parallax.y=frameSettings.yPos;
--parallax.blendMode="add"
parallax.alpha=0.5;
parallax.fill = { type="image", filename="stars.png" }
parallax.fill.x = 0
parallax.fill.y = 0
 
 
parallax2=display.newRect(frameSettings.width,frameSettings.height,frameSettings.width,frameSettings.height);
parallax2.x=WX/2;
parallax2.y=frameSettings.yPos;
--parallax2.blendMode="add"
parallax2.alpha=0.5;
parallax2.xScale=3;
parallax2.yScale=3;
parallax2.fill = { type="image", filename="stars.png" }
parallax2.fill.x = 0
parallax2.fill.y = 0
 
local function scrollParalaxes ()
parallax.fill.y=parallax.fill.y-0.0005;
if parallax.fill.y<-1 then parallax.fill.y=1  end
parallax2.fill.y=parallax2.fill.y-0.001;
if parallax2.fill.y<-1 then parallax2.fill.y=1 end
 
 
end
 
Runtime:addEventListener("enterFrame",scrollParalaxes)


[TOPIC: post.html]
#4

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi Rob,

Can you please test out our "repeating fills" sample on one of the same testing devices and report the results? The project is located in your local CoronaSDK application folder here:

 

SampleCode > Graphics-Premium > PatternFill

 

Thanks,

Brent



[TOPIC: post.html]
#5

Rob...

[GLOBAL: userInfoPane.html]
Rob...
  • Contributor

  • 330 posts
  • Corona SDK

Ok wll do tomorrow. Can you see any potential problem in the code? Using texture twice, filling to screen etc? Maybe there's a maximum amount available for fills on some gpus.

[TOPIC: post.html]
#6

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

I don't see anything immediately alarming. You said the fills are 512x512... and how large are the newRect()s that you're filling? Can you post one of the malfunctioning screenshots when you have a chance?



[TOPIC: post.html]
#7

Rob...

[GLOBAL: userInfoPane.html]
Rob...
  • Contributor

  • 330 posts
  • Corona SDK

Okay well I have some results. Firstly, there really isnt anything to see on the screenshots. Its all blank expect one button which manages to  load at the beginning until the graphics break. 

So I tested your example. All good. I see the texture was 256 so I swapped my stars.png. - it breaks on the Nexus7. I had a quick look again at the texture and see its 512x400. Oops I thought. Guessing this should be square so I go back to the app that broke and check that texture. Well thats square 512x512. So how come that is breaking still? I use my code  that I pasted above and that doesnt break so now im confused!. One last test is that I copy this bit from your example and paste in my breaking app, after I set up my filled objects:

--display.setDefault( "textureWrapX", "clampToEdge" )
--display.setDefault( "textureWrapY", "clampToEdge" )
 
Now it doesnt break. 
The stars.png is not used anywhere else in the game,
 
It seems that leaving that texture wrap setting as it is after the fill objects are set up breaks the game. 
 
Makes me wonder if its a good idea setting up a global graphics setting then setting it back for each object and is the wrong way and perhaps instead the texture wrapping should be set up on the object so then  your core code will automatically set it back after its set.


[TOPIC: post.html]
#8

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi Rob,

So to confirm, the verdict is that you can fill the objects using "repeat" for the texture wrapping, and that works fine... then you can revert that setting to "clampToEdge" and the app does not crash on the Nexus7? But if you don't revert it (you leave it as "repeat") then it crashes?

 

Brent



[TOPIC: post.html]
#9

Rob...

[GLOBAL: userInfoPane.html]
Rob...
  • Contributor

  • 330 posts
  • Corona SDK

Yes it seems that way. But as it is not a problem on just that code on its own it mus be because graphics are loading after it at some point.



[TOPIC: post.html]
#10

Rob...

[GLOBAL: userInfoPane.html]
Rob...
  • Contributor

  • 330 posts
  • Corona SDK

Without any "crash"

[TOPIC: post.html]
#11

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi Rob,

So, in your implementation, can you set the texture wrapping on just for those fills, then turn it back off immediately after, and the devices like Nexus7 run without issue? If that works, I'd suggest going that route... I'm not sure why, but perhaps the GPUs on those devices are fussy and don't like when that setting remains enabled going forward.

 

Brent



[TOPIC: post.html]
#12

Rob...

[GLOBAL: userInfoPane.html]
Rob...
  • Contributor

  • 330 posts
  • Corona SDK

Yeah it seems thats one way to fix it and of course anyone else finding this same problem can now read a solution.

I still think it would have made sense to set the texture repeat on the object without setting the default and setting back.

 

IE parallax.fill = { type="image", filename="stars.png",textureWrapX= "clampToEdge" 



[TOPIC: post.html]
#13

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi Rob,

Yes, it's hard to predict the behavior of all GPUs, but thank you for helping to diagnose a fairly reasonable solution. I remember when I first experimented with this wrapping feature when Graphics 2.0 was released, I did something similar (not resetting the wrap mode) and it was behaving oddly until I reset it to default.

 

To help others in the future, I will add a warning to this document under the "Texture Keys" section which points out that the mode should be reset to normal following the fills being done.

http://docs.coronalabs.com/api/library/display/setDefault.html

 

Take care,

Brent



[TOPIC: post.html]
#14

awesume

[GLOBAL: userInfoPane.html]
awesume
  • Observer

  • 3 posts
  • Corona SDK

This is causing a very weird bug when testing on a Iphone 6. When using textureWrapX repeat, NO of the standard images (not filled, just plain images) are not loaded so the only things showing in my app when testing on iphone6 are actually the filled polygons.

 

Even the Widget buttons are not loaded (the button graphics are not loaded but the actual button function is loaded) so the App look terrible. I have tried setting display.setDefault( "textureWrapX", "repeat" ); - creating my fills and then resetting to display.setDefault( "textureWrapX", "clampToEdge" ); before creating images - But it does nothing (on my iphone 6).

 

 



[TOPIC: post.html]
#15

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @awesume,

Do you have any other devices to test on? I'm curious if this is only isolated to the iPhone 6.

 

Thanks,

Brent




[topic_controls]
[/topic_controls]