X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=tools%2Fdunger%2Fsrc%2Fmain.c;h=7c022c11862312b50648bdfa989cf01b1db5f06b;hb=c91209078ac6e61e8543f506b504bca92b7f1a74;hp=4c0fe7f9fe9a321623b3af4610df916ff027af74;hpb=4cd370bfc34a695d7ab9023b4c6e16b655bd9c92;p=vrlugburz diff --git a/tools/dunger/src/main.c b/tools/dunger/src/main.c index 4c0fe7f..7c022c1 100644 --- a/tools/dunger/src/main.c +++ b/tools/dunger/src/main.c @@ -3,6 +3,7 @@ #include #include #include +#include "level.h" static int init(void); static void cleanup(void); @@ -22,13 +23,18 @@ static void utext(int x, int y, const char *txt, int sz); static int utextspacing(void); static int utextwidth(const char *txt, int sz); -static int win_width, win_height; +int win_width, win_height; +int view_width, view_height; + static float uiscale = 1.0f; +#define UISPLIT 150 #define FONTSZ 16 static struct dtx_font *uifont; static utk_widget *uiroot; +static struct level *lvl; + int main(int argc, char **argv) { @@ -84,27 +90,72 @@ static int init(void) utk_set_text_spacing_func(utextspacing); utk_set_text_width_func(utextwidth); - win = utk_window(uiroot, 20, 20, 100, 100, "window"); - utk_show(win); + win = utk_vbox(uiroot, 0, UTK_DEF_SPACING); + utk_set_pos(win, 15, 15); + utk_button(win, "hello", 0, 0, 0, 0); + utk_button(win, "button 2", 0, 0, 0, 0); + utk_button(win, "button 3", 0, 0, 0, 0); + + if(!(lvl = create_level(32, 32))) { + fprintf(stderr, "failed to create level\n"); + return -1; + } return 0; } static void cleanup(void) { + free_level(lvl); dtx_close_font(uifont); utk_close(uiroot); } static void display(void) { + int splitx = UISPLIT * uiscale; + + view_width = win_width - splitx; + view_height = win_height; + glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + /* draw UI */ + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, splitx, win_height, 0, -1, 1); + glViewport(0, 0, splitx, win_height); + + glBegin(GL_QUADS); + glColor3f(0.25, 0.25, 0.25); + glVertex2f(0, 0); + glVertex2f(splitx, 0); + glVertex2f(splitx, win_height); + glVertex2f(0, win_height); + glEnd(); utk_draw(uiroot); + /* draw view */ + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, view_width, 0, view_height, -1, 1); + glViewport(splitx, 0, view_width, view_height); + + glBegin(GL_QUADS); + glColor3f(0.1, 0.1, 0.1); + glVertex2f(0, 0); + glVertex2f(view_width, 0); + glVertex2f(view_width, view_height); + glVertex2f(0, view_height); + glEnd(); + + draw_level(lvl); + glutSwapBuffers(); } @@ -113,11 +164,6 @@ static void reshape(int x, int y) win_width = x; win_height = y; - glViewport(0, 0, x, y); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, x, y, 0, -1, 1); - if(uiroot) { utk_set_size(uiroot, x / uiscale, y / uiscale); }