Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

1.3.1 beta notes

BortelsBortels Mod
edited February 2012 in Beta Posts: 1,557

I like saveProjectInfo() - I suggest it be added to setup() as part of the boilerplate. I don't see need of a UI aside from that - we're programmers, this works. Would be nice to be able to also set an icon, but I'm sure you know that.

«13

Comments

  • SimeonSimeon Admin Mod
    Posts: 5,363

    Icon is coming. I have big plans for the icon.

    It involves saveProjectImage( "Icon", image ), readProjectImage( "ImageName" ). These will save to .png files in the project's directory. Any Icon.png in the project directory will be used as the project icon.

    We'll also add saveGlobalImage and readGlobalImage to save png files to the Documents directory.

    I also want to expose the regular Lua file IO — but with it's root set to the Project directory.

  • BortelsBortels Mod
    Posts: 1,557

    So - do I read right that I might also be able to saveProjectImage("bigboom", image) then later on do sprite("bigboom")? That would be way cool.

    It would be nice to be able to do a read (not write) from another project's directory, and/or to read/write global (ie. have a shared area).

  • Posts: 2,161

    Now that we have meshes, the ability to use pngs from the project directory would be fantastic. I'm experimenting with adding meshes to my shape explorer code. I have it working with colours, and now I'm trying to add images. But it's more fun if I can use proper images rather than just stuff I can mock-up with the image class.

    Oh, and I really want internal code sharing. I find that I have to concentrate on one project at a time, otherwise I get all confused as to which project contains the latest version of a particular file from my library. Being able to load files from a central library (of my own creation) would be fantastic.

  • BortelsBortels Mod
    Posts: 1,557

    Hmm.

    I am getting an odd error when I have the following:

    -- Use this function to perform your initial setup
    function setup()
       saveProjectInfo("random tests")
       i = image(64, 64)
       -- and more code
    

    The error is

    error: [string "-- Use this function to perform your initia..."]:3: Expected two arguments
    

    If I add a second parameter (I used "1") to the saveProjectInfo() call, it works, in that it doesn't error out - but the project description isn't set.

  • SimeonSimeon Admin Mod
    Posts: 5,363

    Yeah saveProjectInfo works like saveProjectData — it takes a key and a value. The first argument is the key. So:

    saveProjectInfo( "Description", "This will write into the description field" )

    saveProjectInfo( "Author", "This will write into the author field" )

    saveProjectInfo( "Foobar", "This will write into some random field" )

  • BortelsBortels Mod
    edited February 2012 Posts: 1,557

    Ah - the missing info. That's better.

    It still fails with that seemingly nonsensical error if you call it with the wrong # of parameters (I accidentally left the ,1 at the end, so it had 3)

    And - where is the author displayed? is it?

  • SimeonSimeon Admin Mod
    Posts: 5,363

    Hmm the error seemed okay to me: "Expected two arguments" — what was the error when you had 3 arguments?

    The author isn't displayed yet. But it's a field we'd like to use in the future so storing author information in there now is not a bad thing to do.

  • Posts: 2,161

    I'm getting a lot of crashes with the new build. Almost every time I try to run my cube project, it crashes. When I restart then it runs fine so my guess is that it's to do with saving the files.

  • SimeonSimeon Admin Mod
    Posts: 5,363

    Thanks for reporting this. I've put up a new build, 1.3.1 (5), please let me know if it fixes your crashes.

    It seems to be due to the emergency-exit-gesture.

  • edited February 2012 Posts: 2,161

    Yes, that fixed my crashes.

    I like the new theme, I'd probably make it my main coding theme. Three things so far:

    1. The tabs are now too dim. It's hard to read the non-active ones.
    2. Ditto on the suggested completions.
    3. Any way to dim the keyboard? It's very bright in comparison to the rest.

    (Hadn't noticed the dedicated thread on this. Should I repost these comments there?)

  • SimeonSimeon Admin Mod
    Posts: 5,363

    It's fine here @Andrew.

    1. That's an easy fix, thanks for reporting it. I'll make the text brighter on inactive tabs
    2. Also on the completions.
    3. Dimming the keyboard is tricky - I can certainly dim the top row, but the main keyboard is iOS standard. So I'd have to recreate it from scratch to get a dim version. Maybe after version 1.3.1, as it's quite a big task.
  • BortelsBortels Mod
    edited February 2012 Posts: 1,557

    The yellow "f" tabs next to functions scream "tap here to fold/unfold the function", and they don't, and that made me sad.

    But, if they actually did that, I'd want them bigger.

    Random thought: I'd love a bigger editor font. Mostly because I have bigger fingers, and I am often unable to select the correct line the first tap. I can't be the only one. Figured I'd suggest it while you're mucking about in the editor code.

  • Posts: 447

    The new theme looks really good. My only suggestion is giving comments a brighter color. I usually like comments that stand out more than code and use comments to delimit sections of code.

    Maybe switching comment colors with the string colors would work better.

  • Posts: 447

    small bug report: lineCapMode is not drawn in light blue like all other primitive functions (it's drawn in white). Don't know if this is just in this theme or the original one as well

  • SimeonSimeon Admin Mod
    Posts: 5,363

    Thanks @ruilov — forgot to add that one.

    Do you prefer the graphics functions highlighted? Do you think we should highlight all API calls in the same colour regardless of whether they belong to graphics?

  • Posts: 447

    not a big deal for me, but yes I'd highlight all the built-in API calls in the same color. A bigger deal for me is the muted comments - I like comments to stand out above anything else, but don't know if others would agree.

  • SimeonSimeon Admin Mod
    edited February 2012 Posts: 5,363

    Yeah I'll bring them up. I was copying my Xcode colour scheme and copied the wrong comment colour. After you mentioned it I realised that I used the dark comment colour and not the normal one.

  • Posts: 447

    I might steal your color scheme at work. I've had the same one for a few years now, and time for a change

  • Posts: 447

    I spoke against instruction limit before, but now that I'm working on a largish piece of code, and using beta, it's actually coming handy. When my app freezes at least I have a way to know if it's my code, or if it's codea.

  • Posts: 447

    I'm getting pretty frequent freezes out of codea now. It could be my code, but it did not throw an exception when i set the instruction limit. Also the codea buttons stop responding.

    Not sure how to debug or report this. Is it possible for me to download an ealier beta to see if it still happens?

  • Posts: 2,161

    I was going to post something similar to ruilov's previous post. The crashes are back in the latest beta, not as bad as in the version where I mentioned it before, though.

    I'm also getting some strange behaviour with meshes and textures. In my Cube/3d shape (the name "cube" is getting increasingly inappropriate) project then I reuse the same mesh for the shapes, even when completely changing the shape. This doesn't always work smoothly especially where textures are involved. Sometimes the texture doesn't get rendered correctly, and sometimes it persists when I think I've disabled it (though that might just be me not blanking all the pieces: texture and texCoords, I'll have to investigate). Also, I'm finding it hard to render a texture exactly to, say, a rectangle. I seem to be missing the edge - if you look very carefully at my latest pictures on Twitter then you'll see in the die that the edges aren't flush, and in the knot then there's a curious band around the torus (both of these are done with textures).

  • Posts: 2,161

    Oh, and another thing about meshes: the y-coordinate is upside-down. If I define an image and draw on it, then define a mesh and use that image, then I have to invert the y-coordinate. For example:

    m = mesh()
    m.texture = myimg
    m.vertices = {
       vec2(100,100),
       vec2(200,100),
       vec2(200,200),
       vec2(100,100),
       vec2(100,200),
       vec2(200,200)
    }
    m.texCoords = {
       vec2(0,0),
       vec2(1,0),
       vec2(1,1),
       vec2(0,0),
       vec2(0,1),
       vec2(1,1)
    }
    

    draws myimg upside-down (but correct in the left-right direction).

  • SimeonSimeon Admin Mod
    Posts: 5,363

    Definitely sounds like something I've messed up. Will look into the crashes soon — thanks guys.

    The texture stuff sounds odd. So it doesn't turn off when you set mesh.texture to nil? That's a bug.

    The texCoords issue I suspect has more to do with precision. The highest precision on the iPad GPU is 16 bits per float. So: not very high.

  • SimeonSimeon Admin Mod
    Posts: 5,363

    You are completely correct about the y-coordinate being upside down, we'll change this. I think for setRectTex it works the right way.

  • Posts: 2,161

    Ah, the problem with fitting a texture to a rectangle is to do with drawing on an image. I was filling the background of the image by drawing a rectangle of a single colour on to it. Something like:

    img = image(100,100)
    setContext(img)
    rect(0,0,100,100)
    

    But that doesn't quite work. It seems that that doesn't actually draw a rectangle of side length 100 but rather it draws a rectangle which is guaranteed to be at most side length 100, but perhaps a little less. So I wasn't actually filling the whole image but leaving a pixel or so along some sides, which becomes noticeable when magnified and distorted on a mesh. Solution: draw a bigger rectangle. Now the die and torus knot look much better.


    I'll upload new pictures, but just checked and you can quite clearly see the missing pixels on the old ones:

    Torus knot

    http://t.co/yGZZ74s7

    The dark band around the torus at just anti-clockwise from the top is what I'm talking about in this one.

    Die

    http://t.co/JC3cFGTZ

    The vertical line between the four and six is half-white, half-black. That's because it is wholly not there and what you're seeing is the faces behind.

  • SimeonSimeon Admin Mod
    Posts: 5,363

    Perhaps it was because the rectangle was drawn with smooth() enabled, which performs some smoothing of the edges. With noSmooth() do the seams still occur?

  • SimeonSimeon Admin Mod
    Posts: 5,363

    @ruilov it seems your crashes are occurring in an image update when you are rendering a mesh. That is: you are rendering a mesh that is using an image that is being updated every so often?

  • Posts: 2,161

    So it doesn't turn off when you set mesh.texture to nil?

    I think this was what I wasn't doing. I've now set it to do that on changing shape and it's now working as I expect (sort of ... something weird is happening when I go from a shape with a texture to one without, but I'll investigate a bit).

    I was seeing some very strange effects, though, when reusing a mesh. Again, it might have been due to me not clearing things properly, but there did seem to be some stuff persisting, even between successive runs of a program. I can't reproduce it now, but if I do I'll take a screenshot.

  • SimeonSimeon Admin Mod
    Posts: 5,363

    It sounds like there are some state bugs in mesh. I'll have a look for them.

  • Posts: 2,161

    @Simeon: Yes, adding noSmooth fixes it. Great!

  • Posts: 2,161

    And the problem with the vanishing meshes was that I wasn't setting texCoords to nil in between.

    Strikes me that it might be worth having a mesh:reset() function that blanks everything. Especially if one has used the rects to define the mesh, one might not know all that needs to be blanked.

    Which gets me onto something I was wondering: I'm reusing a mesh here, but every frame then I reset its vertices (because I recompute their positions). How much am I saving by reusing the mesh? That's a two-part question because sometimes I'm using a texture (which doesn't change, though the texCoords does because it has to keep step with the vertices) and sometimes colours (which do change). So sometimes I'm essentially completely redefining the mesh every frame, and others I'm redefining it all except for the texture. Is there a significant benefit to reuse, or would I not notice if I had a new mesh every time? (Might be memory penalties here as all those meshes wouldn't be garbage collected every frame.)

  • SimeonSimeon Admin Mod
    edited February 2012 Posts: 5,363

    mesh:reset() is a good idea.

    Here's a breakdown of where performance differs between mesh and sprite.

    Mesh, going from Lua code to GPU
    Vertices defined in Lua -[set]-> Copied into internal buffer -[draw]-> Copied into GPU memory

    Sprite, going from Lua code to GPU
    Parameters defined in Lua -[draw]-> 6 Vertices computed internally and copied into GPU memory

    The main difference between mesh and sprite is that mesh can submit batches of more than 6 vertices at a time. The biggest overhead comes from moving data from main memory to the GPU. The more often you do this, the slower things get.

    If you want to draw 5000 sprites, for example, we do the following 5000 times:

    Allocate 6 vertices (+ texture coords), submit 6 vertices to GPU, draw

    If you do the same with 5000 quads in a mesh, then we do this once:

    Copy 5000 * 6 vertices to GPU, draw

    We're looking at making some modifications to mesh so we can do the following:

    Create your vertices in Lua, copy them into a mesh. The mesh creates a write-only buffer in GPU memory and keeps a pointer to the GPU memory. It then exposes a special vertex array object to your Lua code. You can manipulate the vertices individually without having to copy the whole set and they change directly in GPU memory. So there is no copy step when you draw the mesh.

  • SimeonSimeon Admin Mod
    Posts: 5,363

    @Andrew I've fixed your crash (but not @ruilov's which appears to be a bit different).

    I've also fixed the inverted-Y texture coordinate problem. Hopefully this won't mean too many changes to your code.

  • edited February 2012 Posts: 447

    Simeon indeed i've added functionality to draw an image with setcontext and then i use that as the texture of a mesh. I didnt think the image was ever updated though, i thought i created it once and that was it.

    Code that does is in the Layout.makeStepButton in the code i sent you last night

    Edit: and SpriteObj.makeSprite in the Utils tab

  • SimeonSimeon Admin Mod
    Posts: 5,363

    Thanks @ruilov. I've been testing your code on my iPad 1 but have yet to experience the crash. Will look into those two areas.

    I did notice the physics slow down on the title screen. It happens after 10 seconds or so on iPad 1 then eventually speeds up again.

  • Posts: 447

    Just play the count in binary level and it will usually eventually freeze (i'm on ipad 2, will try on ipad1 now)

  • SimeonSimeon Admin Mod
    Posts: 5,363

    It's still playing out, no freeze yet. It may be fixed. A new build (7) is being uploaded and should definitely fix @Andrew's bug — and hopefully also your freezing issue.

  • SimeonSimeon Admin Mod
    edited February 2012 Posts: 5,363

    It played through without issues in 1.3.1 (7). Took longer to play through than to upload the build :) I don't know how you even managed to build a puzzle so difficult.

    I've also improved the comment brightness. (And the inactive tab text brightness for @Andrew_Stacey)

  • Posts: 447

    I didnt want it to be difficult, i wanted to count in binary and difficulty wasnt going to stop me!

  • Posts: 447

    just got the freeze with 1.3.1(7). Also removed the calls to SpriteObj.makeSprite so now I should only be using sprites for mesh textures and still got a freeze. Unfortunately I'll only get to use an ipad1 tonight to test on it.

    Will keep digging.

  • Posts: 2,161

    Only noticed the y-axis inversion because of the die. I made an atlas for it and decided that to get the best accuracy, I'd make an image large enough for 8 sides rather than 6, but left two blank. So I was a little surprised when two faces of the die were missing.

    (Incidentally, when thinking about atlases for meshes, given that we currently specify textures using decimals, it's worth ensuring that the components of the atlas lie at places where one can say where they are using a finite decimal, so atlases should consist of a grid of elements with number of rows and columns some multiples of 2 and 5 - if that makes sense.)

    New colours are much better. Liking the look a lot.

  • Posts: 447

    Simeon, re my codea freezes, I noticed that if I start directly from the level selection screen, they go away (in setup() just uncomment currentScreen = LevelSelect() and comment out currentScreen = StartScreen())

    This makes me think that it has something to do with the physics. I tried showing a very simple screen after touching the StartScreen (instead of the usual level select), simply displaying ElapsedTime as a text string, to see if I could catch it freezing, but it didn't freeze. So it might be something to do with the interaction between the startscreen and something else I'm doing.

    Also tried on ipad1 with 5.0.1 iOS and it did freeze, although only towards the second time I played the binary counting level, so it took some time.

    Very mysterious.

  • Posts: 2,161

    No crashes so far, and liking the new colours.

    There is definitely something funny going on with meshes. Even when I tear down and set up a new mesh for a new shape then I get strange behaviour after doing that a Couple of times - see just-posted picture on Twitter.

  • Posts: 447

    Andrew, for mine I'm more suspicious of the physics than meshes at this point. But who knows...

  • Posts: 2,161

    The mesh problem is separate to the crash, by the way.

    I've narrowed down the mesh rendering issue to using a texture while recording (which is annoying because I have a fun playlist lined up!).

  • JohnJohn Admin Mod
    Posts: 616

    Is the texture created using setContext during the recording?

  • SimeonSimeon Admin Mod
    Posts: 5,363

    Thanks for narrowing it down @ruilov. I'm running the binary counting level at the moment after commenting at the start screen and uncommenting level select. Hopefully it freezes so I can see what's going on.

  • Posts: 447

    sorry, I think we had some miscommunication there. If I start directly from the level select screen then it stop freezing. It's when I start from the StartScreen that it freezes.

  • SimeonSimeon Admin Mod
    Posts: 5,363

    @ruilov I've managed to play it through many times with the changes you suggested. I can't seem to cause the freeze here.

  • SimeonSimeon Admin Mod
    Posts: 5,363

    So do the opposite of this? "(in setup() just uncomment currentScreen = LevelSelect() and comment out currentScreen = StartScreen())"

    Either way it seems to work, though.

Sign In or Register to comment.