I began working on retrieving the results from the mini-app. First, I created a new struct:
struct Results
{
double maxHeight;
double timeToMaximumHeight;
double timeToLand;
};
Then, I used the resource locator to find the mini-app's location. This will be used to run the mini-app when the start button is pressed. The FindResource
function returns the complete path to the directory or file.
miniApplication.location = FindResource("/Contents/Resources/modules/jumpcalculations");
After that, I had a lot of trouble starting the application. Using the printf
function, I discovered that the textboxFont
was not being loaded because fontResource.location
is being mutated after use. I do not know why. It might be worth opening an issue on SDL_TTF GitHub.
printf("%s\n", fontResource.location); // This is the correct one
char *temp = calloc(strlen(fontResource.location), sizeof(char));
strcpy(temp, fontResource.location);
appFont = TTF_OpenFont(fontResource.location, 30);
TTF_SetFontStyle(appFont, TTF_STYLE_BOLD);
printf("%s\n", fontResource.location); // This is not the correct one, the string gets mutated after use?
textboxFont = TTF_OpenFont(temp, 50); // copying the path to another variable works fine.
TTF_SetFontStyle(textboxFont, TTF_STYLE_BOLD);
It might be a good time to learn some basics of multithreading with C. I plan to use it to run the mini application and make the main thread wait until the calculation is finished.