#include <SDL2/SDL.h>#include <box2d/box2d.h>#include <vector>#include <random>#include <iostream>#include <fstream>#include <sstream>#include "utils.h"#include "distances.h"#include "render.h"#include "spogobot.h"#include "fpng.h"Functions | |
| void | draw_polygon (SDL_Renderer *renderer, const std::vector< b2Vec2 > &polygon) |
| Draws a polygon using an SDL renderer. | |
| void | save_window_to_png (SDL_Renderer *renderer, SDL_Window *window, const std::string &filename) |
| Saves the content of an SDL window to a PNG file. | |
| void draw_polygon | ( | SDL_Renderer * | renderer, |
| const std::vector< b2Vec2 > & | polygon ) |
Draws a polygon using an SDL renderer.
This function renders a polygon by drawing red lines between consecutive vertices on the provided SDL renderer. It also closes the polygon by drawing a line between the last and first vertex.
| renderer | Pointer to the SDL_Renderer to use for drawing. |
| polygon | A vector of b2Vec2 points defining the polygon. |
| void save_window_to_png | ( | SDL_Renderer * | renderer, |
| SDL_Window * | window, | ||
| const std::string & | filename ) |
Saves the content of an SDL window to a PNG file.
This function reads the pixels from the SDL renderer associated with a window and saves the image as a PNG file. It also ensures that the directory path for the output file exists.
| renderer | Pointer to the SDL_Renderer used for capturing the window content. |
| window | Pointer to the SDL_Window from which to capture the content. |
| filename | The file path where the PNG image will be saved. |