Skip to content

Commit

Permalink
Bump rawdraw version and make use of example for local file logging
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlohr committed Oct 3, 2024
1 parent 83f7161 commit f8bc408
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rawdraw
26 changes: 26 additions & 0 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,28 @@ void HandleMotion( int x, int y, int mask )
lastmotiony = y;
}

//writes the text to a file to path (example): /storage/emulated/0/Android/data/org.yourorg.cnfgtest/files
// You would not normally want to do this, but it's an example of how to do local storage.
void Log(const char *fmt, ...)
{
const char* getpath = AndroidGetExternalFilesDir();
char buffer[2048];
snprintf(buffer, sizeof(buffer), "%s/log.txt", getpath);
FILE *f = fopen(buffer, "w");
if (f == NULL)
{
exit(1);
}

va_list arg;
va_start(arg, fmt);
vsnprintf(buffer, sizeof(buffer), fmt, arg);
va_end(arg);

fprintf(f, "%s\n", buffer);

fclose(f);
}
#define HMX 162
#define HMY 162
short screenx, screeny;
Expand Down Expand Up @@ -496,6 +518,8 @@ int main( int argc, char ** argv )
double ThisTime;
double LastFPSTime = OGGetAbsoluteTime();

Log( "Starting Up" );

CNFGBGColor = 0x000040ff;
CNFGSetupFullscreen( "Test Bench", 0 );

Expand Down Expand Up @@ -529,6 +553,8 @@ int main( int argc, char ** argv )
RunCallbackOnUIThread( SetupWebView, &MyWebView );
while( !MyWebView.WebViewObject ) usleep(1);

Log( "Startup Complete" );

while(1)
{
int i;
Expand Down

0 comments on commit f8bc408

Please sign in to comment.