Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro 4.9.8

This thread is locked; no one can reply to it. rss feed Print
Allegro 4.9.8
Thomas Fjellstrom
Member #476
June 2000
avatar

It wouldn't be out of place in an addon. We accept patches ;)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Don Freeman
Member #5,110
October 2004
avatar

Here is the al_draw_filled_rounded_rect function:

void al_draw_filled_rounded_rect( float x, float y, float w, float h, float r,
                                  ALLEGRO_COLOR c, int t )
{
  ///////////////////////////////////////////////////////////////////////////
  al_draw_filled_rectangle(x+r,y,(x+w)-r,(y+h),c);
  al_draw_filled_rectangle(x,y+r,(x+w),(y+h)-r,c);
  al_draw_filled_circle(x+r,y+r,r,c);                 // top left
  al_draw_filled_circle((x+w)-r,y+r,r,c);             // top right
  al_draw_filled_circle(x+r,(y+h)-r,r,c);             // bottom left
  al_draw_filled_circle((x+w)-r,(y+h)-r,r,c);         // bottom right
  ///////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////

Again, needs to be optimized like the unfilled version, but it works.8-)

Edit:
Is there no easy way to set the text color besides using the blender? If not, is this not slow????

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

Elias
Member #358
May 2000

Quote:

Is there no easy way to set the text color besides using the blender?

Just make a function like this:

void text_color(float r, float g, float b) {
    al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA,
        al_map_rgb_f(r, g, b));
}

And then in the rest of your code do this:

text_color(1, 0, 0);
al_font_textprintf(font, x, y, "This is red.");
text_color(0, 1, 0);
al_font_textprintf(font, x, y, "This is green.");

Might be worth adding such a function to the font addon actually - but I'm not sure.

Quote:

If not, is this not slow????

How so? I'd say it's a much faster method than the real-time pixel-by-pixel recoloring used in A4...

--
"Either help out or stop whining" - Evert

Don Freeman
Member #5,110
October 2004
avatar

You have to reset the blender though...I found that out after setting the font color that way, my images got 'colorized' as well.:-/

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

SiegeLord
Member #7,827
October 2006
avatar

Quote:

it works.

That is, until you happen to turn on blending :P. Well, no worries, I'll implement it later on.

Quote:

Whats the 3D api going to look like?

It already exists in an unimplemented state, so, basically like it looks like now :P

Or did you not notice that al_set_vbuff_pos takes x, y and z? ;)

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Don Freeman
Member #5,110
October 2004
avatar

Yeah...I noticed that with the filled version. I guess it is because of the overlap of the rectangles on the circles. I could probably fix it...but if you will implement it later on, I'll just wait.::) If you make a version, do you plan to keep the same layout and drawing style (The rounded rect will NOT exceed a normal rect)? That would be awesome if so, this way I could just switch my code later to use yours without having to modify that layout of all of my drawings and such.:D

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

SiegeLord
Member #7,827
October 2006
avatar

Quote:

If you make a version, do you plan to keep the same layout and drawing style (The rounded rect will NOT exceed a normal rect)?

I was thinking that if the bevel radius is 0, then the output is identical to al_draw_{filled_}rectangle, so I guess, yes I am planning on that.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Trent Gamblin
Member #261
April 2000
avatar

The titlebar thing is a bug, I swear it worked with 4.9.8 (haven't checked again) but even though there were no changes to the windows window handling code, you can't click on the client area to focus a window. I've looked at it a bit but haven't found the problem.

Don Freeman
Member #5,110
October 2004
avatar

I was thinking of using the al_calculate_arc and using a ALLEGRO_VBUFFER to draw the shape with al_draw_prim...maybe even be able to pass in a texture to it as well, since al_draw_prim allows a texture...but hey, whatever works for you.::)

Is there any built in anti-aliasing functions for the primitives? That would be awesome as well!:D

Trent: No, it is broken in the 4.9.8 version. That is what I am using right now. I can't get a dynamic version of 4.9.9 to compile for visual studio yet...

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

SiegeLord
Member #7,827
October 2006
avatar

Quote:

I was thinking of using the al_calculate_arc and using a ALLEGRO_VBUFFER to draw the shape with al_draw_prim...

That's probably how it'll be done.

Quote:

maybe even be able to pass in a texture to it as well, since al_draw_prim allows a texture...but hey, whatever works for you.::)

No high level primitive routines have texture support for one simple reason, there is no unique way to do it. Do you want a rotated/scaled texture or whatnot? For circles, do you want a radial texture mapping, or a rectangular one? Etc etc. I just figured that if you want textures, you go into the source, copy the implementation, and set the uv coordinates to your liking yourself.

Quote:

Is there any built in anti-aliasing functions for the primitives? That would be awesome as well!

There is multi-sampling support in A4.9.8 that supposedly antialiases the entire screen. So far it looked like crud to me, but that's probably because my card is bad.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Don Freeman
Member #5,110
October 2004
avatar

Do you know the name of it, or is it on by default? I do not see it in the docs.:-/

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

SiegeLord
Member #7,827
October 2006
avatar

The program that uses it is called ex_multisample. Maybe I am mistaken and it was added after 4.9.8...

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Trezker
Member #1,739
December 2001
avatar

I was thinking about looking into the place where mouse axes events are processed, it seems likely that's where something gets fucked up.

As for multiple displays, I'm not really thinking about that yet. I'm just using current display. With the API being as it is now, I think you can only support jumping within one display. Though I'm not sure. I'll have a look at it. I think people might want to be able to jump between displays, even if it's a stretch I'll bet in the future some guy will be wondering about it.

But for the time being, I think you could use the patch I attached back there. At least you can move the mouse at all, even if it's buggy and might not work on multiple displays.

Thomas Fjellstrom
Member #476
June 2000
avatar

At some point someone WILL make a game that can span monitors. Having the mouse move between displays is rather important, regardless of where the actual allegro Display is placed. Hopefully the underlying window manager will do most of the work.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Evert
Member #794
November 2000
avatar

Quote:

As for multiple displays, I'm not really thinking about that yet. I'm just using current display. With the API being as it is now, I think you can only support jumping within one display. Though I'm not sure. I'll have a look at it. I think people might want to be able to jump between displays, even if it's a stretch I'll bet in the future some guy will be wondering about it.

Actually, I think it makes sense if x and y in al_set_mouse_xy() refer to the current display. I don't think there's any other sane way for the function to behave, so supporting multiple displays shouldn't be hard at all if that function works correctly.
Or do I misunderstand what you mean by "As for multiple displays, I'm not really thinking about that yet. I'm just using current display."?

Trezker
Member #1,739
December 2001
avatar

Well, the x warp function takes a parameter of a type called window, but the docs don't link to this mysterious type and I don't feel like looking for it.
That's why I'm using the relative position warp, and that will not work with jumping between displays. Or maybe it can be done, but I would still need to figure out where to get some additional variables...

The code in allegro 4.2 that skips some events was really crazy. It made no sense to me. But I'm trying to skip some events after a warp now to see if I can make that work. So far it's not looking good...

On another note, I'd like to know how to skip building the examples when I build allegro.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

That's why I'm using the relative position warp, and that will not work with jumping between displays.

In windowed mode I don't think we can even try to say that windows pretend to be beside each other... any XWarp wouldn't move the cursor directly to the next window unless it was directly beside it.

That is, the only time moving the mouse should go from one display to another is if the displays are right next to each other. Anything else would be complicated to implement

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Trezker
Member #1,739
December 2001
avatar

I fixed it, the jerky thing and event skipping.

Now, it skips up to one motion event after warp.
I also added an if to avoid sending 0,0 delta events which also occur after a warp.

The multi display issue is still open. I only have one display sitting on my desk so I don't feel like taking care of that feature.

So, it's all smooth now. The attached diff is made against the same revision as the other one.

EDIT: Hmm, I got two attachments, I thought I deleted the first one...
Well the bigger one is the right one. It has the if that skips the 0,0 delta event.

count
Member #5,401
January 2005

Quote:

The titlebar thing is a bug, I swear it worked with 4.9.8 (haven't checked again) but even though there were no changes to the windows window handling code, you can't click on the client area to focus a window. I've looked at it a bit but haven't found the problem.

I currently use 4.9.8 and it doesn't work correctly here too.
When I start a allegro window I can only give it focus by clicking on the title.

Once I alt tabbed AWAY from the allegro window I can give focus by clicking inside the window. Regardless how it looses the focus. alt tabing away once fixes the problem for the lifespan of the window.

Maybe this helps to track down the bug.

Thomas Fjellstrom
Member #476
June 2000
avatar

I am confused as to how that can happen at all. The WM shouldn't be affected by Allegro doing anything.. Any window should get focus when you click on the title bar (not nesesarily the client area, that could be ignored). Though I suppose if our win32 event handling handles NC (non client) area clicks, and handles that case wrong, it might do it, but why the hell would we handle NC area events at all?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

count
Member #5,401
January 2005

Quote:

Any window should get focus when you click on the title bar

Did you misunderstand my post or did anyone else say that clikcing on the title doesn't work? ???

For me clikcing on the title always works.
But clicking inside the window only gives focus after I alt tabbed away from the allegro window.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

Did you misunderstand my post or did anyone else say that clikcing on the title doesn't work? ???

I'm not sure now. :( I thought someone did. No it seems I'm just not reading properly ::) nm.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Evert
Member #794
November 2000
avatar

Are these problems with Allegro windows showing up specifically in one version of Windows? Or does it show up in all of them?

Trent Gamblin
Member #261
April 2000
avatar

It must have something to do with the code that was added to detect mouse enter/leave events. I'll try to look at it today.

[edit]
It should be fixed in SVN now.

Elias
Member #358
May 2000

Quote:

I fixed it, the jerky thing and event skipping.

Now, it skips up to one motion event after warp.
I also added an if to avoid sending 0,0 delta events which also occur after a warp.

The multi display issue is still open. I only have one display sitting on my desk so I don't feel like taking care of that feature.

So, it's all smooth now. The attached diff is made against the same revision as the other one.

Can you try the attached patch? It adds a modified version of your patch as well as your example to current SVN. Just recompile then run ex_mouse_warp to test.

I removed all the mouse skipping stuff as it makes no difference here - I assume it will have to be added back. However, we should describe in more detail how exactly it behaves "weird" without the skipping, and maybe we can figure out which X11 versions show that behavior and only do the skipping for those.

--
"Either help out or stop whining" - Evert



Go to: