title: How do I apply a texture to a quad in GTK or Cairo?
body: <p>I am trying to make an image to fit a quadrilateral.</p>
  
  <pre><code>#include &lt;gtk/gtk.h&gt;
  
  int main(int argc, char *argv[]) {
      gtk_init(&amp;argc, &amp;argv);
      GtkWidget (*Image) = gtk_image_new_from_file("image.png");
      GtkWidget (*Window) = gtk_window_new(0);
      gtk_image_set_pixel_size(GTK_IMAGE(Image), 200);
      gtk_container_add(GTK_CONTAINER(Window), Image);
      gtk_widget_show_all(Window);
      gtk_main();
      return 0;
  }
  </code></pre>
  
  <p>Suppose I have 8 variables. Each corresponding to the vertices of a quadrilateral. <code>x1 y1 x2 y2 x3 y3 x4 y4</code> These eight numbers correspond to four points on the window/drawing area that can be used to construct a quadrilateral. These numbers are representing points that are <code>x</code> pixels from the left and <code>y</code> from the top of the window, and since there are 4, the numbers represent which one. I have been trying to figure this out for a long time. How can I use those to create a quadrilateral, and stretch  the image to fit inside? Also, I want to avoid including header files other than the standard ones and gtk if possible. Basically I need to load an image from a file which is square and then transform it to match the desired shape. How exactly do I do that? Don't think I am trying to edit image files, I am actually trying to render block faces for a block sandbox game.</p>
  
  <p>I do appreciate the help, but I still don't quite know how to do what I am describing. Something I need to know is should I use a <code>GtkDrawingArea</code> or not?</p>
  
  <p><a href="https://developer.apple.com/documentation/metal/creating_and_sampling_textures" rel="nofollow noreferrer">I think I found something for the Mac version of what I am looking for</a>, but how can I do this in GTK?</p>
  
  <p>For more information, I am trying to render textures in the form of a 3D game.</p>
  
  <p>In Metal tutorials, this is one of the first features taught. Is this possible in GTK/Cairo, or do I need to scrap my progress and use OpenGL or something for Linux.</p>