|
|
| Screen Update API: final draft |
|
23yrold3yrold
Member #1,134
March 2001
|
I guess it's worth the effort. Anything else? -- |
|
Rash
Member #2,374
May 2002
|
A couple of style issues: do { } while (poll_scroll()); Is this deliberately chosen instead of just a while statement? active_page = active_page == pages[0] ? pages[1] : pages[0]; buffer = active_page = active_page == pages[0] ? pages[1] : pages[0]; I would have put the RHS between parentheses. |
|
23yrold3yrold
Member #1,134
March 2001
|
That while (poll_scroll()); with just a terminator at the end always looks suspicious to me. -- |
|
Rash
Member #2,374
May 2002
|
Actually I was looking for the parentheses being put around the assigned expressions instead. |
|
23yrold3yrold
Member #1,134
March 2001
|
... Why? Also, I caught a bug; destroying all the bitmaps like that in shutdown_screen_updating() is a bad move because buffer and active_page could be pointing at the same bitmap. Calling destroy_bitmap() on both would be bad, yes? Fixed up. -- |
|
Rash
Member #2,374
May 2002
|
Quote: ... Why? The way I see it, you would want to draw attention to the fact that the statement is in fact an assignment. Quote: Also, I caught a bug; destroying all the bitmaps like that in shutdown_screen_updating() is a bad move because buffer and active_page could be pointing at the same bitmap. Calling destroy_bitmap() on both would be bad, yes? Just like calling delete or free twice on the same value. |
|
Marcello
Member #1,860
January 2002
|
If you are assuming the first update method is 0, I'd suggest for clarity, simply explicitly setting the first item in the enum: enum { NOUPDATEMETHOD = 0, TRIPLEBUFFER, PAGEFLIP, SYSTEMBUFFER, DOUBLEBUFFER, TRIPLEBUFFERWMB, PAGEFLIPWMB, LASTVALUE }; And personally I'd add underscores in those, cause they're kinda hard to read. Or in this case, since they're global constants, perhaps: enum { UPDATE_NONE = 0, UPDATE_DOUBLE_BUFFER, // Or take out _BUFFER? UPDATE_TRIPLE_BUFFER, UPDATE_PAGE_FLIP, UPDATE_SYSTEM_BUFFER, UPDATE_TRIPLE_WMB, // WMB is a bit odd... maybe MEM or MEMORY instead UPDATE_PAGEFLIP_WMB, UPDATE_MAX // this is just personal style for me when doing enums }; Marcello |
|
Kitty Cat
Member #2,815
October 2002
|
Quote: do { } while (poll_scroll()); Allegro tends to use do { } while (...); though I personalyl prefer doing while(...) ; Personal preference, though. Quote: active_page = active_page == pages[0] ? pages[1] : pages[0];
And I thought *ptr++ was bad. active_page = ((active_page == pages[0]) ? pages[1] : pages[0]); buffer = active_page = ((active_page == pages[0]) ? pages[1] : pages[0]); The ?: operators are generally quite anal when it comes to operator precedence, so I prefer to leave little room for errors (I would even put parenthesis around the two "return" values, though when it's just a single word like that I usually omit it). -- |
|
23yrold3yrold
Member #1,134
March 2001
|
I like Marcello's enum name suggestions. I'm gonna keep the WMB (With Memory Buffer) though. New update; you can now toggle vsync by pressing 2, and cycle through screen update methods by pressing 1 (that's a change to the example code, not the API). Calling the initialization function now let's you switch update methods with a single function call (it calls the shutdown function internally if there's already an update method in operation). Also streamlined main.cpp a bit and added more comments. I think it's bulletproof now ... EDIT: Oddly, Double Buffering is twice as fast as System Buffering for me. I thought the latter was supposed to be faster ... maybe I should omit it? -- |
|
Rash
Member #2,374
May 2002
|
I'm a bit skeptical about the idea of falling back to triple buffering in case an illegal value is supplied by the user. I guess it depends on whether you're "defensively" or "offensively" minded programming wise. How about implementing dirty rectangles too? |
|
X-G
Member #856
December 2000
|
Quote: EDIT: Oddly, Double Buffering is twice as fast as System Buffering for me. I thought the latter was supposed to be faster ... maybe I should omit it? Maybe, maybe not. I know that for me, page flipping nets worse results both in terms of tearing and flicker than double buffering does. (Disclaimer: I didn't write the programs referred to here. They might have used some dodgy methods.) -- |
|
23yrold3yrold
Member #1,134
March 2001
|
Quote: I'm a bit skeptical about the idea of falling back to triple buffering in case an illegal value is supplied by the user. I guess it depends on whether you're "defensively" or "offensively" minded programming wise.
The return value can be checked, if the programmer definitely wants to avoid triple buffering. Perhaps more wisely, let the user determine what's best for their system themselves (dirt easy now, isn't it? Quote: How about implementing dirty rectangles too?
Firstly, I don't want to bloat the API too much. Screen updating is fine, especially since a seperate DRS could probably be built seperately. Secondly, I have no need or use for a DRS, so a) I personally won't waste my time and b) I wouldn't know where to start anyway. Let's just worry about problems with the current setup. Does all look good? X-G: Yeah, but page flipping isn't as comparable to double buffering as system buffering is. -- |
|
Rash
Member #2,374
May 2002
|
One comment of yours fails the spell checker test. |
|
Marcello
Member #1,860
January 2002
|
omg "seperately" Marcello |
|
23yrold3yrold
Member #1,134
March 2001
|
Can't see it. -- |
|
Rash
Member #2,374
May 2002
|
"self-explanitory" |
|
23yrold3yrold
Member #1,134
March 2001
|
Huh. Thought it was spelt with an 'i'. Oh well. If that's my worst bug I'm happy. -- |
|
Rash
Member #2,374
May 2002
|
Well to be perfectly honest, I haven't bothered delving into the semantic aspect of the program as I'm not familiar with this aspect of Allegro. |
|
23yrold3yrold
Member #1,134
March 2001
|
Final call ... -- |
|
Richard Phipps
Member #1,632
November 2001
|
|
Steve Terry
Member #1,989
March 2002
|
One thing I noticed that could be added is documentation ... even though it's simple it's needed anyway for reference whenever you need to use a function, that way you don't have to go diggin through source code or header files to find something. Also in screen.h it is best to add:
This keeps it from being defined twice if it's included in multiple files in a project I utilized your screen update code into my little game, which works well since it has the *_WMB ability and I use fades, etc. That way I get ultra smooth motion with Triple buffering fullscreen and fast fades. However for some odd reason in windowed mode triple buffering is actually a bit choppy and not smooth, double buffering is excellent windowed and somewhat ok fullscreen, but at least you get to choose ___________________________________ |
|
Oscar Giner
Member #2,207
April 2002
|
Quote: However for some odd reason in windowed mode triple buffering is actually a bit choppy and not smooth tripple buffering in windowed mode doesn't exist. You're probably getting page flipping (it depends on 23 implementation). -- |
|
Steve Terry
Member #1,989
March 2002
|
Ooh just noticed that UPDATE_PAGEFLIP_WMB doesn't work like it should, somehow I'm getting a video bitmap to draw to, this makes it extremely slow at times. ___________________________________ |
|
23yrold3yrold
Member #1,134
March 2001
|
You can page flip in windowed mode? I haven't checked to see how the lib reacts to windowed modes. I should check that tomorrow. But like you said, at least you get to choose. Quote: One thing I noticed that could be added is documentation ...
Well, yeah. But right now it's pretty easy to read from the code. I'll make docs once it's done, fully and completely. Quote: Ooh just noticed that UPDATE_PAGEFLIP_WMB doesn't work like it should, somehow I'm getting a video bitmap to draw to, this makes it extremely slow at times. Huh? That shouldn't be ... from the code that's impossible. is_video_bitmap() == true?! -- |
|
Steve Terry
Member #1,989
March 2002
|
if(is_video_bitmap(get_buffer())){ allegro_message("OMG VIDEO BITMAP!!!!!DIEKTHXBYE"); exit(1); }
You can guess what pops up on the screen ___________________________________ |
|
|
|