projects
/
demo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix indentation,style
[demo]
/
src
/
main.cc
diff --git
a/src/main.cc
b/src/main.cc
index
cbe6ed6
..
69721c1
100644
(file)
--- a/
src/main.cc
+++ b/
src/main.cc
@@
-69,6
+69,7
@@
static MorphRenderer *cow_rend;
static Terrain terrain;
static TerrainParams p;
static Texture *skybox_tex;
static Terrain terrain;
static TerrainParams p;
static Texture *skybox_tex;
+static Texture *irradiance_tex;
static Texture *terrain_tex;
static Material terrain_mat;
static Renderer *terrain_rend;
static Texture *terrain_tex;
static Material terrain_mat;
static Renderer *terrain_rend;
@@
-170,9
+171,12
@@
static bool init(Gfx_API api)
skybox_tex = gfx_create_texture();
skybox_tex->load("data/cubemap/cubemap.hdr");
skybox_tex = gfx_create_texture();
skybox_tex->load("data/cubemap/cubemap.hdr");
- //irr_tex->load("data/cubemap/irradiance.hdr");
terrain_rend->set_sky_tex(skybox_tex);
terrain_rend->set_sky_tex(skybox_tex);
+ irradiance_tex = gfx_create_texture();
+ irradiance_tex->load("data/cubemap/irradiance.hdr");
+ terrain_rend->set_diffuse_sky_tex(irradiance_tex);
+
if(!terrain_rend->create()) {
fprintf(stderr, "terrain fail\n");
return false;
if(!terrain_rend->create()) {
fprintf(stderr, "terrain fail\n");
return false;
@@
-207,7
+211,7
@@
static bool init(Gfx_API api)
Object *cow = new Object;
*cow = *cow0;
Object *cow = new Object;
*cow = *cow0;
- if (!gen_poisson(cow_pos, cow_gap, disk_radius))
+ if(!gen_poisson(cow_pos, cow_gap, disk_radius))
goto cowgen_end;
Vec2 pos = cow_pos.back();
float y = terrain.get_height(Vec3(pos.x, 1, pos.y));
goto cowgen_end;
Vec2 pos = cow_pos.back();
float y = terrain.get_height(Vec3(pos.x, 1, pos.y));
@@
-230,8
+234,11
@@
static void cleanup()
delete cow_scene;
delete cow_rend;
delete cow_scene;
delete cow_rend;
+ delete skybox_tex;
+ delete irradiance_tex;
delete terrain_tex;
delete terrain_rend;
delete terrain_tex;
delete terrain_rend;
+
gfx_cleanup();
}
gfx_cleanup();
}
@@
-298,7
+305,7
@@
static void clbk_motion(GLFWwindow *win, double x, double y)
cam_dist = 0.0;
}
}
cam_dist = 0.0;
}
}
- }
+}
static void clbk_mouse(GLFWwindow *win, int bn, int action, int mods)
{
static void clbk_mouse(GLFWwindow *win, int bn, int action, int mods)
{
@@
-357,8
+364,7
@@
static void display()
static bool gen_poisson(std::vector<Vec2> &points, float min_dist, float radius)
{
/* poisson radius */
static bool gen_poisson(std::vector<Vec2> &points, float min_dist, float radius)
{
/* poisson radius */
- for (int i = 0; i < 1000; i++)
- {
+ for(int i = 0; i < 1000; i++) {
float angle = (float)rand() / (float)RAND_MAX * 2 * M_PI;
float r = sqrt((float)rand() / (float)RAND_MAX) * radius;
float angle = (float)rand() / (float)RAND_MAX * 2 * M_PI;
float r = sqrt((float)rand() / (float)RAND_MAX) * radius;
@@
-366,7
+372,7
@@
static bool gen_poisson(std::vector<Vec2> &points, float min_dist, float radius)
p.x = cos(angle) * r;
p.y = sin(angle) * r;
p.x = cos(angle) * r;
p.y = sin(angle) * r;
- bool valid = true;
+ bool valid = true;
for(size_t j=0; j<points.size(); j++) {
if(length_sq(points[j] - p) < min_dist * min_dist) {
valid = false;
for(size_t j=0; j<points.size(); j++) {
if(length_sq(points[j] - p) < min_dist * min_dist) {
valid = false;