nuclear@3: #include nuclear@2: #include nuclear@1: #include nuclear@2: #include nuclear@4: #include nuclear@0: #include nuclear@0: #ifndef __APPLE__ nuclear@0: #include nuclear@0: #else nuclear@0: #include nuclear@0: #endif nuclear@0: #include "imtk.h" nuclear@7: #include "state.h" nuclear@1: nuclear@0: nuclear@0: void imtk_begin(void) nuclear@0: { nuclear@7: int width, height; nuclear@7: nuclear@7: imtk_get_viewport(&width, &height); nuclear@7: nuclear@0: glMatrixMode(GL_PROJECTION); nuclear@0: glPushMatrix(); nuclear@0: glLoadIdentity(); nuclear@0: glTranslatef(-1, 1, 0); nuclear@7: glScalef(2.0 / width, -2.0 / height, 1.0); nuclear@2: nuclear@2: glMatrixMode(GL_MODELVIEW); nuclear@2: glPushMatrix(); nuclear@2: glLoadIdentity(); nuclear@2: nuclear@2: glPushAttrib(GL_ENABLE_BIT); nuclear@2: glDisable(GL_DEPTH_TEST); nuclear@2: glDisable(GL_CULL_FACE); nuclear@2: glDisable(GL_LIGHTING); nuclear@0: } nuclear@0: nuclear@0: void imtk_end(void) nuclear@0: { nuclear@2: glPopAttrib(); nuclear@2: nuclear@0: glMatrixMode(GL_PROJECTION); nuclear@0: glPopMatrix(); nuclear@2: glMatrixMode(GL_MODELVIEW); nuclear@2: glPopMatrix(); nuclear@0: } nuclear@0: nuclear@5: nuclear@5: void imtk_post_redisplay(void) nuclear@0: { nuclear@5: glutPostRedisplay(); nuclear@0: } nuclear@0: nuclear@1: nuclear@7: /*int imtk_listbox(int id, const char *list, int sel, int x, int y) nuclear@4: { nuclear@4: int i; nuclear@4: assert(id >= 0); nuclear@4: nuclear@4: if(!list) { nuclear@4: return -1; nuclear@4: } nuclear@4: nuclear@4: if(id & 1) { nuclear@4: id++; nuclear@4: } nuclear@4: nuclear@4: for(i=0; *list; i++) { nuclear@4: if(imtk_button(id + i * 2 + 1, list, x, y + i * 20)) { nuclear@4: sel = i; nuclear@4: } nuclear@4: list += strlen(list) + 1; nuclear@4: } nuclear@4: return sel; nuclear@4: } nuclear@4: nuclear@4: int imtk_combobox(int id, char *textbuf, size_t buf_sz, const char *list, int sel, int x, int y) nuclear@4: { nuclear@4: imtk_textbox(id + 1, textbuf, buf_sz, x, y); nuclear@4: imtk_button(id + 3, "V", x + TEXTBOX_SIZE, y); nuclear@4: nuclear@4: if(prev_active == id + 3) { nuclear@4: sel = imtk_listbox(id + 5, list, sel, x, y + 20); nuclear@4: } nuclear@4: return sel; nuclear@4: } nuclear@4: nuclear@4: char *imtk_create_list(const char *first, ...) nuclear@4: { nuclear@4: int sz; nuclear@4: char *buf, *item; nuclear@4: va_list ap; nuclear@4: nuclear@4: if(!first) { nuclear@4: return 0; nuclear@4: } nuclear@4: nuclear@4: sz = strlen(first) + 2; nuclear@4: if(!(buf = malloc(sz))) { nuclear@4: return 0; nuclear@4: } nuclear@4: memcpy(buf, first, sz - 2); nuclear@4: buf[sz - 1] = buf[sz - 2] = 0; nuclear@4: nuclear@4: va_start(ap, first); nuclear@4: while((item = va_arg(ap, char*))) { nuclear@4: int len = strlen(item); nuclear@4: char *tmp = realloc(buf, sz + len + 1); nuclear@4: if(!tmp) { nuclear@4: free(buf); nuclear@4: return 0; nuclear@4: } nuclear@4: buf = tmp; nuclear@4: nuclear@4: memcpy(buf + sz - 1, item, len); nuclear@4: sz += len + 1; nuclear@4: buf[sz - 1] = buf[sz - 2] = 0; nuclear@4: } nuclear@4: va_end(ap); nuclear@4: nuclear@4: return buf; nuclear@4: } nuclear@4: nuclear@4: void imtk_free_list(char *list) nuclear@4: { nuclear@4: free(list); nuclear@7: }*/