Next Previous Contents

7. Overview of how to write a LibGGI display target

[This article is NOT a substitute for not looking at the existing display target code. This (unfinished) article does not explain every detail (yet).]

Actually, most of the work of displaying and servicing an application has been done for the display target writer. For example, there is reasonably optimized code for linear framebuffers of most bit-types, and stubs exist to do a few non-crucial operations such as ggiPutc() by calling ggiSetPixel() individually. "Convenient" functions such as ggi{Set/Check}{Text/Graph}Mode() simply call the "master" function, ggi{Set/Check}Mode(), with different arguments, and the display target writer only needs to supply "master" functions for these to work.

When the application requests a visual (by name), LibGGI looks it up in its configuration file, and loads and initializes the appropriate library. On initialization, the display target's GGIdlinit() is called. This function should do whatever set up is necessary to begin using the target, e.g. initializing Xlib in the display-X target. But do NOT set the mode here yet. GGIdlinit() should also indicate which functions it implements by setting the various fields of the operation structs (the main one being opdisplay). (It does not have to implement all of the possible functions; if it doesn't then stubs are used or the function fails.)

The return codes for these functions are the same as if they were called directly by LibGGI-using applications.

GGIsetmode() is used to set the mode. If it fails, GGIsetmode() should suggest a mode, although this change may not be propagated back to ggiSet{Text/Graph}Mode because they don't take a ggi_mode pointer. GGIsetmode() implementations usually use _GGIdomode(), which sets up "suggestions". This function is used to load any additional libraries used by the target, such as the linear framebuffer libraries, and stubs.

GGIgetmode() is used to check the mode. Usually the display target can simply grab the mode stored in the given ggi_visual.

GGIcheckmode() is used to check if the mode in question is valid. If not, the mode passed to it should be changed to the suggested mode.


Next Previous Contents