Where to put the code? - Printable Version +- Forums (http://www.scratchpadgames.net/forums) +-- Forum: Main Forums (http://www.scratchpadgames.net/forums/forumdisplay.php?fid=1) +--- Forum: Help my code won't work?? (http://www.scratchpadgames.net/forums/forumdisplay.php?fid=22) +--- Thread: Where to put the code? (/showthread.php?tid=46) |
Where to put the code? - pahendriks - 03-15-2018 Hi, In the book you say (section: Add some code, picture of Lenna): After the FileHandler add this code: MyFiles FileHandler; int Width, Height; char* OurRawData = FileHandler.Load((char*)"../Lenna.png", &Width, &Height); if (OurRawData == NULL) printf("We failed to load\n"); WHERE do I have to put this code? In which file and on which location? Best Regards, Patrick update: it seems that putting it after this line in MyFiles.cpp is the place to be: unsigned char *data = stbi_load(filename, width, height, &comp, 4); RE: Where to put the code? - Brian Beuken - 03-15-2018 yes, the code can actually go anywhere really as long as you include STB, and have a MyFiles Filehandler line somewhere but putting into a Myfiles.cpp file to wrap our load in to a nice function is the safest option. |