sgl
diff src/wsys.c @ 7:edbfc96fe80d
glut wsys thingy and stuff...
author | John Tsiombikas <nuclear@siggraph.org> |
---|---|
date | Sat, 14 May 2011 08:26:10 +0300 |
parents | 1b6c5dadb460 |
children | 124195562f7e |
line diff
1.1 --- a/src/wsys.c Fri May 13 09:44:21 2011 +0300 1.2 +++ b/src/wsys.c Sat May 14 08:26:10 2011 +0300 1.3 @@ -1,11 +1,13 @@ 1.4 #include <stdio.h> 1.5 +#include <stdlib.h> 1.6 +#include <string.h> 1.7 #include "wsys.h" 1.8 1.9 static struct wsys_module *merge(struct wsys_module *list1, struct wsys_module *list2); 1.10 static struct wsys_module *msort(struct wsys_module *list, int count); 1.11 1.12 1.13 -struct wsys_module *wslist; 1.14 +struct wsys_module *wslist, *sel; 1.15 int wscount; 1.16 1.17 int sgl_register_module(struct wsys_module *ws) 1.18 @@ -21,9 +23,38 @@ 1.19 wslist = msort(wslist, wscount); 1.20 } 1.21 1.22 +void sgl_print_modules(void) 1.23 +{ 1.24 + struct wsys_module *ws = wslist; 1.25 + 1.26 + printf("window system modules:\n"); 1.27 + while(ws) { 1.28 + printf("- %s\n", ws->name); 1.29 + ws = ws->next; 1.30 + } 1.31 +} 1.32 + 1.33 struct wsys_module *sgl_wsys_module(void) 1.34 { 1.35 - return wslist; 1.36 + if(!sel) { 1.37 + char *modname; 1.38 + if((modname = getenv("SGL_MODULE"))) { 1.39 + struct wsys_module *ws = wslist; 1.40 + while(ws) { 1.41 + if(strcmp(ws->name, modname) == 0) { 1.42 + sel = ws; 1.43 + break; 1.44 + } 1.45 + ws = ws->next; 1.46 + } 1.47 + if(!sel) { 1.48 + sel = wslist; 1.49 + } 1.50 + } else { 1.51 + sel = wslist; 1.52 + } 1.53 + } 1.54 + return sel; 1.55 } 1.56 1.57 #define APPEND(node) \