Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Graphics API proposal (take 5)

This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
Graphics API proposal (take 5)
Bob
Free Market Evangelist
September 2000
avatar

Yes, I know it'll destroy all video bitmaps. But keeping memory copies and updating those pretty much halves the speed (or worse) of any operation on video bitmaps...

--
- Bob
[ -- All my signature links are 404 -- ]

Thomas Harte
Member #33
April 2000
avatar

Quote:

But keeping memory copies and updating those pretty much halves the speed (or worse) of any operation on video bitmaps...

True, but for most people operations on video bitmaps are sub-optimal anyway (compared to most other bitmap types), and the main purpose of them is to enable hardware accelerated (masked) blitting of static images. Perhaps you could offer backup and restore functions for video bitmaps which back them up to main memory and restore them to video space? The main argument for taking this into the API being that not all targets will require the calls to actually do anything, since as you say in Allegro 5 not all targets use the same memory pool for display buffers and video bitmaps.

Funklord
Member #467
June 2000
avatar

My personal opinion would go to have separate functions for all blitting types for optimum speed, but with a common interface.

void al_blit(AL_BITMAP* dest, AL_BITMAP* src, int x, int y);
void al_blit_section(AL_BITMAP* dest, AL_BITMAP* src, int x, int y, int sx, int sy, int sw, int sh);
void al_blit_scaled(AL_BITMAP* dest, AL_BITMAP* src, int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh);

void al_masked_blit(AL_BITMAP* dest, AL_BITMAP* src, int x, int y);
void al_masked_blit_section(AL_BITMAP* dest, AL_BITMAP* src, int x, int y, int sx, int sy, int sw, int sh);
void al_masked_blit_scaled(AL_BITMAP* dest, AL_BITMAP* src, int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh);

If many people are looking for a quick search&replace upgrade to allegro 5.0
then these could be renamed to nblit??
(new blit)

----------------------
[ Me payge | Me shoutcast (128k) | Me in aktOin! | Me OS | Me friends ]

Age is inversely proportional to how much drink you've had - Funklord

MindCode
Member #2,031
March 2002
avatar

This is looking really sweet so far. Gives me high hopes for Allegro 5. I agree with 'al_draw' rather than 'al_blit'. Makes more sense as it has a wider meaning.

I also like the state changes via a string. It would really make it easy for a user to edit settings during runtime via a console/scripting system.

Hey and that 'al_main' thing ;D. Anything that gets rid of 'END_OF_MAIN()' (ugh!).

Losing the 'screen' global is a great idea and multi windowing is definately an issue i had with allegro4.

The only problem I have is with the differentiation between structures and functions. Hungarian is obviously not an option, so I suggest that structures be written as:

struct AL_structure_name {
//...
};

Capitol 'AL_'.

Good work Bob!

______________________________________
Frag The Planet

Cage
Member #1,277
March 2001

I propose that rather than something like:
al_masked_blit()
You go more like:
alMaskedBlit()
It makes for cleaner-looking code.
I also suggest a
alMaskedBlit2x()
for extra fast 2x blitting (I dunno about other peeps but I love the 2x stretch blitting in Fblend almost as much at the translucency).
Whoops, that shows I've been coding too much: I just tried to end that last sentence with a semicolon.:P

-----
"I'm dumb!. it prolly wont do anything just like Sub7 when u extract it to ur own system I'm dumb!." - theforgotten
"heh i got hit by sub7 before. I just dont know how i got it. It took me about 2 yrs to figure out which virus i had. I'm dumb!. then i started wanting to hack and i got sub7 just ot play around with it and i found the features in it that i had been affected by when i got the virus." - theforgotten

Korval
Member #1,538
September 2001
avatar

Using alDraw is not a good idea compared to alBlit. Blit is an operation that anyone doing anything in 2D should know. If they don't know what a blit is, then they should educate themselves. By the same token, if someone is playing with 3D and they don't know what a matrix is used for, they need to educate themselves.

MindCode
Member #2,031
March 2002
avatar

I suggested that function typeing too Cage. Bob didn't go for it.:-[

I also agree with using 'alDraw' instead of 'alBlit'.

______________________________________
Frag The Planet

Richard Phipps
Member #1,632
November 2001
avatar

See my earlier message in this thread:

"hmm.. the problem with al_draw is that doesn't explicitly say that it's for blitting. What I mean is that you could have al_draw_line, al_draw_rectangle, al_draw_circle, and then al_draw.. may be confusing what al_draw actually does to newbies at first.

I agree blit is a bit of a technical word for newbies too. I suppose you could call it al_copy_block or al_draw_block, but that's getting a little long winded to type for a very common function name."

:)

Rich.

MindCode
Member #2,031
March 2002
avatar

I think any newbie would learn quite quickly from the documentation what 'al_draw' is for. And if they don't read the doc's, they should be slapped upside the head.

And I had another idea too. Allegro add-on paks should reform their api to conform with the new allegro api. So that paks like AllegroGL having the function name:

allegro_gl_blit();

Is quite long winded. It should follow a tighter syntax like the new allegro.

agl_blit();

Or as I was saying before:

agl_draw();

And this is all arbitrary since I think AllegroGL should be part of mainstream Allegro.

______________________________________
Frag The Planet

23yrold3yrold
Member #1,134
March 2001
avatar

For the love of all that's holy, call it al_blit >:( al_draw? wtf is that? Draw what? Besides, how long does it take to explain what "blit" means to a newbie, not to mention the fact that every other graphics API in existence has a blit function ::)

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Richard Phipps
Member #1,632
November 2001
avatar

Thank you very much 23yr3yrold! I am completely in agreement about this idea of using al_draw. It's an unneccessary step backwards to a less descriptive function name as well.

hmmm.. let's call load_bmp, al_load.. and while we are at it let's have al_scare and al_unscare too..

Do you get what I mean about al_draw being unclear compared to al_blit yet, when we would already have al_drawline and al_drawcircle?

Rich.

Cage
Member #1,277
March 2001

Actually, I'd like to retract my opinion that the new API should have functions like "myFunctionName" instead of "my_function_name". I tried coding with the former and it looks quite messy :P
Also, I STRONGLY believe (at least for now;D) that it should be al_blit, not al_draw. Listen to the pleas of the majority...

-----
"I'm dumb!. it prolly wont do anything just like Sub7 when u extract it to ur own system I'm dumb!." - theforgotten
"heh i got hit by sub7 before. I just dont know how i got it. It took me about 2 yrs to figure out which virus i had. I'm dumb!. then i started wanting to hack and i got sub7 just ot play around with it and i found the features in it that i had been affected by when i got the virus." - theforgotten

Peter Hull
Member #1,136
March 2001

I'm as dumb as toast and I still know what a blit is. It's a BIt Transfer with L in the middle :P
Whatever.
My point was that if we were to swap the source, destination order* and still call it blit that would cause no end of confusion. So, invent a new function name with new arguments. al_draw was the first one I could think of. That's all. Anyway I am puzzled by the argument that everyone can understand al_blit but al_draw will cause poor little allegro users to give up in confusion. "What are we drawing with this AL_BITMAP parameter?" they will weep into their keyboards. Hm.

Pete

  • one of the stated aims was to reduce inconsistency in the API. Having blit(src, dest, ...) and draw_sprite(dest, src, ...) is an inconsistency. It is. You know it is.:-/

Funklord
Member #467
June 2000
avatar

Just to make it clear, in C coding, there are unwritten laws that clearly state that Capital and small letters should never be mixed.

Only Microsoft code uses AlBlitDrawBitmap style.
and some insane programmers =)

I agree totally to the opinion that blit should not be changed to draw, which is less descriptive

Having flags passed to a blit function adds a huge load to a low level function, we need to have many different ones so you don't need to pass arguments unneccessarily.
I hate filling things with like "NULL, NULL, 0"

----------------------
[ Me payge | Me shoutcast (128k) | Me in aktOin! | Me OS | Me friends ]

Age is inversely proportional to how much drink you've had - Funklord

Bob
Free Market Evangelist
September 2000
avatar

Blit actually means BLock Transfer, with an 'i' in the middle :)

--
- Bob
[ -- All my signature links are 404 -- ]

MindCode
Member #2,031
March 2002
avatar

bIt BLock Transfer but the letters are all gobboly goo.

______________________________________
Frag The Planet

Richard Phipps
Member #1,632
November 2001
avatar

Funklord,

I think my code breaks the unwritten capital law!

I write my functions roughly like this:

AL_block_transfer_blit();

oops..

;) Insane programmer..

Rich.

spellcaster
Member #1,493
September 2001
avatar

I'd like to propose a new function for text printing:

al_textprintf(AL_BITMAP *dst, int x, int y, AL_FONT *font, int color, int align, char *format, ...);

Nothing new here but the align paramter. It could be AL_LEFT_ALIGN, AL_CENTER_ALIGN or AL_RIGHT_ALIGN. This way we can avoid having the xxx_center xxx_right versions of the text functions.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Richard Phipps
Member #1,632
November 2001
avatar

Great idea spellcaster!

:)

Why don't you have a look at the thread in this forum I made for a new masked_blit function and tell me what you think?

Danke,
Rich.

MindCode
Member #2,031
March 2002
avatar

I suppose if 'align' is non-zero then the 'x' parameter would be ignored.

______________________________________
Frag The Planet

spellcaster
Member #1,493
September 2001
avatar

Nah. The x parameter should be used the same way as in the current functions. It's either the left-most point, the center point or the right-most point.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Korval
Member #1,538
September 2001
avatar

Quote:

Just to make it clear, in C coding, there are unwritten laws that clearly state that Capital and small letters should never be mixed.

Only Microsoft code uses AlBlitDrawBitmap style.
and some insane programmers =)

We're programmers. Calling us "insane programmers" is just restating the obvious ;)

Bob
Free Market Evangelist
September 2000
avatar

spellcaster: Add to that separate foreground / background colors and you'd be set.

--
- Bob
[ -- All my signature links are 404 -- ]

spellcaster
Member #1,493
September 2001
avatar

Background colors?
What will they be used for?
While the textout with the solid bg is nice for debugging, it's not really needed for games...
And if someone really wants it, he can simply rectfill that area himself.

I see no reason to keep that solid bg textout in the new version. Unless it will fade the antialiased font to the background color, of course :)

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Bob
Free Market Evangelist
September 2000
avatar

Hmm, actually, that might be a good idea.

--
- Bob
[ -- All my signature links are 404 -- ]

 1   2   3   4 


Go to: