A Porgram to display wireframe maps!
This project is a 3D wireframe visualizer that demonstrates rendering and manipulating 3D maps, including zooming, shifting functionalities or window resize management.
It highlights efficient coding practices and custom solutions, providing a solid foundation for exploring computer graphics and 3D visualization.
git clone https://github.com/floktl/WireframeVisualizer
cd WireframeVisualizer && make
./fdf 42.fdf
You can zoom the map with the scroll wheel Or shift the map with left mouse button clicked
Press I for the full manual
Here are some examples that showcase why the code in this project is safe and easy to read:
All dynamically allocated memory is properly freed to avoid memory leaks.
int32_t ***free_map_data(int32_t ***map, char **collumn, int row)
{
map[row] = NULL;
free_two_dimensional_array(collumn);
free_map(map);
return (NULL);
}
Function names are descriptive, making it easy to understand what each function does.
void remove_manual_from_window(t_window *window);
void set_map_to_middle(t_window *window);
void print_manual(t_window *window);
The code includes checks to handle errors gracefully.
// function to assign the coordinate data from the map into 3-dimensional array
int assign_map_values(int32_t ***map_x_axis, char **collumn, int line)
{
char *color;
int x;
x = 0;
while (collumn[x] != NULL)
{
(*map_x_axis)[x] = malloc(2 * sizeof(int));
if (!(*map_x_axis)[x])
return (EXIT_FAILURE); // returns an Error if there is a mallocation error
To prove my mathematical skills, i didn't us the math.h library, so i created my own math functions
for example a sqrt() replacement-function:
// replace function for square root, why not, Math is fun!
// Newton-Raphson Method
double ft_sqrt(double a)
{
double x;
double next;
x = a;
while (1)
{
next = 0.5 * (x + a / x);
if ((next - x) * (next - x) < EPSILON * EPSILON)
break ;
x = next;
}
return (x);
}
Florian Keitel - https://www.linkedin.com/in/fkeitel/ - [email protected]
Project Link: https://github.com/floktl/WireframeVisualizer)]