1 #include <GL/oscontext.h>
8 static int buffercnt
= 0;
11 ostgl_create_context(const int xsize
,
17 ostgl_context
*context
;
21 assert(depth
== 16); /* support for other depths must include bpp
23 assert(numbuffers
>= 1);
25 context
= gl_malloc(sizeof(ostgl_context
));
27 context
->zbs
= gl_malloc(sizeof(void*)*numbuffers
);
28 context
->framebuffers
= gl_malloc(sizeof(void*)*numbuffers
);
30 assert(context
->zbs
!= NULL
&& context
->framebuffers
!= NULL
);
32 for (i
= 0; i
< numbuffers
; i
++) {
33 context
->framebuffers
[i
] = framebuffers
[i
];
34 zb
= ZB_open(xsize
, ysize
, ZB_MODE_5R6G5B
, 0, NULL
, NULL
, framebuffers
[i
]);
36 fprintf(stderr
, "Error while initializing Z buffer\n");
41 if (++buffercnt
== 1) {
42 glInit(context
->zbs
[0]);
44 context
->xsize
= xsize
;
45 context
->ysize
= ysize
;
46 context
->numbuffers
= numbuffers
;
51 ostgl_delete_context(ostgl_context
*context
)
54 for (i
= 0; i
< context
->numbuffers
; i
++) {
55 ZB_close(context
->zbs
[i
]);
57 gl_free(context
->zbs
);
58 gl_free(context
->framebuffers
);
61 if (--buffercnt
== 0) {
67 ostgl_make_current(ostgl_context
*oscontext
, const int idx
)
69 GLContext
*context
= gl_get_context();
70 assert(idx
< oscontext
->numbuffers
);
71 context
->zb
= oscontext
->zbs
[idx
];
75 ostgl_resize(ostgl_context
*context
,
81 for (i
= 0; i
< context
->numbuffers
; i
++) {
82 ZB_resize(context
->zbs
[i
], framebuffers
[i
], xsize
, ysize
);