Pages

Sunday, 22 March 2020

Chapter 12 // Exercise 7 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and the graphics files found here:
https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files

Chapter 12 // Exercise 7

Draw a two-dimensional house seen from the front, the way a child would: with a door, two windows, and a roof with a chimney. Feel free to add details; maybe have "smoke come out of the chimney.

Github: https://github.com/l-paz91/principles-practice/blob/master/Chapter%2012/Exercise%207

I wanted to add some clouds and grass to this and thought it would be easy however I got an error when drawing saying "PNG images are unsupported". FLTK does actually support png however we are using Bjarne's "version" of fltk and if you go to Graph.cpp (line 378) you'll see that he's only supported the use of two file formats; jpg and gif. So, I decided to add png.

First add #include <Fl/Fl_PNG_Image.H>  to fltk.h. Then in Graph.h add another enum type to Suffix::Encoding called png. In init_suffix_map() in Graph.cpp, add two more entries for png.

In Graph.cpp, in the Image constructor, add another case for png (basically copy pasta but change the name).

And then last, go to the project properties->linker->input->additional dependencies. Click edit and add fltkpngd.lib and fltkzlibd.lib

Png images now work with Bjarne's Image class! Once that was working; I got lazy....super lazy. And so I made the house in Photoshop, saved it as png and then loaded it.



Looks legit right? I could've just done the entire thing in photoshop...then loaded it as a normal png but I don't think that was the point of the exercise, or was it?

No comments:

Post a Comment