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;
22 inst = RrSurfaceInstance(sur);
24 /* can't paint a prototype! */
29 assert(x >= 0 && y >= 0);
30 if (!(x >= 0 && y >= 0)) return;
31 assert(x + w <= RrSurfaceWidth(sur) && y + h <= RrSurfaceHeight(sur));
32 if (!(x + w <= RrSurfaceWidth(sur) && y + h <= RrSurfaceHeight(sur)))
35 /* XXX recurse and paint children */
37 if (!RrSurfaceVisible(sur)) return;
39 RrDebug("making %p, %p, %p current\n",
40 RrDisplay(inst), RrSurfaceWindow(sur), RrContext(inst));
42 ok = glXMakeCurrent(RrDisplay(inst), RrSurfaceWindow(sur),RrContext(inst));
45 glMatrixMode(GL_MODELVIEW);
47 glMatrixMode(GL_PROJECTION);
50 glOrtho(0, RrScreenWidth(inst), RrScreenHeight(inst), 0, 0, 10);
51 glViewport(0, 0, RrScreenWidth(inst), RrScreenHeight(inst));
52 glMatrixMode(GL_MODELVIEW);
53 glTranslatef(-RrSurfaceX(sur),
54 RrScreenHeight(inst)-RrSurfaceHeight(sur)-RrSurfaceY(sur), 0);
55 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
60 surx += RrSurfaceX(p);
61 sury += RrSurfaceY(p);
65 switch (RrSurfaceType(sur)) {
66 case RR_SURFACE_PLANAR:
67 RrPlanarPaint(sur, surx + x, sury + y, w, h);
69 case RR_SURFACE_NONPLANAR:
76 glXSwapBuffers(RrDisplay(inst), RrSurfaceWindow(sur));