Pages: 1 2 »
  Print  
Author Topic: sprite_add not working?  (Read 14802 times)
Offline (Unknown gender) RobotiX
Posted on: January 17, 2015, 10:18:52 pm

Member
Location: Pomona, CA
Joined: Jan 2015
Posts: 5

View Profile
Hey all,

I have lots of GM experience but only recently started with ENIGMA. I started a project from scratch in LGM, it's the newest ENIGMA portable, I have jdk 8, running Windows 7.
Basically I have:
Code: [Select]
image = sprite_add(file_name, 0, false, false, 0, 0)
show_message(string(image))
And then in the draw event:
Code: [Select]
draw_sprite(image, 0, x, y)I get the message and it shows the sprite index but when it tries to call the draw function the game crashes.
Any help would be appreciated.

RobotiX
Logged
Offline (Unknown gender) Darkstar2
Reply #1 Posted on: January 18, 2015, 01:45:43 am
Member
Joined: Jan 2014
Posts: 1238

View Profile Email
Even in GMS 1.4 latest this does not work, returns error "cannot display non existing sprite"

I  obvously replaced file name with an image file in the same directory as the compiled exe.

Interesting.
Logged
Offline (Unknown gender) RobotiX
Reply #2 Posted on: January 18, 2015, 02:21:57 am

Member
Location: Pomona, CA
Joined: Jan 2015
Posts: 5

View Profile
It works perfectly in GM 8.

EDIT:
Ok so I managed to get an error in the console, it said something along the lines as "incorrect PNG signature, it's no PNG or corrupted" So i thought maybe ENIGMA can only handle pngs. No problem, I just converted my image to a png. Still crashes, no error message this time. So I just ran gdb on it and got this:

Code: [Select]
Program received signal SIGFPE, Arithmetic exception.
0x004de1de in enigma::sprite_add_to_index (ns=0x6b391f8, filename=...,
    imgnumb=0, precise=false, transparent=false, smooth=false, x_offset=0,
    y_offset=0, mipmap=false) at Universal_System/spritestruct.cpp:285
285             unsigned cellwidth = width/imgnumb;

and the backtrace:

Code: [Select]
#0  0x004de1de in enigma::sprite_add_to_index (ns=0x6b391f8, filename=...,
    imgnumb=0, precise=false, transparent=false, smooth=false, x_offset=0,
    y_offset=0, mipmap=false) at Universal_System/spritestruct.cpp:285
#1  0x004dd066 in enigma_user::sprite_add (filename=..., imgnumb=0,
    precise=false, transparent=false, smooth=false, preload=true, x_offset=0,
    y_offset=0, mipmap=false) at Universal_System/spritestruct.cpp:68
#2  0x004dd1b6 in enigma_user::sprite_add (filename=..., imgnumb=0,
    transparent=false, smooth=false, x_offset=0, y_offset=0, mipmap=false)
    at Universal_System/spritestruct.cpp:74
#3  0x0040351b in enigma::OBJ_obj_0::myevent_create (this=0x6b38d78)
    at C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfu
nctionality.h:43
#4  0x004e61c1 in enigma::roomstruct::gotome (
    this=0x7ef3e0 <enigma::grd_rooms>, gamestart=true)
    at Universal_System/roomsystem.cpp:193
#5  0x004ea4e9 in enigma::game_start () at Universal_System/roomsystem.cpp:841
#6  0x004b2a0f in enigma::initialize_everything ()
    at Universal_System/loading.cpp:120
#7  0x00407a76 in WinMain@16 (hInstance=0x400000, hPrevInstance=0x0,
    lpCmdLine=0x1ed6386 "", iCmdShow=10)
    at Platforms/Win32/WINDOWSmain.cpp:255
#8  0x0076a48d in main ()

It looks like a problem with ENIGMA.

EDIT AGAIN:
Fixed it. looking at the error it says "Arithmetic exception." and "width/imgnumb" I put two and two together and guessed that it was a divide-by-zero error, I changed image_num to 1 instead of 0 and it didn't crash.
Thanks Obama.
« Last Edit: January 18, 2015, 05:28:46 am by RobotiX » Logged
Offline (Unknown gender) TheExDeus
Reply #3 Posted on: January 18, 2015, 03:07:33 pm

Developer
Joined: Apr 2008
Posts: 1860

View Profile
Yup, we need better error checking. Many parts of the code don't do any checks even in debug mode. We need to add a special error window and than add many more checks.

And we support png's, bmp's and most recently gif's. They are all identified by the extension of the file and default's to bmp.
Logged
Offline (Unknown gender) RobotiX
Reply #4 Posted on: January 18, 2015, 03:15:54 pm

Member
Location: Pomona, CA
Joined: Jan 2015
Posts: 5

View Profile
Yeah, anytime something is divided by user input it should first check to see if it's zero. But I understand you guys already have massive amounts of work to be done. Overall I am EXTREMELY impressed. I fixed that error and the game I ported from GM ran perfectly. Except for sound_fade...
Logged
Offline (Unknown gender) TheExDeus
Reply #5 Posted on: January 18, 2015, 04:46:42 pm

Developer
Joined: Apr 2008
Posts: 1860

View Profile
Our idea is not to test things like that in normal Run mode. They will only be checked in debug mode, and in a lot of cases it is (like all the drawing functions check if the resource exists only in debug mode, in regular or release mode it will not check that). So you will still have a million ways to crash even if we implement it all fully.

Sound fade might not be implemented fully. You can try DirectSound and see if it's there. In OpenAL I think we don't support any sound effects, as there is no easy way to add them in OpenAL.
Logged
Offline (Male) Goombert
Reply #6 Posted on: January 18, 2015, 06:21:12 pm

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2991

View Profile
Quote from: RobotiX
Thanks Obama.
lol, Howdy, I am Robert and I have done a lot of contributing here so I may be able to clarify some things for you.

Currently OpenAL attempts to implement both the basic sound functions and DirectSound functions, however we eventually plan to drop support for the sound_* functions unless you use the DirectSound system. audio_* functions are from GM: Studio which uses OpenAL and is better for both cross-platform development as well as positional audio, DirectSound is deprecated by Microsoft. The original sound_* functions from GM 8.1 and earlier were implemented with DirectSound and mp3 files were played using DirectMusic which is an interface for Windows Media Player (hence the old option to use an external media player). ENIGMA's DirectSound system does not implement DirectMusic yet so it only supports basic WAV formats. I am certain our OpenAL system supports OGG, WAV, and MP3 because we built it with those codecs.

I am sorry you encountered the bug ENIGMA certainly needs better error handling, and there is discussion about the interface design for it but that is mainly in the context of compile-time errors and not run-time errors. There have been some things I have been planning regarding ENIGMA's run-time exceptions and that is mainly to provide a stack trace with line numbers in the function show_debug_message like LateralGM's exception dialog. One place we have improved recently is that undefined variables can actually report scope in debug mode, which was a huge improvement.
« Last Edit: January 18, 2015, 06:33:07 pm by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) RobotiX
Reply #7 Posted on: January 19, 2015, 01:53:04 am

Member
Location: Pomona, CA
Joined: Jan 2015
Posts: 5

View Profile
Oh I know who you are and I am grateful.
I get a "Unknown function or script `sound_fade'" error regardless of which sound system I'm using.
I made a pretty hacky GML alternative that increments or decrements the volume and sets it using sound_volume(). sound_get_volume() also doesn't seem to work so I just use a variable to store the the current value and manipulate that.
Logged
Offline (Unknown gender) Darkstar2
Reply #8 Posted on: January 19, 2015, 11:23:05 am
Member
Joined: Jan 2014
Posts: 1238

View Profile Email
Since the topic was about sprite_add,

Robert, any idea why sprite_add no longer works ? It used to.

I also tried it, it crashes, it works only with GIF, but with PNG it crashes, and yes I am using proper settings, tried all possible combinations, different PNG, etc.

After months of not using ENIGMA, I started playing around with it and notice how far more unstable it has become, just after half a dozen save/updating I get memory access JVM errors in LGM and crashing/closing.......I have 16GB of RAM, 14GB free, and yes I use the 1000 max in settings.ini, and some functions that used to work fine now either don't work at all or fail/crash.
sprite_add one of them.

Logged
Offline (Male) Goombert
Reply #9 Posted on: January 19, 2015, 03:06:27 pm

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2991

View Profile
Quote from: Darkstar2
Robert, any idea why sprite_add no longer works ? It used to.
Does this answer your question?
Quote from: RobotiX
EDIT AGAIN:
Fixed it. looking at the error it says "Arithmetic exception." and "width/imgnumb" I put two and two together and guessed that it was a divide-by-zero error, I changed image_num to 1 instead of 0 and it didn't crash.
Thanks Obama.
It's not broke and it hasn't been broke since I broke it to fix it.

Quote from: RobotiX
I get a "Unknown function or script `sound_fade'" error regardless of which sound system I'm using.
It looks like we never actually even outlined the function. I can give you the basic steps to add it though.
First outline the function in the general header https://github.com/enigma-dev/enigma-dev/blob/master/ENIGMAsystem/SHELL/Audio_Systems/General/ASbasic.h#L62
it should be the same path in your local enigma-dev copy regardless of how you installed. By outlining it there it ensures the parameter and return types are the same for every system.
Then you just add the body of the function in https://github.com/enigma-dev/enigma-dev/blob/master/ENIGMAsystem/SHELL/Audio_Systems/DirectSound/DSbasic.cpp#L92
or https://github.com/enigma-dev/enigma-dev/blob/master/ENIGMAsystem/SHELL/Audio_Systems/OpenAL/ALbasic.cpp#L152
for OpenAL. That's really all you need to do and the function will be usable, you could also send us a pull request on GitHub and we may merge it so long as you write the code neatly to match the other functions in the files.

Quote from: GM8.1 Manual
sound_fade(index,value,time) Changes the volume for the indicated sound to the new value(0 = low, 1 = high) during the indicated time (in milliseconds). This can be used to fade out or fade in music.
« Last Edit: January 19, 2015, 03:11:36 pm by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) Darkstar2
Reply #10 Posted on: January 19, 2015, 09:51:59 pm
Member
Joined: Jan 2014
Posts: 1238

View Profile Email
lol perhaps you didn't read the part in my post where I said I tried all possibilities still did not load the PNG. By all possibilities means yes I tried the 1 instead of 0 also.

Quote
and yes I am using proper settings, tried all possible combinations, different PNG, etc.

Logged
Offline (Male) Goombert
Reply #11 Posted on: January 19, 2015, 09:54:52 pm

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2991

View Profile
Do you have the PNG? I'll test myself, Project Mario uses extensive BMP and PNG loading. Also the code that you are trying to load it with.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) Darkstar2
Reply #12 Posted on: January 19, 2015, 09:58:18 pm
Member
Joined: Jan 2014
Posts: 1238

View Profile Email
Do you have the PNG? I'll test myself, Project Mario uses extensive BMP and PNG loading. Also the code that you are trying to load it with.

Here :D and the code is the SAME code as the OP, I just used my file instead, tried it with 0 and with 1 same thing.
if I make this into a GIF, it worked fine.



Logged
Offline (Male) Goombert
Reply #13 Posted on: January 19, 2015, 11:10:25 pm

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2991

View Profile


I don't know, I plugged it into my last Project Mario build and it seems to work fine. I can't build an exe right now because I have the 64 built configured right now but I haven't updated the libraries. An executable would be helpful.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #14 Posted on: January 20, 2015, 04:45:48 am

Developer
Joined: Apr 2008
Posts: 1860

View Profile
I just tested loading and drawing in my ENIGMA (which is very up to date and only few commits behind) and it's working fine:


Code:
Code: (edl) [Select]
spr = sprite_add("C:\001.png",1,0,0,0,0);
draw_sprite(spr,-1,mouse_x,mouse_y);

edit: I tested both  GL1 and GL3. Can you maybe try GDB and post the bt?
« Last Edit: January 20, 2015, 04:48:10 am by TheExDeus » Logged
Pages: 1 2 »
  Print