rev |
line source |
nuclear@3
|
1 #include <X11/Xlib.h>
|
nuclear@3
|
2 #include <GL/glx.h>
|
nuclear@3
|
3 #include "wsys.h"
|
nuclear@3
|
4
|
nuclear@3
|
5 struct window {
|
nuclear@3
|
6 Window win;
|
nuclear@3
|
7 GLXContext ctx;
|
nuclear@3
|
8 struct window *next;
|
nuclear@3
|
9 };
|
nuclear@3
|
10
|
nuclear@3
|
11 static int init(void);
|
nuclear@3
|
12 static void shutdown(void);
|
nuclear@3
|
13 static int set_vidmode(int xsz, int ysz, int bpp);
|
nuclear@3
|
14 static int get_vidmode(int *xsz, int *ysz, int *bpp);
|
nuclear@3
|
15 static int create_window(int xsz, int ysz, unsigned int flags);
|
nuclear@3
|
16 static void close_window(int id);
|
nuclear@3
|
17
|
nuclear@3
|
18 static struct wsys_module ws = {
|
nuclear@3
|
19 "x11-glx", 0,
|
nuclear@3
|
20 init,
|
nuclear@3
|
21 shutdown,
|
nuclear@3
|
22 set_vidmode,
|
nuclear@3
|
23 get_vidmode,
|
nuclear@3
|
24 create_window,
|
nuclear@3
|
25 close_window,
|
nuclear@3
|
26 0
|
nuclear@3
|
27 };
|
nuclear@3
|
28
|
nuclear@3
|
29 static Display *dpy;
|
nuclear@3
|
30 static int scr;
|
nuclear@3
|
31 static struct window *winlist;
|
nuclear@3
|
32
|
nuclear@3
|
33
|
nuclear@3
|
34 void sgl_register_x11(void)
|
nuclear@3
|
35 {
|
nuclear@3
|
36 sgl_register_module(&ws);
|
nuclear@3
|
37 }
|
nuclear@3
|
38
|
nuclear@3
|
39 static int init(void)
|
nuclear@3
|
40 {
|
nuclear@3
|
41 winlist = 0;
|
nuclear@3
|
42
|
nuclear@3
|
43 if(!(dpy = XOpenDisplay(0))) {
|
nuclear@3
|
44 return -1;
|
nuclear@3
|
45 }
|
nuclear@3
|
46 scr = DefaultScreen(dpy);
|
nuclear@3
|
47
|
nuclear@3
|
48 return 0;
|
nuclear@3
|
49 }
|
nuclear@3
|
50
|
nuclear@3
|
51 static void shutdown(void)
|
nuclear@3
|
52 {
|
nuclear@3
|
53 while(winlist) {
|
nuclear@3
|
54 struct window *win = winlist;
|
nuclear@3
|
55 winlist = winlist->next;
|
nuclear@3
|
56
|
nuclear@3
|
57 glXDestroyContext(dpy, win->ctx);
|
nuclear@3
|
58 XCloseWindow(dpy, win->win);
|
nuclear@3
|
59 free(win);
|
nuclear@3
|
60 }
|
nuclear@3
|
61 XCloseDisplay(dpy);
|
nuclear@3
|
62 dpy = 0;
|
nuclear@3
|
63 }
|
nuclear@3
|
64
|
nuclear@3
|
65 static int set_vidmode(int xsz, int ysz, int bpp)
|
nuclear@3
|
66 {
|
nuclear@3
|
67 /* TODO */
|
nuclear@3
|
68 }
|
nuclear@3
|
69
|
nuclear@3
|
70 static int get_vidmode(int *xsz, int *ysz, int *bpp)
|
nuclear@3
|
71 {
|
nuclear@3
|
72 /* TODO */
|
nuclear@3
|
73 }
|
nuclear@3
|
74
|
nuclear@3
|
75 static int create_window(int xsz, int ysz, unsigned int flags)
|
nuclear@3
|
76 {
|
nuclear@3
|
77 }
|
nuclear@3
|
78
|
nuclear@3
|
79 static void close_window(int id)
|
nuclear@3
|
80 {
|
nuclear@3
|
81 struct window dummy, *win, *prev;
|
nuclear@3
|
82 dummy.next = winlist;
|
nuclear@3
|
83
|
nuclear@3
|
84 prev = &dummy;
|
nuclear@3
|
85 win = prev->next;
|
nuclear@3
|
86
|
nuclear@3
|
87 while(win) {
|
nuclear@3
|
88 if(win->win == id) {
|
nuclear@3
|
89 glXDestroyContext(dpy, win->ctx);
|
nuclear@3
|
90 XCloseWindow(dpy, win->win);
|
nuclear@3
|
91 prev->next = win->next;
|
nuclear@3
|
92 free(win);
|
nuclear@3
|
93 return;
|
nuclear@3
|
94 }
|
nuclear@3
|
95 win = win->next;
|
nuclear@3
|
96 }
|
nuclear@3
|
97 }
|