Re: [AD] "New example to test P3D scene rendering"

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Peter Wang wrote :
> 
> No offence, but it looks too much like `exzbuf.c' ;-)

IMHO, the major disavantage of David's demo is that it uses intersecting
polygons which are not handled by the P3D code. I thought this was
written in the docs but it seems it is not, I'm guilty :-P 

> 
> Also, I noticed you are allocating and deallocating memory before
> and after each frame.  I don't think that's a good idea.

Actually, the P3D code does not reallocate memory if  the "nedge" and
"npoly" values of scene_start() are not changed. However,
scene_start(NULL, 0, 0) should be called *after* KEY_ESC has been
pressed (i.e. at exit). The scene_start function allocates memory the
first time it is called, otherwise it only resets internal variables.
The loop should look like that :

while (!key[KEY_ESC]) /* or for (;;) */
{
   scene_start(buffer, 6*8, 8*8); /* allocates memory the first time,
resets internals otherwise */
   
   <Do everything you need to render the cube>
}
scene_start(NULL, 0, 0); /* deallocates the memory once the loop is
ended */
destroy_bitmap(...);

> 
> > And another thing, why "scene_end" it is in `scene3d.c' like
> > global function while in `allegro.h' neither he/she appears?

Because I first planned to change the API but I changed my mind because
I received mails from people who want to use those routines as soon as
they are released. So far, they keep using Allegro 3.12 since P3D is not
compatible with the last WIP. I did not want to make them change their
code. May be I was wrong ?

> 
> Bertand, is there a good reason for "scene_start(NULL, 0, 0)"?  It's
> really ugly.  I'd like to just move the memory deallocation part
> into `scene_end'.

At least, there is a good reason : it is the only way to deallocate
memory that scene_start() allocated. Anyway, I agree with you : the P3D
API is, in some way, ugly and not compliant with the "Allegro spirit". I
would have prefered to create some new functions like
- create_scene() to allocate memory
- clear_scene() to reset internal variables
- destroy_scene() (or scene_end) to deallocate memory
which are more friendly but I did not do it for the reasons I told
before :-( But since Allegro 4.0 beta is not yet released (nice April
fool BTW ;-) it's time to do it.

	Bertrand.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/