gpuray_glsl
diff src/gpuscene.cc @ 4:2ed3da7dc0bc
broken
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 10 Nov 2014 01:26:00 +0200 |
parents | f234630e38ff |
children |
line diff
1.1 --- a/src/gpuscene.cc Sun Nov 09 20:13:33 2014 +0200 1.2 +++ b/src/gpuscene.cc Mon Nov 10 01:26:00 2014 +0200 1.3 @@ -35,10 +35,12 @@ 1.4 Sphere *sph; 1.5 Plane *plane; 1.6 Box *box; 1.7 + Cone *cone; 1.8 1.9 std::vector<Sphere*> spheres; 1.10 std::vector<Plane*> planes; 1.11 std::vector<Box*> boxes; 1.12 + std::vector<Cone*> cones; 1.13 1.14 // collect all objects into the different type-specific arrays 1.15 for(auto obj : objects) { 1.16 @@ -51,6 +53,9 @@ 1.17 } else if((box = dynamic_cast<Box*>(obj))) { 1.18 boxes.push_back(box); 1.19 1.20 + } else if((cone = dynamic_cast<Cone*>(obj))) { 1.21 + cones.push_back(cone); 1.22 + 1.23 } else { 1.24 fprintf(stderr, "skipping object of unknown type: %s\n", obj->get_name()); 1.25 } 1.26 @@ -59,6 +64,7 @@ 1.27 create_sphere_texture(spheres); 1.28 create_plane_texture(planes); 1.29 create_box_texture(boxes); 1.30 + create_cone_texture(cones); 1.31 1.32 create_env_texture(); 1.33 create_xform_texture(); 1.34 @@ -194,6 +200,38 @@ 1.35 delete [] pixels; 1.36 } 1.37 1.38 +void GPUScene::create_cone_texture(const std::vector<Cone*> &cones) 1.39 +{ 1.40 + int xsz = OBJ_LINE_WIDTH; 1.41 + int ysz = (int)cones.size() + 1; 1.42 + int tex_ysz = next_pow2(ysz); 1.43 + 1.44 + Vector4 *pixels = new Vector4[xsz * tex_ysz]; 1.45 + 1.46 + pixels[0].x = (float)ysz; 1.47 + pixels[0].y = (float)tex_ysz; 1.48 + 1.49 + Vector4 *pixptr = pixels + xsz; 1.50 + 1.51 + for(size_t i=0; i<cones.size(); i++) { 1.52 + pixptr[0].x = object_index(cones[i]); 1.53 + 1.54 + pixptr[1].x = cones[i]->angle; 1.55 + pixptr[1].y = cones[i]->ymin; 1.56 + pixptr[1].z = cones[i]->ymax; 1.57 + pixptr[1].w = 0.0; 1.58 + 1.59 + copy_material(pixptr, &cones[i]->material); 1.60 + pixptr += OBJ_LINE_WIDTH; 1.61 + } 1.62 + 1.63 + glBindTexture(GL_TEXTURE_2D, textures[TEX_SPHERE]); 1.64 + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, xsz, tex_ysz, 0, GL_RGBA, GL_FLOAT, pixels); 1.65 + 1.66 + delete [] pixels; 1.67 +} 1.68 + 1.69 + 1.70 void GPUScene::create_megatexture() 1.71 { 1.72 // at least a 1x1 dummy white texture