PreloadTextures how it work?

Hi,

I am trying to change this parameter:

display.setDefault( "preloadTextures", false)

On simulator I have no error but on device the app crash. When I display an image the errors say (nil value) for the sprite sheet

Can someone help me?

Because I find no information about how to use it (Doc)

Thanks

This work only on simulator on device it s like if it s on false

Do you have to set this value at a special place?

display.setDefault( "isImageSheetSampledInsideFrame", true)

Hi @remiduchalard,

There are two questions here. Which do you need help with first? I can attempt to assist you. Can you please post some code you’re using? Which devices are you testing on?

Thanks,

Brent

thank you for your help! Firstly help me on “preloadTextures”.

I have made test on three different android device (jiayu S3, THL W8s, Nexus 4).

Main.lua

display.setDefault( "preloadTextures", false) imagemenu.engrenages=graphics.newImageSheet("choniveau/engrenages.jpg",{width=696,height=606,numFrames=1,sheetContentWidth=696,sheetContentHeight=606}) engrenages=display.newImage(imagemenu.engrenages,1)

I have an error at the line 3. On simulator it work but not on device. Without the first line I have no error on device.

Do you need more information?

Thanks

Rémi

Does the same crash/error occur if you use this with display.newImageRect()?

[lua]

engrenages=display.newImageRect( imagemenu.engrenages, 1, 696, 606 )

[/lua]

I have done more test. Device where the app crash, it crash at the same code line (with image Rect). But on some device it didn’t crash at all. The link of the apk. In a few week I will delete it.

https://drive.google.com/open?id=0B5XGunixm_xqa1pGYW5pVURoVUk 

I hope you can help me :slight_smile:

Is the spelling in your file path 100% correct: “choniveau/engrenages.jpg”

Some operating systems are case sensitive, and some are not, which would explain why it works on some of your devices.

It’s exacly the same writing. The path is not the problem because when I remove the line

display.setDefault( "preloadTextures", false) 

it’s work well

Hi @remiduchalard,

Can you please test it so that your command to create the image occurs at least one time-step after your command to “display.setDefault()”? For example, create a tiny timer:

[lua]

display.setDefault( “preloadTextures”, false )

local function onDelay()

   imagemenu.engrenages=graphics.newImageSheet(“choniveau/engrenages.jpg”,{width=696,height=606,numFrames=1,sheetContentWidth=696,sheetContentHeight=606})

   engrenages=display.newImage(imagemenu.engrenages,1)

end

timer.performWithDelay( 100, onDelay )

[/lua]

Pleae test and report to me if this crashes on the same devices your current code is crashing on.

Best regards,

Brent

We have the same error. I have look what is special on this device. It’s my only device with java 6

Can I try something else?

Thank you Brent Sorrentino for your help!

On simulator is load a lot of file before display them. With 

display.setDefault( "preloadTextures", false)

I have the same Texture Memory used at the end of the loading (I create a lot of imagesheet), that is not normal?

The problem is because suffix is nil, on some device

see the post: 

I have explain my bug on it.

Hi @remiduchalard,

Thanks for the update. Just to provide some more clarity on “preloadTextures”, here is what I received from the engineers:

Basically, setting this to “true” loads the texture as soon as you create it or pass it to a newly created display object. When set to “false”, it won’t load the texture into memory until it needs to be rendered on screen (loading is deferred). So, setting it to “false” only loads them at the exact moment when they’re needed, which may cause a visual stutter in the frame rate. This is not ideal for a game, but might be fine in a business app.

Best regards,

Brent

Thank you @Brent-Sorrentino @BrentSorrentino for your answer. I have done some test on device and simulator. And after loading (I display no image I only create image sheet) I have the same texture memory used, what that’s mean? (Is it a reserve memeory for image? Or I don’t use it correctly?)

Thank you so much for your help!

Rémi

After analyse apparently the texture memory of an imagesheet is display as use (“textureMemoryUsed”) but it’s empty until we display the image.

Can I have more information of the working of preloadTextures?

This work only on simulator on device it s like if it s on false

Do you have to set this value at a special place?

display.setDefault( "isImageSheetSampledInsideFrame", true)

Hi @remiduchalard,

There are two questions here. Which do you need help with first? I can attempt to assist you. Can you please post some code you’re using? Which devices are you testing on?

Thanks,

Brent

thank you for your help! Firstly help me on “preloadTextures”.

I have made test on three different android device (jiayu S3, THL W8s, Nexus 4).

Main.lua

display.setDefault( "preloadTextures", false) imagemenu.engrenages=graphics.newImageSheet("choniveau/engrenages.jpg",{width=696,height=606,numFrames=1,sheetContentWidth=696,sheetContentHeight=606}) engrenages=display.newImage(imagemenu.engrenages,1)

I have an error at the line 3. On simulator it work but not on device. Without the first line I have no error on device.

Do you need more information?

Thanks

Rémi

Does the same crash/error occur if you use this with display.newImageRect()?

[lua]

engrenages=display.newImageRect( imagemenu.engrenages, 1, 696, 606 )

[/lua]

I have done more test. Device where the app crash, it crash at the same code line (with image Rect). But on some device it didn’t crash at all. The link of the apk. In a few week I will delete it.

https://drive.google.com/open?id=0B5XGunixm_xqa1pGYW5pVURoVUk 

I hope you can help me :slight_smile:

Is the spelling in your file path 100% correct: “choniveau/engrenages.jpg”

Some operating systems are case sensitive, and some are not, which would explain why it works on some of your devices.