projects
/
demo_prior
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- moved fbtex to post.c, made it a ping-pong buffer, added fbos for it.
[demo_prior]
/
src
/
part_whitted.c
diff --git
a/src/part_whitted.c
b/src/part_whitted.c
index
d71585c
..
658b2ff
100644
(file)
--- a/
src/part_whitted.c
+++ b/
src/part_whitted.c
@@
-2,6
+2,8
@@
#include "demo.h"
#include "part.h"
#include "sdr.h"
#include "demo.h"
#include "part.h"
#include "sdr.h"
+#include "texture.h"
+#include "post.h"
static int init(void);
static void destroy(void);
static int init(void);
static void destroy(void);
@@
-23,7
+25,7
@@
static struct demo_part part = {
mbutton, mmotion
};
mbutton, mmotion
};
-static float cam_theta, cam_phi, cam_dist = 8;
+static float cam_theta, cam_phi, cam_dist = 6;
static int bnstate[8];
static int mouse_x, mouse_y;
static int bnstate[8];
static int mouse_x, mouse_y;
@@
-31,6
+33,9
@@
static int mouse_x, mouse_y;
static unsigned int sdr;
static int uloc_aspect;
static unsigned int sdr;
static int uloc_aspect;
+static struct texture *dbgtex;
+static float dbg_alpha;
+
void reg_whitted(void)
{
void reg_whitted(void)
{
@@
-44,11
+49,15
@@
static int init(void)
return -1;
}
uloc_aspect = get_uniform_loc(sdr, "aspect");
return -1;
}
uloc_aspect = get_uniform_loc(sdr, "aspect");
+
+ dbgtex = load_texture("data/dbg_whitted.jpg");
+
return 0;
}
static void destroy(void)
{
return 0;
}
static void destroy(void)
{
+ free_texture(dbgtex);
}
static void start(void)
}
static void start(void)
@@
-85,6
+94,11
@@
static void draw(long tm)
glTexCoord2f(0, 1);
glVertex2f(-1, 1);
glEnd();
glTexCoord2f(0, 1);
glVertex2f(-1, 1);
glEnd();
+
+ if(dbgtex) {
+ glUseProgram(0);
+ overlay_tex(dbgtex, dbg_alpha);
+ }
}
static void mbutton(int bn, int st, int x, int y)
}
static void mbutton(int bn, int st, int x, int y)
@@
-92,6
+106,16
@@
static void mbutton(int bn, int st, int x, int y)
bnstate[bn] = st;
mouse_x = x;
mouse_y = y;
bnstate[bn] = st;
mouse_x = x;
mouse_y = y;
+
+ switch(bn) {
+ case 3:
+ dbg_alpha += 0.1;
+ if(dbg_alpha > 1.0) dbg_alpha = 1.0;
+ break;
+ case 4:
+ dbg_alpha -= 0.1;
+ if(dbg_alpha < 0.0) dbg_alpha = 0.0;
+ }
}
static void mmotion(int x, int y)
}
static void mmotion(int x, int y)