8 /*! Paints the surface, and all its children */
9 void RrPaint(struct RrSurface *sur)
11 RrPaintArea(sur, 0, 0, RrSurfaceWidth(sur), RrSurfaceHeight(sur));
14 /*! Paints the surface, and all its children, but only in the given area. */
15 void RrPaintArea(struct RrSurface *sur, int x, int y, int w, int h)
17 struct RrInstance *inst;
20 inst = RrSurfaceInstance(sur);
22 /* can't paint a prototype! */
26 assert(x >= 0 && y >= 0);
27 if (!(x >= 0 && y >= 0)) return;
28 assert(x + w <= RrSurfaceWidth(sur) && y + h <= RrSurfaceHeight(sur));
29 if (!(x + w <= RrSurfaceWidth(sur) && y + h <= RrSurfaceHeight(sur)))
32 RrDebug("making %p, %p, %p current\n",
33 RrDisplay(inst), RrSurfaceWindow(sur), RrContext(inst));
35 ok = glXMakeCurrent(RrDisplay(inst), RrSurfaceWindow(sur),RrContext(inst));
38 glMatrixMode(GL_MODELVIEW);
40 glMatrixMode(GL_PROJECTION);
43 glOrtho(0, RrScreenWidth(inst), RrScreenHeight(inst), 0, 0, 10);
44 glViewport(0, 0, RrScreenWidth(inst), RrScreenHeight(inst));
45 glMatrixMode(GL_MODELVIEW);
46 glTranslatef(-RrSurfaceX(sur),
47 RrScreenHeight(inst)-RrSurfaceHeight(sur)-RrSurfaceY(sur), 0);
48 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
50 switch (RrSurfaceType(sur)) {
51 case RR_SURFACE_PLANAR:
52 RrPlanarPaint(sur, x, y, w, h);
54 case RR_SURFACE_NONPLANAR:
59 glXSwapBuffers(RrDisplay(inst), RrSurfaceWindow(sur));