meson: gtest needs pthreads
[mesa.git] / src / gallium / targets / osmesa / test-render.c
1 #include <stdint.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "GL/osmesa.h"
5
6 static void
7 render(void)
8 {
9 glClearColor(0, 1, 0, 0);
10 glClear(GL_COLOR_BUFFER_BIT);
11 }
12
13 int
14 main(int argc, char **argv)
15 {
16 OSMesaContext ctx;
17 uint32_t pixel;
18 uint32_t green = 0xff << 8;
19 int w = 1, h = 1;
20
21 ctx = OSMesaCreateContext(GL_RGBA, NULL);
22 if (!ctx) {
23 fprintf(stderr, "Context create failed\n");
24 return 1;
25 }
26
27 if (!OSMesaMakeCurrent(ctx, &pixel, GL_UNSIGNED_BYTE, w, h )) {
28 fprintf(stderr, "MakeCurrent failed\n");
29 return 1;
30 }
31
32 render();
33 glFinish();
34
35 if (pixel != green) {
36 fprintf(stderr, "Expected: 0x%08x\n", green);
37 fprintf(stderr, "Probed: 0x%08x\n", pixel);
38 return 1;
39 }
40
41 OSMesaDestroyContext(ctx);
42
43 return 0;
44 }