ALLEGRO_REQUIRE vs ALLEGRO_SUGGEST
APrince

Hi, i have a strange problems with these lines:

al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_REQUIRE);
al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_REQUIRE); //What the hell?!?!
if (!(*display = al_create_display(display_width,display_height))){
std::cerr << "Failed to create display with multisampling!" << std::endl;
al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 0, ALLEGRO_SUGGEST);
al_set_new_display_option(ALLEGRO_SAMPLES, 0, ALLEGRO_SUGGEST);
if (!(*display = al_create_display(display_width,display_height))){
std::cerr << "Failed to create display even without multisampling!" << std::endl;
return false;
}
}

I have 2 computers, one of which is kinda old.

If I leave the code like this, display is created only on the new one at the first attempt. And on the old one it writes the one error and then created the display without multisampling. Problem is that multisampling doesn't work on the both machines. However if i change this line:

al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_REQUIRE);

to:

al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST);

than it gets created on both machines for the first time. Now the problem is, that it works only on the new machine. The old one doesn't draw any fonts or images from now on...

What i naturally want is for the multisampling to work on the machine that is capable of running it but be disabled, if the machine cannot cope with it.

What should I do?

Thanks a lot.

Edgar Reynaldo

Use <code>code goes here...</code> tags to post code on the forums. You can edit your post using a button on your post.

al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_REQUIRE);
al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_REQUIRE); //What the hell?!?!
if (!(*display = al_create_display(display_width,display_height))){
std::cerr << "Failed to create display with multisampling!" << std::endl; al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 0, ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_SAMPLES, 0, ALLEGRO_SUGGEST);
if (!(*display = al_create_display(display_width,display_height))){
std::cerr << "Failed to create display even without multisampling!" << std::endl; return false; } }

Both of the highlighted lines should be :

if (!(display = al_create_display(width,height))) {

Note that there is no * being used there. You're assigning an ALLEGRO_DISPLAY object the value of a pointer. That shouldn't even compile.

Which version of Allegro 5 are you using?

APrince said:

If I leave the code like this, display is created only on the new one at the first attempt. And on the old one it writes the one error and then created the display without multisampling. Problem is that multisampling doesn't work on the both machines. However if i change this line:

That's what you want - to create a display with multi sampling enabled if possible and disabled if not.

APrince said:

than it gets created on both machines for the first time. Now the problem is, that it works only on the new machine. The old one doesn't draw any fonts or images from now on...

What OS does the old computer have? If it works on one machine, it should work on the other unless you're doing something wrong. Post the smallest example program using a font and image that doesn't work on the old machine, and post it's specs (GPU).

Matthew Leverton

You should use SUGGEST for both parameters the first time. Then you don't need the second call to al_create_display() on failure.

APrince

Both of the highlighted lines should be :

Not really, because display is of the type ALLEGRO_DISPLAY**, so I'm not actually doing anything wrong here...

I'm using Allegro 5.0.1

Quote:

That's what you want - to create a display with multi sampling enabled if possible and disabled if not.

Yes, but as I said / that doesn't work on the old one. What it does is that it creates a display (al_create_display does not fail), but the one that cannot be drawn at. All the rendering attempts (except for drawing primitives) just do not draw anything at all... Images do not render as well as any text.

The operating system of the old machine is WinXP. To be more specific it is very well known IBM T42 notebook...

//edit:

You should use SUGGEST for both parameters the first time. Then you don't need the second call to al_create_display() on failure.

I would not have asked if that worked :-) It had been exactly as You suggest until I found out it did not work on the old machine...

Edgar Reynaldo

Why would you ever use an ALLEGRO_DISPLAY** to hold the display? There's no reason that you need it's address, and what do you do, allocate a new ALLEGRO_DISPLAY* and assign the double pointer it's address? All you need is an ALLEGRO_DISPLAY*, unless you're modifying the pointer in a separate function.

APrince said:

Yes, but as I said / that doesn't work on the old one. What it does is that it creates a display (al_create_display does not fail), but the one that cannot be drawn at. All the rendering attempts (except for drawing primitives) just do not draw anything at all... Images do not render as well as any text.

Yes, but that is a separate problem, because the display is being created successfully. You need to figure that out separately. Also, what GPU / Integrated graphics does your T42 use?

Again, if the display is created successfully, there is something else wrong.

amber

Why would you ever use an ALLEGRO_DISPLAY** to hold the display?

Maybe something like

void blah() {
   ALLEGRO_DISPLAY *display;
   setup_display(&display);
}

void setup_display(ALLEGRO_DISPLAY **display) {
   // do stuff
}

Edgar Reynaldo
Edgar said:

All you need is an ALLEGRO_DISPLAY*, unless you're modifying the pointer in a separate function.

I thought of that already, but I still don't see the point of passing pointer addresses into a separate function to initialize allegro. I can see the point of making a class that holds those values and initializes them, or maybe even a struct, but by themselves? I don't get it.

APrince

unless you're modifying the pointer in a separate function

...and that is exactly what I do. It looks like amber suggested. I have an init function that set's all the basic ALLEGRO stuff.

Anyway, what do you suggest me to do? Long story short: T42 (Mobility Radeon 7500) with these settings:

al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST);

creates a display, that cannot be drawn at. However, when I use these settings:

al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 0, ALLEGRO_SUGGEST);
al_set_new_display_option(ALLEGRO_SAMPLES, 0, ALLEGRO_SUGGEST);

it works fine, but theres (of course) no multisampling even on those machines that could do that.

Elias

Does ex_multisample work as expected?

Also which OS is this (sorry if I missed it)? If Windows, can you try using OpenGL instead of DirectX? (Just add al_set_new_display_flags(ALLEGRO_OPENGL);)

APrince

ex_multisample? I came across this when I was searching this forum for answers but didn't quite understand what it is for... I couldn't even google any satisfying answer. Can you please post some link?

Anyway, yes, it is Windows... I will try OpenGL (no sooner than yesterday unfortunatelly) if you think it can tell us anything.

Elias

It's one of the examples that come with allegro (http://static.allegro.cc/file/library/allegro/5.0.4/allegro-5.0.4-extra.zip) - it will open two windows and draw two lines in each, using multi-sampling in one window and not in the other.

APrince

Right, I'll try that and post the result...

//please do not lock this thread before saturday, I don't have the laptop with me so I won't be able to do the ex_multisample check till friday...

edit:
ex_multisample seems working... I tried to post a screenshot as an attachement, but somehow it still shows "failed". So what now?

Thread #608492. Printed from Allegro.cc