Re: [AD] OpenGL

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


On Tue, 2006-07-25 at 14:03 +0200, Evert Glebbeek wrote:
> >
> > The former probably would be rather messy, but once it compiles, would
> > mean we get all the features already in AllegroGL. The latter means,
> > we'd initially start with only a minimal implementation, and then would
> > need to add the required features again step by step (probably peeking
> > at the AllegroGL code).
> 
> What I would prefer in terms of the graphics drivers is to change the existing 
> vtables now and adapt the code to use the new drivers.
> The real problem I had with that (which I brought up before and was discussed, 
> without reaching some final consensus) is that right now, changing the 
> graphics drivers will break all other drivers on all other platforms. Now 
> maybe we should just Not Care and allow things to break and then fix them 
> later.

Yes, I think we have to do that.

> > What I expect in the end is, that I simply can do:
> >
> > display = al_create_display(640, 480, AL_AUTODETECT, AL_OPENGL);
> > glClearColor(0, 0, 1, 1);
> > glClear();
> > al_flip_display(display);
> 
> I would hide any refence to OpenGL and use a dummy `bitmap':

Yes, but I'm talking about the case where I do want to use the OpenGL
API :)

> display = al_create_display(..., AL_ACCELERATED, ...);
> bmp = al_get_buffer(display);
> al_clear_bitmap(bmp, 0,0,1,1); // or whatever colour format
> al_flip_display(display);
> 
> that way, code can be written with complete ignorance of the underlying driver 
> and work properly. Sure, one can still use the normal OpenGL commands (and we 
> must make sure that this does work), but the second example should work too.

Yes. So basically, we would have two sorts of drivers: Those without
OpenGL, who implement the Allegro graphics API in the same way as 4.2
drivers. And those who use OpenGL. This second group does not need to
implement anything else besides providing the OpenGL context, since
after that, a platform independent implementation of the Allegro
graphics API in OpenGL should be used.

> In case of OpenGL, the returned bitmap from al_get_buffer could just have a 
> flag set to say `use OpenGL commands instead of drawing to me', or better 
> yet, the drawing operations in the vtable could be directly mapped to OpenGL 
> commands:
> 
> al_clear_bitmap(bmp, ...) gets translated to
> bmp->vtable->clear(bmp, ...);
> which is a reference to
> al_opengl_clear_bmp(BITMAP *dummy, ...)
> {
>    glClearColor(...);
>    glClear();
> }

Yes, and the windows-GL, X11-GL, and OSX-GL all would share that
al_opengl_clear.

> > Each graphics driver would have a capability flag telling if it can
> > provide an OpenGL context or not. And graphics drivers would see in
> > their initialization function if OpenGL is requested, and initialize an
> > OpenGL context if so.
> 
> I think a generic AL_ACCELERATED flag would be better. Internally it would 
> work as you describe anyway.

But all the flag should do is allow me to use the OpenGL API. Even if it
is a Mesa driver, that is ok. I never should quite on the user because
they don't use an accelerated driver, but I have to quit on them if they
don't have a driver providing OpenGL, if my program uses OpenGL.

-- 
Elias Pschernig





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