aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/targets/osmesa/test-render.c
blob: 62118607713c31b804f1adbc63d09b7cf99a5069 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <stdlib.h>
#include "GL/osmesa.h"

static void
render(void)
{
   glClearColor(0, 1, 0, 0);
   glClear(GL_COLOR_BUFFER_BIT);
}

int
main(int argc, char **argv)
{
   OSMesaContext ctx;
   uint32_t pixel;
   uint32_t green = 0xff << 8;
   int w = 1, h = 1;

   ctx = OSMesaCreateContext(GL_RGBA, NULL);
   if (!ctx) {
      fprintf(stderr, "Context create failed\n");
      return 1;
   }

   if (!OSMesaMakeCurrent(ctx, &pixel, GL_UNSIGNED_BYTE, w, h )) {
      fprintf(stderr, "MakeCurrent failed\n");
      return 1;
   }

   render();
   glFinish();

   if (pixel != green) {
      fprintf(stderr, "Expected: 0x%08x\n", green);
      fprintf(stderr, "Probed: 0x%08x\n", pixel);
      return 1;
   }

   OSMesaDestroyContext(ctx);

   return 0;
}