Development/Documentation/WrappingFunctions

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
What is 3 + 6

Wrapping Functions

XXX: Add some information about prologues/epilogues

Sometimes you want to override or hook into a certain function and have it do something else. For example, you might want to use an accelerated function for drawing triangles. This is done by replacing the function pointers in the data structures

/* Don't forget to save the original function */
pMyScreenData->CreatePixmap = pSCreen->CreatePixmap;

/* Replace the function */
pScreen->CreatePixmap = MyCreatePixmap;

Now the function MyCreatePixmap will be called instead of the regular CreatePixmap function. This is good if we're superstitious:

static PixmapPtr
MyCreatePixmap (ScreenPtr pScreen, int w, int h, int depth)
{
         MyScreenDataPtr pMyScreenData = GET''MY''SCREEN_DATA (pScreen);

         if (w == 13 && h == 13)
         {
                  /* Refuse to create pixmaps with size 13x13 */
                  return NULL;
         }

         /* Call the original function */
         return (* pMyScreenData->CreatePixmap) (pScreen, w, h, depth);
}

(See Development/Documentation/DevPrivates for information on where the MyScreenDataPtr comes from)

-- AndersCarlsson - 23 Sep 2003