warn = -pedantic -Wall -g
def = -DMINIGLUT_USE_LIBC
-incpath = -Isrc -Ilibs/cgmath -Ilibs/glew -Ilibs/treestore/src \
+incpath = -Isrc -Isrc/imtk -Ilibs/cgmath -Ilibs/glew -Ilibs/treestore/src \
-Ilibs/imago2/src -Ilibs/drawtext/src
libpath = -Llibs/glew -Llibs/treestore -Llibs/imago2 -Llibs/drawtext
struct dtx_font *fnt_ui;
int fnt_ui_size;
+int dbgui;
+
static int reshape_pending;
static unsigned int sdr_gamma;
dt = time_msec - prev_upd;
if(dt >= 750) {
- fps = (frames * 1000 << 8 + 128) / dt;
+ fps = ((frames * 1000 << 8) + 128) / dt;
frames = 0;
prev_upd = time_msec;
}
void demo_keyboard(int key, int st)
{
- if(st && key == 27) {
- demo_quit();
- return;
+ if(st) {
+ switch(key) {
+ case 27:
+ demo_quit();
+ return;
+
+ case '`':
+ dbgui ^= 1;
+ break;
+ }
}
if(cur_part && cur_part->keyboard) {
extern struct dtx_font *fnt_ui;
extern int fnt_ui_size;
+extern int dbgui;
+
int demo_init(void);
void demo_cleanup(void);
#include <assert.h>
#include "draw.h"
#include "imtk.h"
+#include "drawtext.h"
+#include "demo.h"
#define COLOR_MASK 0xff
void imtk_draw_string(int x, int y, const char *str)
{
- /*
- glRasterPos2i(x, y);
- while(*str) {
- glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *str++);
- }
- */
+ dtx_use_font(fnt_ui, fnt_ui_size);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glTranslatef(x, y + dtx_line_height() * 0.2, 0);
+ glScalef(1, -1, 1);
+
+ glColor4fv(colors[IMTK_TEXT_COLOR]);
+ dtx_string(str);
+
+ glPopMatrix();
}
int imtk_string_size(const char *str)
{
- return 0;
+ dtx_use_font(fnt_ui, fnt_ui_size);
+ return dtx_string_width(str);
}
void imtk_layout_newline(void);
void imtk_layout_get_pos(int *x, int *y);
void imtk_layout_get_bounds(int *bbox);
+int imtk_layout_contains(int x, int y);
/* defined in draw.c */
void imtk_set_color(unsigned int col, float r, float g, float b, float a);
{
memcpy(bbox, st[top].box, sizeof st[top].box);
}
+
+int imtk_layout_contains(int x, int y)
+{
+ if(x < st[top].box[0] || x >= st[top].box[0] + st[top].box[2]) {
+ return 0;
+ }
+ if(y < st[top].box[1] || y >= st[top].box[1] + st[top].box[3]) {
+ return 0;
+ }
+ return 1;
+}
glutKeyboardUpFunc(keyup);
glutMouseFunc(mouse);
glutMotionFunc(demo_mmotion);
+ glutPassiveMotionFunc(demo_mmotion);
glutSpaceballMotionFunc(demo_sball_motion);
glutSpaceballRotateFunc(demo_sball_rotate);
glutSpaceballButtonFunc(demo_sball_button);
#include "sdr.h"
#include "texture.h"
#include "post.h"
+#include "imtk.h"
static int init(void);
static void destroy(void);
static void draw(long tm)
{
+ static float vgn_offset = 0.47;
+ static float vgn_sharp = 3.1;
+
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_MODELVIEW);
glVertex2f(-1, 1);
glEnd();
- vignette(0.43, 0.38, 0.45, 0.8, 1.0);
+ vignette(0.43, 0.38, 0.45, vgn_offset, vgn_sharp);
if(dbgtex && dbg_alpha > 0.0) {
glUseProgram(0);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
}
+
+ if(dbgui) {
+ glUseProgram(0);
+
+ imtk_begin();
+ imtk_layout_start(10, 20);
+ imtk_layout_spacing(10);
+
+ imtk_layout_dir(IMTK_HORIZONTAL);
+
+ imtk_label("offset:", IMTK_AUTO, IMTK_AUTO);
+ vgn_offset = imtk_slider(IMUID, vgn_offset, 0.0, 1.5, IMTK_AUTO, IMTK_AUTO);
+ imtk_layout_newline();
+
+ imtk_label("sharpness:", IMTK_AUTO, IMTK_AUTO);
+ vgn_sharp = imtk_slider(IMUID, vgn_sharp, 0, 10, IMTK_AUTO, IMTK_AUTO);
+ imtk_layout_newline();
+ imtk_end();
+ }
}
static void mbutton(int bn, int st, int x, int y)
mouse_y = y;
switch(bn) {
+ case 0:
+ if(imtk_layout_contains(x, y)) {
+ imtk_inp_mouse(bn, st);
+ }
+ break;
case 3:
dbg_alpha += 0.1;
if(dbg_alpha > 1.0) dbg_alpha = 1.0;
if(!(dx | dy)) return;
+ if(imtk_layout_contains(x, y)) {
+ imtk_inp_motion(x, y);
+ return;
+ }
+
if(bnstate[0]) {
cam_theta += dx * 0.5;
cam_phi += dy * 0.5;