March 05, 2017, 11:08:55 am

Okay, so I'm making a quest-log type menu that is semi-dynamic, meaning they have a set order and are organized by location, but don't appear until activated.Like so:StoreABCHouseABCDForestACD

So basically I have a function that checks, orders, and creates the selections for the menu and then returns the selection order and the selection display in an object. The display is created basically like so:

The problem is when I call the menu to be displayed, it only displays the title(from drawText) and not the header or icon(from prim.blit). This is my first go with surfaces, so maybe I'm just not using them right, or maybe I'm missing something?Thanks in advance.

object.image.drawText(x, y, text);object.image.drawImage(x, y, image); // not too sure on this one

But what are you trying to do? Is this for a menu or for an on-screen hud? I've never used surfaces to draw many things on to unless I'm pre-processing images into one image to draw, but rarely do I do that.

If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

object.image.drawText(x, y, text);object.image.drawImage(x, y, image); // not too sure on this one

But what are you trying to do? Is this for a menu or for an on-screen hud? I've never used surfaces to draw many things on to unless I'm pre-processing images into one image to draw, but rarely do I do that.

The nice thing about Sphere v2 is that screen is just another Surface - so you can draw stuff just as easily to any surface as you can to the screen. At least, you're supposed to be able to. scojin's case seems to be broken, and I can't figure out what's wrong based on reading his code. I'll have to do some testing myself.

Yeah, that's correct. I'm basically piecing together an image from a few smaller images. I am preprocessing it when the menu is first called so it doesn't have to run the code to build the image on each menu update.I was just puzzled on why the text would appear correctly but not the images.

I was able to test around and recreate the situation. If I create the surface as an image, it displays whatever image was loaded, however if I 'add' an image afterwards, it doesn't. I'm able to have text appear and I can get graphic primitives to display(line,circle,fill,etc.), but images do not.

If it helps, my menu is basically a loop that 'refreshes' after a key is pressed.Let me know if you need anymore info.

No problem, hehe. Everything works differently now, which is jarring at first, but being in the process of upgrading Spectacles to take advantage of all the Sphere v2 stuff now, I would say the changes I made are for the better. I'm not really unhappy with any of them. Combined with ES6, Sphere v2 really feels like a fully modern development environment now unlike Sphere 1.x which was really showing its age.

@scojin: I can verify your report, and I'm almost certain this is a bug. I tried the following code:

The rectangle is rendered, but the image is not. Now I just have to figure out why. By the way, Image was renamed to Texture a few versions ago so you should probably upgrade your miniSphere installation if you want your code to keep running

edit: I found the bug. When drawing to the screen, texture coordinates (U/V) are normalized and go from [0-1] bottom-to-top. When drawing to a surface, however, they are in pixels and go from [0-w/h). So what's actually happening is that prim.blit() correctly assumes the normalized coordinates, and only the top-left pixel of the image gets drawn. I'm not sure what causes that yet, I'll have to study the Galileo code.

@scojin: I found the cause of the bug; it'll be fixed in miniSphere 4.5.5. Allegro tracks shaders per render target. When drawing Shapes to a surface, miniSphere was incorrectly applying the shader before switching the render target, meaning the shader got applied to the screen while the surface actually being drawn still used the Allegro default shader--which maps U/V to image pixels and thus causing prim.blit() to fail. Very simple to fix.