1. Allegro 5 Wrapper Error

Hello,

I am having a issue when trying to wrap Allegro 5. I have most of the library wrapped, but when I try to use it an example, I get this a machine-level exception occured during execution of this statement. Here's the code below

Wrapper code

 
include std/machine.e 
include std/dll.e 
 
atom allg 
 
allg = open_dll("allegro-5.0.9-monolith-mt-debug.dll") 
 
if allg = 0 then 
   puts(1,"Could not open DLL!\n") 
end if 
 
public constant xal_create_display = define_c_func(allg,"al_create_display",{C_INT,C_INT},C_POINTER) 
 
public function al_create_display(atom w,atom h) 
	 
	return c_func(xal_create_display,{w,h}) 
	 
end function 
 

Test Program

 
include std/machine.e 
include euall5.ew 
 
atom ret = al_install_system(ALLEGRO_VERSION_INT,0) 
 
atom dis = al_create_display(640,480) --error comes from this 
 

I can post more code if it is needed.

new topic     » topic index » view message » categorize

2. Re: Allegro 5 Wrapper Error

Lone_EverGreen_Ranger said...

Hello,

I am having a issue when trying to wrap Allegro 5. I have most of the library wrapped, but when I try to use it an example, I get this a machine-level exception occured during execution of this statement. Here's the code below

Wrapper code

 
include std/machine.e 
include std/dll.e 
 
atom allg 
 
allg = open_dll("allegro-5.0.9-monolith-mt-debug.dll") 
 
if allg = 0 then 
   puts(1,"Could not open DLL!\n") 
end if 
 
public constant xal_create_display = define_c_func(allg,"al_create_display",{C_INT,C_INT},C_POINTER) 
 
public function al_create_display(atom w,atom h) 
	 
	return c_func(xal_create_display,{w,h}) 
	 
end function 
 

Test Program

 
include std/machine.e 
include euall5.ew 
 
atom ret = al_install_system(ALLEGRO_VERSION_INT,0) 
 
atom dis = al_create_display(640,480) --error comes from this 
 

I can post more code if it is needed.

What's the wrapper code for al_install_system() look like? Also, how are you defining ALLEGRO_VERSION_INT?

I'm wondering if the reason for the machine exception is because al_install_system() is returning false, but then the code calls al_create_display() anyways.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Allegro 5 Wrapper Error

public constant ALLEGRO_RELEASE_NUMBER = 1 
 
public constant ALLEGRO_VERSION = 5, 
				ALLEGRO_SUB_VERSION = 0, 
				ALLEGRO_WIP_VERSION = 9 
				 
public constant ALLEGRO_VERSION_INT = ALLEGRO_VERSION and ALLEGRO_SUB_VERSION and ALLEGRO_WIP_VERSION and ALLEGRO_RELEASE_NUMBER 
 

I can provide more flags if neccessary.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Allegro 5 Wrapper Error

Lone_EverGreen_Ranger said...
public constant ALLEGRO_RELEASE_NUMBER = 1 
 
public constant ALLEGRO_VERSION = 5, 
				ALLEGRO_SUB_VERSION = 0, 
				ALLEGRO_WIP_VERSION = 9 
				 
public constant ALLEGRO_VERSION_INT = ALLEGRO_VERSION and ALLEGRO_SUB_VERSION and ALLEGRO_WIP_VERSION and ALLEGRO_RELEASE_NUMBER 
 

I can provide more flags if neccessary.

It looks like your definition of ALLEGRO_VERSION_INT is incorrect, going by http://upstream-tracker.org/diffs/allegro/5.0.4_to_5.0.5/diff.html

This is the accurate translation from C

constant ALLEGRO_VERSION_INT = or_bits(ALLEGRO_VERSION * power(2, 24), or_bits(ALLEGRO_SUB_VERSION * power(2, 16), or_bits(ALLEGRO_WIP_VERSION * power(2, 8), ALLEGRO_RELEASE_NUMBER))) 
new topic     » goto parent     » topic index » view message » categorize

5. Re: Allegro 5 Wrapper Error

jimcbrown said...
Lone_EverGreen_Ranger said...
public constant ALLEGRO_RELEASE_NUMBER = 1 
 
public constant ALLEGRO_VERSION = 5, 
				ALLEGRO_SUB_VERSION = 0, 
				ALLEGRO_WIP_VERSION = 9 
				 
public constant ALLEGRO_VERSION_INT = ALLEGRO_VERSION and ALLEGRO_SUB_VERSION and ALLEGRO_WIP_VERSION and ALLEGRO_RELEASE_NUMBER 
 

I can provide more flags if neccessary.

It looks like your definition of ALLEGRO_VERSION_INT is incorrect, going by http://upstream-tracker.org/diffs/allegro/5.0.4_to_5.0.5/diff.html

This is the accurate translation from C

constant ALLEGRO_VERSION_INT = or_bits(ALLEGRO_VERSION * power(2, 24), or_bits(ALLEGRO_SUB_VERSION * power(2, 16), or_bits(ALLEGRO_WIP_VERSION * power(2, 8), ALLEGRO_RELEASE_NUMBER))) 

Thanks, Jim. It ran without the error.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Allegro 5 Wrapper Error

Lone_EverGreen_Ranger said...

Hello,

I am having a issue when trying to wrap Allegro 5. I have most of the library wrapped, but when I try to use it an example, I get this a machine-level exception occured during execution of this statement. Here's the code below

Wrapper code

 
include std/machine.e 
include std/dll.e 
 
atom allg 
 
allg = open_dll("allegro-5.0.9-monolith-mt-debug.dll") 

That "mt" in the DLL is a red flag to me. That usually stands for multi-threaded, which can lead to problems, since euphoria is single threaded (actually, non-Windows versions use threads for tasks, but it works like it's single threaded).

Matt

new topic     » goto parent     » topic index » view message » categorize

7. Re: Allegro 5 Wrapper Error

mattlewis said...

That "mt" in the DLL is a red flag to me. That usually stands for multi-threaded, which can lead to problems, since euphoria is single threaded (actually, non-Windows versions use threads for tasks, but it works like it's single threaded).

Agreed. You'll need to use the monolithic non-threaded library, e.g. allegro-5.0.7-monolith-md.dll

Lone_EverGreen_Ranger said...

I am having a issue when trying to wrap Allegro 5. I have most of the library wrapped, but when I try to use it an example, I get this a machine-level exception occured during execution of this statement. Here's the code below

Hello Mr. Lone_EverGreen_Ranger, you should know that I have already started quite an effort on this front. It unfortunately has involved a custom "shim" DLL to wrap some functions in C for passing structures by value instead of by pointer (namely AL_COLOR values). So by all means, please continue my efforts if you'd like. I've laid out the library quite well and the code is all quite clean and simple. I made some good progress for a while but I've stalled out in the last few months. You can clone my Mercurial repository from here:

https://bitbucket.org/ghaberek/euallegro5

One thing that might be worth-while is upgrading all the DLL code to my euadvlib functions so I can eliminate all those nasty tests (t_allegro.e tests each function's ID manually). It would also allow better DLL debugging and for passing C strings back-and-forth.

-Greg

new topic     » goto parent     » topic index » view message » categorize

8. Re: Allegro 5 Wrapper Error

ghaberek said...
mattlewis said...

That "mt" in the DLL is a red flag to me. That usually stands for multi-threaded, which can lead to problems, since euphoria is single threaded (actually, non-Windows versions use threads for tasks, but it works like it's single threaded).

Agreed. You'll need to use the monolithic non-threaded library, e.g. allegro-5.0.7-monolith-md.dll

Lone_EverGreen_Ranger said...

I am having a issue when trying to wrap Allegro 5. I have most of the library wrapped, but when I try to use it an example, I get this a machine-level exception occured during execution of this statement. Here's the code below

Hello Mr. Lone_EverGreen_Ranger, you should know that I have already started quite an effort on this front. It unfortunately has involved a custom "shim" DLL to wrap some functions in C for passing structures by value instead of by pointer (namely AL_COLOR values). So by all means, please continue my efforts if you'd like. I've laid out the library quite well and the code is all quite clean and simple. I made some good progress for a while but I've stalled out in the last few months. You can clone my Mercurial repository from here:

https://bitbucket.org/ghaberek/euallegro5

One thing that might be worth-while is upgrading all the DLL code to my euadvlib functions so I can eliminate all those nasty tests (t_allegro.e tests each function's ID manually). It would also allow better DLL debugging and for passing C strings back-and-forth.

-Greg

That's great Greg, although I'm almost done with my wrapper. Though I could look at yours and see, and perhaps compare the two. I'll see how it goes.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu