examples: Print a description of the program to the console on startup.
This commit is contained in:
parent
a6407e88da
commit
6a25e94472
@ -103,6 +103,19 @@ sub handle_example_dir {
|
||||
my $jsdst = "$dst/$jsfname";
|
||||
my $wasmdst = "$dst/$wasmfname";
|
||||
|
||||
my $print_description = '';
|
||||
if (open(my $readmetxth, '<', "$examples_dir/$category/$example/README.txt")) {
|
||||
my $spc = '';
|
||||
while (<$readmetxth>) {
|
||||
chomp;
|
||||
s/\"/\\"/g;
|
||||
$print_description .= "${spc}Module.print(\"$_\");";
|
||||
$spc = ' ';
|
||||
}
|
||||
$print_description .= "${spc}Module.print(\"\");";
|
||||
close($readmetxth);
|
||||
}
|
||||
|
||||
do_mkdir($dst);
|
||||
do_copy($jssrc, $jsdst);
|
||||
do_copy($wasmsrc, $wasmdst);
|
||||
@ -142,6 +155,7 @@ sub handle_example_dir {
|
||||
s/\@example_name\@/$example/g;
|
||||
s/\@javascript_file\@/$jsfname/g;
|
||||
s/\@htmlified_source_code\@/$htmlified_source_code/g;
|
||||
s/\@print_description\@/$print_description/g;
|
||||
$html .= $_;
|
||||
}
|
||||
close($htmltemplate);
|
||||
|
5
examples/audio/01-simple-playback/README.txt
Normal file
5
examples/audio/01-simple-playback/README.txt
Normal file
@ -0,0 +1,5 @@
|
||||
If you're running this in a web browser, you need to click the window before you'll hear anything!
|
||||
|
||||
This example code creates an simple audio stream for playing sound, and
|
||||
generates a sine wave sound effect for it to play as time goes on. This is the
|
||||
simplest way to get up and running with procedural sound.
|
@ -47,9 +47,6 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
/* SDL_OpenAudioDeviceStream starts the device paused. You have to tell it to start! */
|
||||
SDL_ResumeAudioStreamDevice(stream);
|
||||
|
||||
/* (this is a web browser requirement, not an SDL thing.) */
|
||||
SDL_Log("If you're running this in a web browser, you need to click the window before you'll hear anything.");
|
||||
|
||||
return SDL_APP_CONTINUE; /* carry on with the program! */
|
||||
}
|
||||
|
||||
|
5
examples/audio/02-simple-playback-callback/README.txt
Normal file
5
examples/audio/02-simple-playback-callback/README.txt
Normal file
@ -0,0 +1,5 @@
|
||||
If you're running this in a web browser, you need to click the window before you'll hear anything!
|
||||
|
||||
This example code creates an simple audio stream for playing sound, and
|
||||
generates a sine wave sound effect for it to play as time goes on. Unlike
|
||||
the previous example, this uses a callback to generate sound.
|
@ -79,9 +79,6 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
/* SDL_OpenAudioDeviceStream starts the device paused. You have to tell it to start! */
|
||||
SDL_ResumeAudioStreamDevice(stream);
|
||||
|
||||
/* (this is a web browser requirement, not an SDL thing.) */
|
||||
SDL_Log("If you're running this in a web browser, you need to click the window before you'll hear anything.");
|
||||
|
||||
return SDL_APP_CONTINUE; /* carry on with the program! */
|
||||
}
|
||||
|
||||
|
5
examples/audio/03-load-wav/README.txt
Normal file
5
examples/audio/03-load-wav/README.txt
Normal file
@ -0,0 +1,5 @@
|
||||
If you're running this in a web browser, you need to click the window before you'll hear anything!
|
||||
|
||||
This example code creates an simple audio stream for playing sound, and
|
||||
loads a .wav file that is pushed through the stream in a loop.
|
||||
|
@ -61,9 +61,6 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
/* SDL_OpenAudioDeviceStream starts the device paused. You have to tell it to start! */
|
||||
SDL_ResumeAudioStreamDevice(stream);
|
||||
|
||||
/* (this is a web browser requirement, not an SDL thing.) */
|
||||
SDL_Log("If you're running this in a web browser, you need to click the window before you'll hear anything.");
|
||||
|
||||
return SDL_APP_CONTINUE; /* carry on with the program! */
|
||||
}
|
||||
|
||||
|
3
examples/renderer/01-clear/README.txt
Normal file
3
examples/renderer/01-clear/README.txt
Normal file
@ -0,0 +1,3 @@
|
||||
This example code creates an SDL window and renderer, and then clears the
|
||||
window to a different color every frame, so you'll effectively get a window
|
||||
that's smoothly fading between colors.
|
3
examples/renderer/02-primitives/README.txt
Normal file
3
examples/renderer/02-primitives/README.txt
Normal file
@ -0,0 +1,3 @@
|
||||
This example creates an SDL window and renderer, and then draws some lines,
|
||||
rectangles and points to it every frame.
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This example code creates an SDL window and renderer, and then draws a few
|
||||
* lines and rectangles to it every frame.
|
||||
* This example creates an SDL window and renderer, and then draws some lines,
|
||||
* rectangles and points to it every frame.
|
||||
*
|
||||
* This code is public domain. Feel free to use it for any purpose!
|
||||
*/
|
||||
|
@ -201,6 +201,7 @@
|
||||
if (text) console.error('[post-exception status] ' + text);
|
||||
};
|
||||
};
|
||||
@print_description@
|
||||
</script>
|
||||
<script async type="text/javascript" src="@javascript_file@"></script>
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user