Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with clearing screen #7

Open
joelcnz opened this issue Jun 15, 2017 · 8 comments
Open

Error with clearing screen #7

joelcnz opened this issue Jun 15, 2017 · 8 comments

Comments

@joelcnz
Copy link

joelcnz commented Jun 15, 2017

import derelict.allegro5;

import std.stdio: writeln;

ALLEGRO_DISPLAY* DISPLAY;

int main() {
    DerelictAllegro5.load();

	DerelictAllegro5.run( {
		if (! al_init()) {
			writeln("failed to initialize allegro!");
			return -1;
		}

		DISPLAY = al_create_display( 640, 480 );
		assert(DISPLAY, "failed to create display");
		scope(exit) al_destroy_display( DISPLAY );

		al_clear_to_color(al_map_rgb(255,180,0)); //#error return value -11
		al_flip_display();

		al_rest(2);

		return 0;
	} );

	return 0;
}
@mdparker
Copy link
Member

Joel, if you have bugs with DerelictAllegro5, this is definitely the place to post them. But this is not an Allegro support forum. I don't use Allegro that much myself and for me to help you would require me to dig into the Allegro docs and debug your programs for you. I don't have time for that. Please take issues like this to the Allegro forums at allegro.cc if you can't solve them yourself. If you later determine a problem is with the binding, then by all means report it here.

@mdparker mdparker reopened this Jun 16, 2017
@mdparker
Copy link
Member

Alright, I need you to clarify something. When you said "error return value", it sounded like you were talking about the return value of a function. But are you actually talking about a message you're getting from the system?

@joelcnz
Copy link
Author

joelcnz commented Jun 16, 2017

Yes, it displays "Program exited with code -11" in the terminal, when I run the program.

@joelcnz
Copy link
Author

joelcnz commented Jun 16, 2017

Also, I posted it on allegro.cc and some one said that the code worked on DAllegro, using Linux.

@mdparker
Copy link
Member

I've tested your code on my MacBook and it crashes for me, too. Running in the debugger shows a segmentation fault. Looks like it's a thread-related issue. Marking DISPLAY as __gshared or moving the declaration inside the function literal makes the crash go away.

I recommend using __gshared on any of your globals for now, just as a temporary workaround until I can figure out how to solve this.

@joelcnz
Copy link
Author

joelcnz commented Jun 16, 2017

It doesn't crash with __gshared, but it doesn't give me the colour either.

Also, if I use a bitmap with it it crashes again:

		ALLEGRO_BITMAP* bmp = al_create_bitmap(640,480);
		assert(bmp, "create bitmap failed!");
		scope(exit) al_destroy_bitmap( bmp );
		al_set_target_bitmap(bmp);
		al_clear_to_color(al_map_rgb(255,180,0));

How did you run the program in a debugger? Some one said about using a debugger before your post.

@mdparker
Copy link
Member

When you install XCode, you get the clang tools, which includes the lldb debugger. Run lldb <program_name> to debug. You'll want to compile your D programs with -gc (though -g might work as well with lldb, these days, don't know), so add that to a dflags field in your dub configuration.

I've had nothing but trouble trying to bind dynamically with Allegro. These Mac issues are just more in a long line of them. I may end up abandoning this completely and just directing people to DAllegro. Never had issues with like this with any other C library I've created a Derelict binding for.

@joelcnz
Copy link
Author

joelcnz commented Jun 16, 2017

Thanks for your replies. I'll look at DAllegro next, (I have an old version on a Windows computer to update. It didn't have dub back then).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants