From: Mikko Rasa Date: Sun, 21 Mar 2021 15:51:09 +0000 (+0200) Subject: Update the desert pillars demo to work once again X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=3d156fc172b3de552fa29578218dae89a07b2728;p=libs%2Fgl.git Update the desert pillars demo to work once again There's some warnings which require a more comprehensive overhaul to get rid of. --- diff --git a/demos/desertpillars.cpp b/demos/desertpillars.cpp index 242a9e73..89a0fe51 100644 --- a/demos/desertpillars.cpp +++ b/demos/desertpillars.cpp @@ -227,13 +227,17 @@ const char DesertPillars::ground_src[] = "const bool use_normal_map = true;\n" "const bool use_shadow_map = true;\n" "#pragma MSP stage(vertex)\n" - "layout(location=7) in float ground_type;\n" + "layout(location=11) in float ground_type;\n" + "void custom_transform() override\n" + "{\n" + " passthrough;\n" + "}\n" "#pragma MSP stage(fragment)\n" - "vec4 get_diffuse_color()\n" + "vec4 get_diffuse_color() override\n" "{\n" " return mix(texture(texture1, texcoord.xy*3.0), texture(texture2, texcoord.xy), ground_type);\n" "}\n" - "vec4 get_fragment_normal()\n" + "vec3 get_fragment_normal() override\n" "{\n" " return mix(texture(normalmap1, texcoord.xy*3.0).rgb, texture(normalmap2, texcoord.xy).rgb, ground_type);\n" "}\n"; @@ -244,12 +248,12 @@ const char DesertPillars::cube_src[] = "const bool use_reflectivity = true;\n" "uniform float spherify;\n" "#pragma MSP stage(vertex)\n" - "layout(location=7) in vec3 sphere_coord;\n" - "vec4 transform_position(vec4 pos)\n" + "layout(location=11) in vec3 sphere_coord;\n" + "vec4 transform_position(vec4 pos) override\n" "{\n" " return eye_obj_matrix*vec4(mix(vertex.xyz, sphere_coord, spherify), 1.0);\n" "}\n" - "vec3 transform_normal(vec3 pos)\n" + "vec3 transform_normal(vec3 pos) override\n" "{\n" " return eye_obj_normal_matrix*normalize(mix(normal, normalize(sphere_coord), spherify));\n" "}\n"; @@ -609,7 +613,7 @@ void DesertPillars::create_ground() /* No shadow pass here; the ground only receives shadows, but doesn't cast them. */ - GL::VertexFormat vfmt = (GL::VERTEX3, GL::NORMAL3, GL::TANGENT3, GL::BINORMAL3, GL::TEXCOORD2, GL::ATTRIB1,7); + GL::VertexFormat vfmt = (GL::VERTEX3, GL::NORMAL3, GL::TANGENT3, GL::BINORMAL3, GL::TEXCOORD2, GL::GENERIC1); ground_data.mesh = new GL::Mesh(vfmt); // Create a base grid @@ -622,7 +626,7 @@ void DesertPillars::create_ground() unsigned tan = vfmt.offset(GL::TANGENT3); unsigned bin = vfmt.offset(GL::BINORMAL3); unsigned tex = vfmt.offset(GL::TEXCOORD2); - unsigned gt = vfmt.offset(GL::make_indexed_component(GL::ATTRIB1, 7)); + unsigned gt = vfmt.offset(GL::GENERIC1); for(unsigned i=0; imodify_vertex(i); @@ -676,7 +680,7 @@ void DesertPillars::create_pillars() pillar_material.set_receive_shadows(true); GL::RenderPass *pass = &pillar_tech.add_pass(0); - pass->set_material(&pillar_material); + pass->set_material(&pillar_material, &resources); pass = &pillar_tech.add_pass("shadow"); pass->set_shader_program(&shadow_shprog, 0); @@ -752,13 +756,13 @@ void DesertPillars::create_cube() cube_material.set_reflectivity(0.5); GL::RenderPass *pass = &cube_tech.add_pass(0); - pass->set_material(&cube_material); + pass->set_material(&cube_material, &resources); pass->set_shader_program(&cube_shprog, 0); pass = &cube_tech.add_pass("shadow"); pass->set_shader_program(&cube_shadow_shprog, 0); - cube_data.mesh = new GL::Mesh((GL::VERTEX3, GL::NORMAL3, GL::ATTRIB3,7)); + cube_data.mesh = new GL::Mesh((GL::VERTEX3, GL::NORMAL3, GL::GENERIC3)); GL::MeshBuilder bld(*cube_data.mesh); create_cube_face(bld, GL::Vector3(-1, -1, -1), GL::Vector3(2, 0, 0), GL::Vector3(0, 2, 0), 16); bld.offset(cube_data.mesh->get_n_vertices()); @@ -800,7 +804,7 @@ void DesertPillars::create_cube_face(GL::MeshBuilder &bld, const GL::Vector3 &ba l = sqrt(v.x*v.x+v.y*v.y+v.z*v.z); l /= 1.732; - bld.attrib(7, v.x/l, v.y/l, v.z/l); + bld.generic(0, v.x/l, v.y/l, v.z/l); bld.vertex(v); }