mirror of https://github.com/BOINC/boinc.git
- example app: parse <max_frames_sec> and <max_gfx_cpu_pct>
from project-specific prefs. This gives the user a couple of ways of limiting CPU usage for graphics. - example app: define APP_GRAPHICS in project file, not source svn path=/trunk/boinc_samples/; revision=14636
This commit is contained in:
parent
345c38ae9c
commit
cbe6b403b1
|
@ -512,8 +512,18 @@ Charlie 28 Nov 2007
|
|||
UpperCase2.xcodeproj/
|
||||
project.pbxproj
|
||||
|
||||
David 6 Jan 2007
|
||||
David 6 Jan 2008
|
||||
- small bug fix
|
||||
|
||||
wrapper/
|
||||
wrapper.C
|
||||
|
||||
David 28 Jan 2008
|
||||
- example app: parse <max_frames_sec> and <max_gfx_cpu_pct>
|
||||
from project-specific prefs. This gives the user a couple
|
||||
of ways of limiting CPU usage for graphics.
|
||||
- example app: define APP_GRAPHICS in project file, not source
|
||||
|
||||
example_app/
|
||||
uc2.C
|
||||
uc2_graphics.C
|
||||
|
|
|
@ -17,19 +17,21 @@
|
|||
// or write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
// This program serves as both
|
||||
// - An example BOINC application, illustrating the use of the BOINC API
|
||||
// - A program for testing various features of BOINC
|
||||
//
|
||||
// NOTE: this file exists as both
|
||||
// boinc/apps/upper_case.C
|
||||
// and
|
||||
// boinc_samples/example_app/uc2.C
|
||||
// If you update one, please update the other!
|
||||
|
||||
// This is the primary sample BOINC application;
|
||||
// it shows most of the features of the BOINC API.
|
||||
//
|
||||
// The program converts a mixed-case file to upper case:
|
||||
// read "in", convert to upper case, write to "out"
|
||||
//
|
||||
// command line options (use for debugging various scenarios):
|
||||
// -run_slow: sleep 1 second after each character; useful for debugging
|
||||
// command line options
|
||||
// -run_slow: sleep 1 second after each character
|
||||
// -cpu_time N: use about N CPU seconds after copying files
|
||||
// -early_exit: exit(10) after 30 chars
|
||||
// -early_crash: crash after 30 chars
|
||||
|
@ -55,8 +57,6 @@
|
|||
#include "mfile.h"
|
||||
#include "graphics2.h"
|
||||
|
||||
#define APP_GRAPHICS
|
||||
|
||||
#ifdef APP_GRAPHICS
|
||||
#include "uc2.h"
|
||||
UC_SHMEM* shmem;
|
||||
|
@ -93,16 +93,12 @@ int do_checkpoint(MFILE& mf, int nchars) {
|
|||
fprintf(f, "%d", nchars);
|
||||
fclose(f);
|
||||
|
||||
fprintf(stderr, "APP: upper_case checkpointing\n");
|
||||
|
||||
retval = mf.flush();
|
||||
if (retval) return retval;
|
||||
boinc_resolve_filename_s(CHECKPOINT_FILE, resolved_name);
|
||||
retval = boinc_rename("temp", resolved_name.c_str());
|
||||
if (retval) return retval;
|
||||
|
||||
//use_some_cpu();
|
||||
fprintf(stderr, "APP: upper_case checkpoint done\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ bool mouse_down = false;
|
|||
int mouse_x, mouse_y;
|
||||
double pitch_angle, roll_angle, viewpoint_distance=10;
|
||||
float color[4] = {.7, .2, .5, 1};
|
||||
// the color of the 3D object.
|
||||
// Can be changed using preferences
|
||||
UC_SHMEM* shmem = NULL;
|
||||
|
||||
// set up lighting model
|
||||
|
@ -234,6 +236,7 @@ static void parse_project_prefs(char* buf) {
|
|||
char cs[256];
|
||||
COLOR c;
|
||||
double hue;
|
||||
double max_frames_sec, max_gfx_cpu_pct;
|
||||
if (!buf) return;
|
||||
if (parse_str(buf, "<color_scheme>", cs, 256)) {
|
||||
if (!strcmp(cs, "Tahiti Sunset")) {
|
||||
|
@ -249,6 +252,12 @@ static void parse_project_prefs(char* buf) {
|
|||
color[2] = c.b;
|
||||
color[3] = 1;
|
||||
}
|
||||
if (parse_double(buf, "<max_frames_sec>", max_frames_sec)) {
|
||||
boinc_max_fps = max_frames_sec;
|
||||
}
|
||||
if (parse_double(buf, "<max_gfx_cpu_pct>", max_gfx_cpu_pct)) {
|
||||
boinc_max_gfx_cpu_frac = max_gfx_cpu_pct/100;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
InlineFunctionExpansion="1"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories=".;../../boinc;../../boinc/api;../../boinc/lib;../image_libs;../jpeglib;../glut"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_MT;_CONSOLE"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_MT;_CONSOLE;APP_GRAPHICS"
|
||||
StringPooling="false"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
|
|
Loading…
Reference in New Issue