Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Memblocks and Tier 2

Author
Message
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Jun 2013 18:53
Is there any way to use the standard memory commands (memset, memcpy) to copy from a local buffer into the buffer of a Memblock?

Or, better yet, use a local buffer of appropriate size and formatting to initialise an image (basically the CreateImageFromMemblock command, but without call the command directly).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 6th Jun 2013 20:25
I've included two new commands in the next version for tier 2 only
and
that could be used to accomplish what you want.

The format of the image data in the first is simply an array of size width*height*4 with the byte order RGBA. Currently all images are 32 bit color depth.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Jun 2013 21:08
Excellent! Those are both very useful and either could be used to accomplish my ends.

I am working on a thing that dynamically creates an image with a beveled edge for the outer object and an inner bar that grows.

Mostly I have it working fairly well. But the program hangs on exit.

This sounds like a dynamic array access thing again.

But it also might be my process.

The process starts with creating a memory block and initialising to the desired image and base color. The an image is created from the block and then a sprite from the image. Good so far.

Now the repetitive part (called to update status):
1. Rebuild as much as necessary within the memory block
2. Recreate the image from the memory block using CreateImageFromMemblock passing in the image id returned from the original CreateImageFromMemblock call. The help says that this will overwrite the old image data (and it does appear to). And I discovered that this automagically updates the sprite's image and appearance.

Does that sound like it might cause an issue?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 6th Jun 2013 22:27
I would not expect that process to cause an issue. Like you say it does sound like an array overflow bug.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Jun 2013 22:42
I figured out what was causing the issue, but not why.

In the update function, if I commented out the 'agk::CreateImageFromMemblock(img_wait,memblk_id)' and rebuilt it, the hang went away completely.

I changed the code to create a new image with new id from the updated memory block. Then I used the SetSpriteImage command to reset the image for the displayed sprite. Next, delete the old image and store the new image id in that variable.

And the problem went away.

I was getting a program hang on everything except the Mac.

It was something in using CreateImageFromMemblock with an existing image that was causing the problem.

I wonder if the code behind it is using a funny offset when it recognizes that the image id is one that exists already.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 6th Jun 2013 23:58
A quick check of the image array indices didn't reveal anything but there is one area in the code that I suspect might be responsible, it involves threading so is difficult to test. It would be fixed with SetImageSavePixels(0) if it were the cause.
tornado
18
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 7th Jun 2013 00:16 Edited at: 7th Jun 2013 00:16
Quote: "void cImage::LoadFromData( int width, int height, unsigned char* data )"

Wish I could have it a couple of months earlier, great

3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 7th Jun 2013 00:48 Edited at: 7th Jun 2013 00:49
memblocks are use-full especially if you want to make a painting program, or uv editor.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 7th Jun 2013 01:11
Paul, I'll give it a test tomorrow and see if it works.

If it works, and doesn't slow down performance for the rest of the app, I'll use that and my original method with the reloading the same image.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-03 03:07:02
Your offset time is: 2024-05-03 03:07:02