Principle drawing screen in Corona

When I write a program in Windows, everything is simple, I know what happened and when.

I know that there are two DirextX buffer.

As long as I draw in the 1st, the user sees the 2nd.

A typical program for PureBasic looks:

Repeat  
  
 FlipBuffers()  
 ClearScreen( #black )  
 DisplaySprite(0, x, y)  
  
 Event = WindowEvent()  
  
Until Event = #PB\_Event\_CloseWindow  

Corona uses OpenGL, so obviously in OpenGl also have buffers.

I can control it like that?

And another question. Even if I can not control buffer. Can I paint a image.
And then when I need to display it on the screen?

[import]uid: 138345 topic_id: 30489 reply_id: 330489[/import]

I’m sure under the hood OpenGL is drawing the frame off screen then drawing the whole fame to the screen once its ready. But Corona hides this from you, just know they are handling it for you.

You can draw things outside the viewable screen them move them to the screen when you are ready.
[import]uid: 19626 topic_id: 30489 reply_id: 122201[/import]

ou can draw things outside the viewable screen them move them to the screen when you are ready.

But how?

Can I draw a series of images and then quickly draw them off? [import]uid: 138345 topic_id: 30489 reply_id: 122208[/import]

G=display.newGroup()  
for i=1,10 do  
 img[i]=display.newImage(G,"MyImage"..i..".png",0,0)  
 img[i].x=i\*50; img[i].y=200;   
end  
G.isVisible=false  

After you do the above, you can set G.isVisible=true to show all the images, G.isVisible=false to hide all the images, or G.isVisible=true and then set img[5].isVisible=false to show all but hide the fifth one. Etc. [import]uid: 160496 topic_id: 30489 reply_id: 122212[/import]

I do not have pictures.

My programa renders image on the fly (Pixel Art).

At the entrance I have a picture of the retro computer - ZX Spectrum.

Size of 6912 bytes (in native format).

I infer it is converted and displayed.
[lua]local path = system.pathForFile( “artist.scr” )
local fileHandle = io.open( path, “rb” )
scr = fileHandle:read( “*a” )

color = {

0 , 0 , 0 ,
0 , 0 , 180 ,
180 , 0 , 0 ,
180 , 0 , 180 ,
0 , 178, 0 ,
0 , 178, 180 ,
180 , 178, 0 ,
180 , 178, 180 ,

0 , 0 , 0 ,
0 , 0 , 252 ,
252 , 0 , 0 ,
252 , 0 , 252 ,
0 , 254, 0 ,
0 , 254, 252 ,
252 , 254, 0 ,
252 , 254, 252

}

pixelline = {0,256,512,768,1024,1280,1536,1792,32,288,544,800,1056,1312,1568,1824,64,320,576,832,1088,1344,1600,1856,96,352,608,864,1120,1376,1632,1888,128,384,640,896,1152,1408,1664,1920,160,416,672,928,1184,1440,1696,1952,192,448,704,960,1216,1472,1728,1984,224,480,736,992,1248,1504,1760,2016,2048,2304,2560,2816,3072,3328,3584,3840,2080,2336,2592,2848,3104,3360,3616,3872,2112,2368,2624,2880,3136,3392,3648,3904,2144,2400,2656,2912,3168,3424,3680,3936,2176,2432,2688,2944,3200,3456,3712,3968,2208,2464,2720,2976,3232,3488,3744,4000,2240,2496,2752,3008,3264,3520,3776,4032,2272,2528,2784,3040,3296,3552,3808,4064,4096,4352,4608,4864,5120,5376,5632,5888,4128,4384,4640,4896,5152,5408,5664,5920,4160,4416,4672,4928,5184,5440,5696,5952,4192,4448,4704,4960,5216,5472,5728,5984,4224,4480,4736,4992,5248,5504,5760,6016,4256,4512,4768,5024,5280,5536,5792,6048,4288,4544,4800,5056,5312,5568,5824,6080,4320,4576,4832,5088,5344,5600,5856,6112}
attr = {6144,6144,6144,6144,6144,6144,6144,6144,6176,6176,6176,6176,6176,6176,6176,6176,6208,6208,6208,6208,6208,6208,6208,6208,6240,6240,6240,6240,6240,6240,6240,6240,6272,6272,6272,6272,6272,6272,6272,6272,6304,6304,6304,6304,6304,6304,6304,6304,6336,6336,6336,6336,6336,6336,6336,6336,6368,6368,6368,6368,6368,6368,6368,6368,6400,6400,6400,6400,6400,6400,6400,6400,6432,6432,6432,6432,6432,6432,6432,6432,6464,6464,6464,6464,6464,6464,6464,6464,6496,6496,6496,6496,6496,6496,6496,6496,6528,6528,6528,6528,6528,6528,6528,6528,6560,6560,6560,6560,6560,6560,6560,6560,6592,6592,6592,6592,6592,6592,6592,6592,6624,6624,6624,6624,6624,6624,6624,6624,6656,6656,6656,6656,6656,6656,6656,6656,6688,6688,6688,6688,6688,6688,6688,6688,6720,6720,6720,6720,6720,6720,6720,6720,6752,6752,6752,6752,6752,6752,6752,6752,6784,6784,6784,6784,6784,6784,6784,6784,6816,6816,6816,6816,6816,6816,6816,6816,6848,6848,6848,6848,6848,6848,6848,6848,6880,6880,6880,6880,6880,6880,6880,6880}
paper_ = {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15}
ink_ = {0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7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,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
}

function plot (x,y,size, r,g,b)

pix = display.newRect( x, y, size, size)
pix:setFillColor( r,g,b )

end

tm = system.getTimer()

for y = 0, 191 do

for x = 0, 31 do

chr_pixels = scr:byte(1+ ( pixelline[1+y] + x) )
chr_attr = scr:byte(1+ ( attr[1+y] + x) )

paper = paper_[chr_attr+1]
ink = ink_[chr_attr+1]

for z=0,7 do

if bit[1+(z*256 +chr_pixels)]==0 then

plot( x*8 + z, y+32, 1, color[1+paper*3], color[2+paper*3], color[3+paper*3] )

else

plot( x*8 + z, y+32, 1, color[1+ink*3], color[2+ink*3], color[3+ink*3] )

end

end

end

end

print ( system.getTimer()-tm )[/lua]

Project https://dl.dropbox.com/u/6439155/zxspectrum-viewer.zip

By the way, it works extremely slow.

I translated all the bitwise operators in the table, but still damn slow. [import]uid: 138345 topic_id: 30489 reply_id: 122216[/import]

And thanks for the explanation display.newsGroup ().

In the tutorial, it’s not very clear explained by. [import]uid: 138345 topic_id: 30489 reply_id: 122217[/import]

Let’s make a few assumptions.
You’re screen is 480x320 and you want to have a full screen offscreen and slide it on screen.

bg1 = display.newImageRect("firstbackground.png", 480, 320)  
bg1.x = display.contentCenterX  
bg1.y = display.contentCenterY  
  
bg2 = display.newImageRect("secondbg.png", 480, 320)  
bg2.x = display.contentCenterX - 480  
bg2.y = display.contentCenterY  
  
transition.to(bg1,{time=1000,x=display.contentCenterX + 480})  
transition.to(bg2,{time=1000,x=display.contentCenterX })  

Now the thing that might seem confusing here is my using display.contentCenterX, but Corona by default uses a “center reference point”. So the center of the offscreen background is -240
[import]uid: 19626 topic_id: 30489 reply_id: 122218[/import]

Corona, with *every* display element having to be an individually addressed object, is NOT the way to do pixel-level plotting on the screen. WAY too many objects making things very slow.

You *can* make a picture of the above though - PNG so it is lossless with no artifacts, then just load it on screen. [import]uid: 160496 topic_id: 30489 reply_id: 122219[/import]

ZX Spectrum Pixel Art example - :slight_smile:

[import]uid: 138345 topic_id: 30489 reply_id: 122220[/import]

I wanted to make a viewer file of pictures from the ZX Spectrum.

As a first sample application for Corona. [import]uid: 138345 topic_id: 30489 reply_id: 122221[/import]

I’m sure under the hood OpenGL is drawing the frame off screen then drawing the whole fame to the screen once its ready. But Corona hides this from you, just know they are handling it for you.

You can draw things outside the viewable screen them move them to the screen when you are ready.
[import]uid: 19626 topic_id: 30489 reply_id: 122201[/import]

ou can draw things outside the viewable screen them move them to the screen when you are ready.

But how?

Can I draw a series of images and then quickly draw them off? [import]uid: 138345 topic_id: 30489 reply_id: 122208[/import]

G=display.newGroup()  
for i=1,10 do  
 img[i]=display.newImage(G,"MyImage"..i..".png",0,0)  
 img[i].x=i\*50; img[i].y=200;   
end  
G.isVisible=false  

After you do the above, you can set G.isVisible=true to show all the images, G.isVisible=false to hide all the images, or G.isVisible=true and then set img[5].isVisible=false to show all but hide the fifth one. Etc. [import]uid: 160496 topic_id: 30489 reply_id: 122212[/import]

I do not have pictures.

My programa renders image on the fly (Pixel Art).

At the entrance I have a picture of the retro computer - ZX Spectrum.

Size of 6912 bytes (in native format).

I infer it is converted and displayed.
[lua]local path = system.pathForFile( “artist.scr” )
local fileHandle = io.open( path, “rb” )
scr = fileHandle:read( “*a” )

color = {

0 , 0 , 0 ,
0 , 0 , 180 ,
180 , 0 , 0 ,
180 , 0 , 180 ,
0 , 178, 0 ,
0 , 178, 180 ,
180 , 178, 0 ,
180 , 178, 180 ,

0 , 0 , 0 ,
0 , 0 , 252 ,
252 , 0 , 0 ,
252 , 0 , 252 ,
0 , 254, 0 ,
0 , 254, 252 ,
252 , 254, 0 ,
252 , 254, 252

}

pixelline = {0,256,512,768,1024,1280,1536,1792,32,288,544,800,1056,1312,1568,1824,64,320,576,832,1088,1344,1600,1856,96,352,608,864,1120,1376,1632,1888,128,384,640,896,1152,1408,1664,1920,160,416,672,928,1184,1440,1696,1952,192,448,704,960,1216,1472,1728,1984,224,480,736,992,1248,1504,1760,2016,2048,2304,2560,2816,3072,3328,3584,3840,2080,2336,2592,2848,3104,3360,3616,3872,2112,2368,2624,2880,3136,3392,3648,3904,2144,2400,2656,2912,3168,3424,3680,3936,2176,2432,2688,2944,3200,3456,3712,3968,2208,2464,2720,2976,3232,3488,3744,4000,2240,2496,2752,3008,3264,3520,3776,4032,2272,2528,2784,3040,3296,3552,3808,4064,4096,4352,4608,4864,5120,5376,5632,5888,4128,4384,4640,4896,5152,5408,5664,5920,4160,4416,4672,4928,5184,5440,5696,5952,4192,4448,4704,4960,5216,5472,5728,5984,4224,4480,4736,4992,5248,5504,5760,6016,4256,4512,4768,5024,5280,5536,5792,6048,4288,4544,4800,5056,5312,5568,5824,6080,4320,4576,4832,5088,5344,5600,5856,6112}
attr = {6144,6144,6144,6144,6144,6144,6144,6144,6176,6176,6176,6176,6176,6176,6176,6176,6208,6208,6208,6208,6208,6208,6208,6208,6240,6240,6240,6240,6240,6240,6240,6240,6272,6272,6272,6272,6272,6272,6272,6272,6304,6304,6304,6304,6304,6304,6304,6304,6336,6336,6336,6336,6336,6336,6336,6336,6368,6368,6368,6368,6368,6368,6368,6368,6400,6400,6400,6400,6400,6400,6400,6400,6432,6432,6432,6432,6432,6432,6432,6432,6464,6464,6464,6464,6464,6464,6464,6464,6496,6496,6496,6496,6496,6496,6496,6496,6528,6528,6528,6528,6528,6528,6528,6528,6560,6560,6560,6560,6560,6560,6560,6560,6592,6592,6592,6592,6592,6592,6592,6592,6624,6624,6624,6624,6624,6624,6624,6624,6656,6656,6656,6656,6656,6656,6656,6656,6688,6688,6688,6688,6688,6688,6688,6688,6720,6720,6720,6720,6720,6720,6720,6720,6752,6752,6752,6752,6752,6752,6752,6752,6784,6784,6784,6784,6784,6784,6784,6784,6816,6816,6816,6816,6816,6816,6816,6816,6848,6848,6848,6848,6848,6848,6848,6848,6880,6880,6880,6880,6880,6880,6880,6880}
paper_ = {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15}
ink_ = {0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,8,9,10,11,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0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
}

function plot (x,y,size, r,g,b)

pix = display.newRect( x, y, size, size)
pix:setFillColor( r,g,b )

end

tm = system.getTimer()

for y = 0, 191 do

for x = 0, 31 do

chr_pixels = scr:byte(1+ ( pixelline[1+y] + x) )
chr_attr = scr:byte(1+ ( attr[1+y] + x) )

paper = paper_[chr_attr+1]
ink = ink_[chr_attr+1]

for z=0,7 do

if bit[1+(z*256 +chr_pixels)]==0 then

plot( x*8 + z, y+32, 1, color[1+paper*3], color[2+paper*3], color[3+paper*3] )

else

plot( x*8 + z, y+32, 1, color[1+ink*3], color[2+ink*3], color[3+ink*3] )

end

end

end

end

print ( system.getTimer()-tm )[/lua]

Project https://dl.dropbox.com/u/6439155/zxspectrum-viewer.zip

By the way, it works extremely slow.

I translated all the bitwise operators in the table, but still damn slow. [import]uid: 138345 topic_id: 30489 reply_id: 122216[/import]

And thanks for the explanation display.newsGroup ().

In the tutorial, it’s not very clear explained by. [import]uid: 138345 topic_id: 30489 reply_id: 122217[/import]

Let’s make a few assumptions.
You’re screen is 480x320 and you want to have a full screen offscreen and slide it on screen.

bg1 = display.newImageRect("firstbackground.png", 480, 320)  
bg1.x = display.contentCenterX  
bg1.y = display.contentCenterY  
  
bg2 = display.newImageRect("secondbg.png", 480, 320)  
bg2.x = display.contentCenterX - 480  
bg2.y = display.contentCenterY  
  
transition.to(bg1,{time=1000,x=display.contentCenterX + 480})  
transition.to(bg2,{time=1000,x=display.contentCenterX })  

Now the thing that might seem confusing here is my using display.contentCenterX, but Corona by default uses a “center reference point”. So the center of the offscreen background is -240
[import]uid: 19626 topic_id: 30489 reply_id: 122218[/import]

Corona, with *every* display element having to be an individually addressed object, is NOT the way to do pixel-level plotting on the screen. WAY too many objects making things very slow.

You *can* make a picture of the above though - PNG so it is lossless with no artifacts, then just load it on screen. [import]uid: 160496 topic_id: 30489 reply_id: 122219[/import]

ZX Spectrum Pixel Art example - :slight_smile:

[import]uid: 138345 topic_id: 30489 reply_id: 122220[/import]

I wanted to make a viewer file of pictures from the ZX Spectrum.

As a first sample application for Corona. [import]uid: 138345 topic_id: 30489 reply_id: 122221[/import]