You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on Lesson 2 and trying to sort the vertices of a triangle using the std::sort() function. To do this, I wrote a lambda function to compare Vec2i objects, but I'm getting a compilation error when I try to run the make command. Even when I try a simple lambda function that just adds two integers, it still gives me an error. Here is my code and Makefile, can someone please help me?
voidtriangle(Vec2i tmp[],TGAImage &image, TGAColor color){
std::vector<Vec2i> p(tmp, tmp + 3);
std::function<int(int, int)> f1 = [](int a, int b){ return a + b; };
auto cmp = [](const Vec2i &a,const Vec2i &b)->bool{return a.y<b.y;};
// std::sort(p.begin(),p.end(),cmp);//// line(p[0],p[1],image,green);// line(p[1],p[2],image,green);// line(p[2],p[0],image,green);
}
int width = 500;
int height = 500;
intmain(int argc, char** argv) {
auto model = newModel("obj/african_head.obj");
TGAImage image(width, height, TGAImage::RGB);
Vec2i t0[3] = {Vec2i(10, 70), Vec2i(50, 160), Vec2i(70, 80)};
triangle(t0,image,blue);
image.flip_vertically(); // i want to have the origin at the left bottom corner of the image
image.write_tga_file("output.tga");
return0;
}
I'm working on Lesson 2 and trying to sort the vertices of a triangle using the std::sort() function. To do this, I wrote a lambda function to compare Vec2i objects, but I'm getting a compilation error when I try to run the make command. Even when I try a simple lambda function that just adds two integers, it still gives me an error. Here is my code and Makefile, can someone please help me?
The text was updated successfully, but these errors were encountered: