When Codea starts up, the project list is at an angle and Reference, Assets, Shader Lab, and Air Code is showing on the left. It’s like Codea is part way between the 2 screens.
The multiline comment error works fine.
@dave1707 thank you for spotting that, I was messing with the initial layout code and broke it in 166. Sorry about that!
@Simeon - just loaded 167. Not sure if it’s just a feature of this version but I have been having problems with dependencies retained after closing the project - when using the new editor. Dependency selection doesn’t appear to be retained. When loading exisiting projects in, that already have dependencies from the old editor, they are present when loaded. I like the way the dependencies selected rise to the top of the list, have you lost the retained link in introducing that?
@Simeon The Codea startup problem is fixed in version 167.
@Simeon (version 167) Sometime when I close a project, I see the project list flash just before the project closes. It’s as if both the project and project list are being shown at the same time just for an instant. It doesn’t do it on every project.
PS. I tried it again about an hour later and I couldn’t get it to mess up.
@dave1707 thank you. I’m experimenting with completely removing the custom blur code on the project browser if I can get to something that looks as good.
@Simeon I’ve tried several more times to see if I can get the project list to flash when closing a project, but I haven’t been able to cause it. I’m not sure what state I had Codea in when it happened the first time. I guess it’s just a timing issue.
@Simeon - just playing around with making seamless tiles and loaded one of @Ignatz routines to play with. Hit the bomb out of Codea again using 167. Adding collectgarbage() seems to resolve the problem. Re-printed @Ignatz’s code for you to check. Note uses a shader:
displayMode(OVERLAY)
function setup()
path = "Dropbox:Tiles/"
images={
path.."canvas6BO",
path.."Scolour2"
}
parameter.integer("Image",1,#images,1,function(a) CreateSeamless(images[a]) end)
parameter.number("Scale",0,100,0,function() img2=CreateSeamless(images[Image]) end)
parameter.boolean("scroll",false)
end
function CreateSeamless(img)
if not Scale then return end
if type(img)=="string" then img=readImage(img) end
local w,h=img.width,img.height
local m=mesh()
m:addRect(w/2,h/2,w,h)
m.shader=shader(SeamlessShader.v,SeamlessShader.f)
m.shader.texture=img
m.shader.p=Scale
local i=image(w,h)
setContext(i)
m:draw()
setContext()
mm=setupTiles(i,WIDTH,HEIGHT)
mm.pos=vec2(0,0)
end
function setupTiles(img,w,h)
local m=mesh()
m.texture=img
local v,t={},{}
--now calculate how many times the image is used along the x and z axes
--use these as the maximum texture settings
--the shader will just use the fractional part of the texture mapping
--(the shader only requires one line to change, to do this)
local x1,x2,y1,y2=0,w,0,h
local tw,th=w/img.width,h/img.height
local tx1,tx2,ty1,ty2=0,tw,0,th
v[1]=vec3(x1,y1,0) t[1]=vec2(tx1,ty1)
v[2]=vec3(x2,y1,0) t[2]=vec2(tx2,ty1)
v[3]=vec3(x2,y2,0) t[3]=vec2(tx2,ty2)
v[4]=vec3(x1,y2,0) t[4]=vec2(tx1,ty2)
v[5]=vec3(x1,y1,0) t[5]=vec2(tx1,ty1)
v[6]=vec3(x2,y2,0) t[6]=vec2(tx2,ty2)
m.vertices=v
m.texCoords=t
m.shader=shader(TileShader.vertexShader,TileShader.fragmentShader)
m:setColors(color(255))
m.t=t
m.w,m.h=img.width,img.height
return m
end
function AdjustTilePosition(x,y)
local b=mm:buffer("texCoord")
for i=1,6 do
mm.t[i]=mm.t[i]+vec2(x/mm.w,y/mm.h)
b[i]=mm.t[i]
end
end
function draw()
background(220)
if scroll then
AdjustTilePosition(2,2)
end
mm:draw()
-- collectgarbage()
end
Have you identified the problem? Just wondered if it may be concerned with a shader issue. The images I was tiling were all about 512x512 pixels in black an white and colour. Need to add your own similar images. Shader code below:
SeamlessShader = {
v = [[
uniform mat4 modelViewProjection;
attribute vec4 position;
attribute vec4 color;
attribute vec2 texCoord;
varying lowp vec4 vColor;
varying highp vec2 vTexCoord;
void main()
{
vColor = color;
vTexCoord = texCoord;
gl_Position = modelViewProjection * position;
}
]],
f = [[
precision highp float;
uniform lowp sampler2D texture;
uniform float p;
varying lowp vec4 vColor;
varying highp vec2 vTexCoord;
void main()
{
//create scaled copy of texture position
//interpolate
vec4 A = texture2D(texture,vTexCoord);
vec4 B = texture2D(texture,vec2(1.0-vTexCoord.x,vTexCoord.y));
vec4 C = texture2D(texture,vec2(vTexCoord.x,1.0-vTexCoord.y));
vec4 D = texture2D(texture,vec2(1.0-vTexCoord.x,1.0-vTexCoord.y));
float xx = 1.0 - pow(vTexCoord.x,p);
float yy = 1.0 - pow(vTexCoord.y,p);
vec4 AB = mix(A,B,xx);
vec4 CD = mix(C,D,xx);
vec4 u = mix(AB,CD,yy);
u.w=1.0;
gl_FragColor = u;
}
]]}
TileShader = {
vertexShader = [[
//
// A basic vertex shader
//
//This is the current model * view * projection matrix
// Codea sets it automatically
uniform mat4 modelViewProjection;
//This is the current mesh vertex position, color and tex coord
// Set automatically
attribute vec4 position;
attribute vec4 color;
attribute vec2 texCoord;
//This is an output variable that will be passed to the fragment shader
varying lowp vec4 vColor;
varying highp vec2 vTexCoord;
uniform float flip; //$$$$
void main()
{
//Pass the mesh color to the fragment shader
vColor = color;
vTexCoord = texCoord;
//Multiply the vertex position by our combined transform
gl_Position = modelViewProjection * position;
}
]],
fragmentShader = [[
//
// A basic fragment shader
//
//Default precision qualifier
precision highp float;
//This represents the current texture on the mesh
uniform lowp sampler2D texture;
//The interpolated vertex color for this fragment
varying lowp vec4 vColor;
//The interpolated texture coordinate for this fragment
varying highp vec2 vTexCoord;
void main()
{
lowp vec4 col = texture2D( texture, vec2(mod(vTexCoord.x,1.0), mod(vTexCoord.y,1.0)));
gl_FragColor = col;
}
]]
}
Still use a lot of @Ignatz routines, his website is one of my regular checks on new project approaches.
@Bri_G I tried your above code and Codea never crashed for me. This was on my 16GB iPad Air. How long did it run before it crashed for you. I used the below code for my images. The first one is 128x128, the second is 512x512 and the third is 1024x1024. I also did the collectgarbage(‘count’) and watched the memory size rise and then fall with no problems.
function setup()
--parameter.watch("collectgarbage('count')")
images={"Blocks:Brick Grey","Surfaces:Desert Cliff Color","Surfaces:Basic Bricks Roughness"}
parameter.integer("Image",1,#images,1,function(a) CreateSeamless(images[a]) end)
parameter.number("Scale",0,100,0,function() img2=CreateSeamless(images[Image]) end)
parameter.boolean("scroll",false)
end
@dave1707 - Thanks for the feedback, was going to apologise as I have had problem with my finger touching before in the top corner on parameters. Tried it out again and looked like it was the finger issue again. Then I tried selecting the image parameter and keeping my finger on the screen and scrolling through the images backwards and forwards repeatedly and it crashed. When I did it before it crashed quicker - timing seems inconsistent. Could be down to the speed of the finger movement. The editor I was using was the new editor. I may have to record a video to show this. Bombs straight into iPad app screen .
Edit: wonder if this is a feature of. Dropbox downloading with rapid selection of images?
Edit2: synced Dropbox and it still happened - possible rapid demand on graphic transfer is too fast, haven’t tried the memory logging - will do next.
@dave1707 - I think this may be occurring due to timing - the mesh is updated with each call from the parameter input and if complete will display, but if the mesh update overlaps the screen update then there will be a clash. Does Codea allow for that?
Edit: happens with the second parameter calling the shader, and it happens faster if you slide backwards and forwards.
Edit2: Ran with your code in setup and bombing still happened, but on the scale parameter option I couldn’t get it to crash with your code.
Wonder if there is a massive memory usage in between screen cycles a crash may occur?
@Bri_G I tried the slider to select different images about one per second and Codea eventually crashed. I tried it again with the memory watch and the memory value wasn’t a problem. It stayed fairly low even when it crashed.
@dave1707 - pheeew, begining to think I was hitting my pad with static!!! What source did you use for the images?
This could easily have been present for some time. Hope @Simeon can reproduce.
@Bri_G I mostly just use the build in Codea images. If I have other images, I put them in the Codea Dropbox folder. I don’t like to use Files because it seems confusing where things are at.
@Simeon I’m not sure how I got into this situation. See attached image. I was able to slide the screen sideways to also show the Reference, Assets, Shader Lab, and Air Code. Once I closed Codea, things were fine.
PS. If you’re viewing in landscape orientation, slide the image up to display the Codea keyboard overlaying the screen or view in portrait orientation.
@dave1707 - just drag your finger from right to left on the projects view. The projects blur into the back and the settings window scrolls in from the right. Tapping the blurred project section or dragging left to right returns to the project screen, or if you drag long enough slides in the assets/Aircode etc screen. Seems a quite neat setup now.
@Bri_G If you’re referring to my image above, apparently you didn’t slide the image all the way up. I guess I should add that comment to the original post. I only use my iPad in portrait mode, so when you view the above image in landscape, you’re missing the bottom part of the screen. That’s where you’ll see the Codea keyboard overlaying the screen. I could only get rid of it by closing Codea.
@dave1707 - oops sorry, did partially scroll it down but didn’t see keyboard there.
@Bri_G Thats OK, it’s my fault. I’m so used to viewing in portrait orientation that I forget that others view in landscape. I’ll also make that mistake when I write code. I never check what it looks like for those in landscape orientation.