mirror of https://github.com/BOINC/boinc.git
- version 6 example app works on Win
example_app/ uc2.C uc2.h (new) uc2_graphics.C win_build/ libgraphics2.vcproj samples.sln uc2.vcproj uc2_graphics.vcproj svn path=/trunk/boinc_samples/; revision=12736
This commit is contained in:
parent
9b9d634039
commit
e86e4464f0
|
@ -334,3 +334,16 @@ David 22 May 2007
|
|||
samples.sln
|
||||
uc2.vcproj (new)
|
||||
uc2_graphics.vcproj (new)
|
||||
|
||||
David 23 May 2007
|
||||
- version 6 example app works on Win
|
||||
|
||||
example_app/
|
||||
uc2.C
|
||||
uc2.h (new)
|
||||
uc2_graphics.C
|
||||
win_build/
|
||||
libgraphics2.vcproj
|
||||
samples.sln
|
||||
uc2.vcproj
|
||||
uc2_graphics.vcproj
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Berkeley Open Infrastructure for Network Computing
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2005 University of California
|
||||
// Copyright (C) 2007 University of California
|
||||
//
|
||||
// This is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -33,9 +33,6 @@
|
|||
#include "boinc_win.h"
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <cstdio>
|
||||
#include <cctype>
|
||||
#include <ctime>
|
||||
|
@ -50,6 +47,8 @@
|
|||
#include "filesys.h"
|
||||
#include "boinc_api.h"
|
||||
#include "mfile.h"
|
||||
#include "graphics2.h"
|
||||
#include "uc2.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
@ -62,7 +61,7 @@ bool early_exit = false;
|
|||
bool early_crash = false;
|
||||
bool early_sleep = false;
|
||||
double cpu_time = 20;
|
||||
|
||||
UC_SHMEM* shmem;
|
||||
|
||||
static void use_some_cpu() {
|
||||
double j = 3.14159;
|
||||
|
@ -96,14 +95,24 @@ int do_checkpoint(MFILE& mf, int nchars) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void update_shmem(double fd) {
|
||||
double cpu;
|
||||
if (!shmem) return;
|
||||
shmem->fraction_done = fd;
|
||||
boinc_calling_thread_cpu_time(cpu);
|
||||
shmem->cpu_time = cpu;
|
||||
shmem->update_time = dtime();
|
||||
}
|
||||
|
||||
void worker() {
|
||||
int c, nchars = 0, retval, n;
|
||||
double fsize;
|
||||
double fsize, fd;
|
||||
char input_path[512], output_path[512], chkpt_path[512];
|
||||
MFILE out;
|
||||
FILE* state, *infile;
|
||||
|
||||
shmem = (UC_SHMEM*)boinc_graphics_make_shmem("uppercase", sizeof(UC_SHMEM));
|
||||
|
||||
// open the input file (resolve logical name first)
|
||||
//
|
||||
boinc_resolve_filename(INPUT_FILENAME, input_path, sizeof(input_path));
|
||||
|
@ -119,8 +128,6 @@ void worker() {
|
|||
//
|
||||
file_size(input_path, fsize);
|
||||
|
||||
// open output file
|
||||
//
|
||||
boinc_resolve_filename(OUTPUT_FILENAME, output_path, sizeof(output_path));
|
||||
|
||||
// See if there's a valid checkpoint file.
|
||||
|
@ -164,11 +171,7 @@ void worker() {
|
|||
}
|
||||
|
||||
if (early_crash && i>30) {
|
||||
#ifdef _WIN32
|
||||
DebugBreak();
|
||||
#else
|
||||
*(int*)0 = 0;
|
||||
#endif
|
||||
boinc_crash();
|
||||
}
|
||||
if (early_sleep && i>30) {
|
||||
g_sleep = true;
|
||||
|
@ -184,7 +187,10 @@ void worker() {
|
|||
boinc_checkpoint_completed();
|
||||
}
|
||||
|
||||
boinc_fraction_done(nchars/fsize);
|
||||
fd = nchars/fsize;
|
||||
if (cpu_time) fd /= 2;
|
||||
boinc_fraction_done(fd);
|
||||
update_shmem(fd);
|
||||
}
|
||||
|
||||
retval = out.flush();
|
||||
|
@ -200,7 +206,9 @@ void worker() {
|
|||
while (1) {
|
||||
double e = dtime()-start;
|
||||
if (e > cpu_time) break;
|
||||
boinc_fraction_done(e/cpu_time);
|
||||
fd = .5 + .5*(e/cpu_time);
|
||||
boinc_fraction_done(fd);
|
||||
update_shmem(fd);
|
||||
|
||||
if (boinc_time_to_checkpoint()) {
|
||||
retval = do_checkpoint(out, nchars);
|
||||
|
@ -214,6 +222,7 @@ void worker() {
|
|||
use_some_cpu();
|
||||
}
|
||||
}
|
||||
update_shmem(1);
|
||||
boinc_finish(0);
|
||||
}
|
||||
|
||||
|
@ -249,3 +258,4 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int WinMode
|
|||
#endif
|
||||
|
||||
const char *BOINC_RCSID_33ac47a071 = "$Id: upper_case.C 12135 2007-02-21 20:04:14Z davea $";
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
struct UC_SHMEM {
|
||||
double update_time;
|
||||
double fraction_done;
|
||||
double cpu_time;
|
||||
};
|
|
@ -28,8 +28,11 @@
|
|||
#include "parse.h"
|
||||
#include "gutil.h"
|
||||
#include "boinc_gl.h"
|
||||
#include "graphics_api.h"
|
||||
#include "app_ipc.h"
|
||||
#include "boinc_api.h"
|
||||
#include "graphics2.h"
|
||||
#include "txf_util.h"
|
||||
#include "uc2.h"
|
||||
|
||||
float white[4] = {1., 1., 1., 1.};
|
||||
TEXTURE_DESC logo;
|
||||
|
@ -39,6 +42,7 @@ bool mouse_down = false;
|
|||
int mouse_x, mouse_y;
|
||||
double pitch_angle, roll_angle, viewpoint_distance=10;
|
||||
float color[4] = {.7, .2, .5, 1};
|
||||
UC_SHMEM* shmem;
|
||||
|
||||
static void parse_project_prefs(char* buf) {
|
||||
char cs[256];
|
||||
|
@ -102,12 +106,19 @@ static void draw_text() {
|
|||
y += dy;
|
||||
if (x < 0 || x > .5) dx *= -1;
|
||||
if (y < 0 || y > .5) dy *= -1;
|
||||
double fd = 0, cpu=0;
|
||||
if (shmem) {
|
||||
fd = shmem->fraction_done;
|
||||
cpu = shmem->cpu_time;
|
||||
}
|
||||
sprintf(buf, "User: %s", uc_aid.user_name);
|
||||
txf_render_string(.1, x, y, 0, 500, white, 0, buf);
|
||||
sprintf(buf, "Team: %s", uc_aid.team_name);
|
||||
txf_render_string(.1, x, y+.1, 0, 500, white, 0, buf);
|
||||
sprintf(buf, "%% Done: %f", 100*boinc_get_fraction_done());
|
||||
sprintf(buf, "%% Done: %f", 100*fd);
|
||||
txf_render_string(.1, x, y+.2, 0, 500, white, 0, buf);
|
||||
sprintf(buf, "CPU time: %f", cpu);
|
||||
txf_render_string(.1, x, y+.3, 0, 500, white, 0, buf);
|
||||
}
|
||||
|
||||
static void draw_3d_stuff() {
|
||||
|
@ -221,8 +232,7 @@ void boinc_app_key_release(int, int){}
|
|||
|
||||
}
|
||||
|
||||
extern void boinc_graphics(int, char**);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
boinc_graphics(argc, argv);
|
||||
shmem = (UC_SHMEM*)boinc_graphics_get_shmem("uppercase");
|
||||
boinc_graphics_loop(argc, argv);
|
||||
}
|
||||
|
|
|
@ -294,6 +294,10 @@
|
|||
RelativePath="..\..\boinc\api\graphics2.C"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\boinc\api\graphics2_util.C"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\boinc\api\graphics2_win.C"
|
||||
>
|
||||
|
@ -360,6 +364,10 @@
|
|||
RelativePath="..\..\boinc\api\boinc_gl.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\boinc\api\graphics2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\boinc\api\graphics_api.h"
|
||||
>
|
||||
|
|
|
@ -12,23 +12,23 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glut", "glut.vcproj", "{C41
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "upper_case", "upper_case.vcproj", "{8281D898-0E64-44EB-8356-4F0336F19A35}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{D3D21F11-A7E7-4EA2-8518-E24695133BFF} = {D3D21F11-A7E7-4EA2-8518-E24695133BFF}
|
||||
{C4165626-F68F-4F66-A126-3B82DDBB7480} = {C4165626-F68F-4F66-A126-3B82DDBB7480}
|
||||
{0BC1DB36-030A-4321-B387-1CEE2611E329} = {0BC1DB36-030A-4321-B387-1CEE2611E329}
|
||||
{E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8}
|
||||
{5F065EAC-B881-4E9A-9E34-7A21D7A01D98} = {5F065EAC-B881-4E9A-9E34-7A21D7A01D98}
|
||||
{E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8}
|
||||
{0BC1DB36-030A-4321-B387-1CEE2611E329} = {0BC1DB36-030A-4321-B387-1CEE2611E329}
|
||||
{C4165626-F68F-4F66-A126-3B82DDBB7480} = {C4165626-F68F-4F66-A126-3B82DDBB7480}
|
||||
{D3D21F11-A7E7-4EA2-8518-E24695133BFF} = {D3D21F11-A7E7-4EA2-8518-E24695133BFF}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wrapper", "wrapper.vcproj", "{F243B93C-73CB-44E7-9BDC-847BB95A27CA}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{0BC1DB36-030A-4321-B387-1CEE2611E329} = {0BC1DB36-030A-4321-B387-1CEE2611E329}
|
||||
{E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8}
|
||||
{0BC1DB36-030A-4321-B387-1CEE2611E329} = {0BC1DB36-030A-4321-B387-1CEE2611E329}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sleeper", "sleeper.vcproj", "{A9647CEA-644D-4C0A-8733-D916CD344859}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{0BC1DB36-030A-4321-B387-1CEE2611E329} = {0BC1DB36-030A-4321-B387-1CEE2611E329}
|
||||
{E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8}
|
||||
{0BC1DB36-030A-4321-B387-1CEE2611E329} = {0BC1DB36-030A-4321-B387-1CEE2611E329}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "worker", "worker.vcproj", "{F1BE6109-586D-448E-8C5B-D5C2CB874EA2}"
|
||||
|
@ -38,17 +38,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "worker", "worker.vcproj", "
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uc2", "uc2.vcproj", "{CCB9A37C-7AD8-4FC1-ABEC-1A6ED2268F83}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8}
|
||||
{0BC1DB36-030A-4321-B387-1CEE2611E329} = {0BC1DB36-030A-4321-B387-1CEE2611E329}
|
||||
{814EBFD3-3CE6-4933-A580-C1FE3147ACB4} = {814EBFD3-3CE6-4933-A580-C1FE3147ACB4}
|
||||
{E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uc2_graphics", "uc2_graphics.vcproj", "{3CF31288-A44D-4C78-A3AA-B05B6E32DF11}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5F065EAC-B881-4E9A-9E34-7A21D7A01D98} = {5F065EAC-B881-4E9A-9E34-7A21D7A01D98}
|
||||
{814EBFD3-3CE6-4933-A580-C1FE3147ACB4} = {814EBFD3-3CE6-4933-A580-C1FE3147ACB4}
|
||||
{D3D21F11-A7E7-4EA2-8518-E24695133BFF} = {D3D21F11-A7E7-4EA2-8518-E24695133BFF}
|
||||
{C4165626-F68F-4F66-A126-3B82DDBB7480} = {C4165626-F68F-4F66-A126-3B82DDBB7480}
|
||||
{5F065EAC-B881-4E9A-9E34-7A21D7A01D98} = {5F065EAC-B881-4E9A-9E34-7A21D7A01D98}
|
||||
{E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8}
|
||||
{C4165626-F68F-4F66-A126-3B82DDBB7480} = {C4165626-F68F-4F66-A126-3B82DDBB7480}
|
||||
{D3D21F11-A7E7-4EA2-8518-E24695133BFF} = {D3D21F11-A7E7-4EA2-8518-E24695133BFF}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libgraphics2", "libgraphics2.vcproj", "{814EBFD3-3CE6-4933-A580-C1FE3147ACB4}"
|
||||
|
|
|
@ -416,6 +416,10 @@
|
|||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\boinc\api\graphics2_util.C"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\example_app\uc2.C"
|
||||
>
|
||||
|
@ -430,6 +434,10 @@
|
|||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\example_app\uc2.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
|
|
@ -430,6 +430,10 @@
|
|||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\example_app\uc2.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
|
Loading…
Reference in New Issue