Changes between Version 35 and Version 36 of GraphicsApi


Ignore:
Timestamp:
Jan 19, 2014, 4:50:31 PM (10 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GraphicsApi

    v35 v36  
    103103}}}
    104104`boinc_graphics_make_shmem()` (called from the main app) creates a shared memory segment of the given size.
    105 'appname' should be the name of this application (used to ensure uniqueness of the shared-memory segment name). `boinc_graphics_get_shmem()` (called from the graphics app) attaches to an existing segment.
     105'appname' should be the name of this application (used to ensure uniqueness of the shared-memory segment name).
     106`boinc_graphics_get_shmem()` (called from the graphics app) attaches to an existing segment.
    106107It must be called AFTER boinc_parse_init_data_file().
    107108
     
    120121using [BasicApi#timer boinc_set_timer_handler()].
    121122The items are:
    122  update_time:: The current time (dtime()).  The graphics app should exit if the current time exceeds this by 5 seconds or so.
     123 update_time:: The current time (dtime()).
     124The graphics app should exit if the current time exceeds this by 5 seconds or so.
    123125 fraction_done:: The last fraction done reported by the main app.
    124126 cpu_time:: The current CPU time.
    125  status:: The BOINC status.  If the 'suspended' flag is set, the graphics app should stop changing its display, and simply display an "application suspended" message.
     127 status:: The BOINC status.  If the 'suspended' flag is set,
     128the graphics app should stop changing its display,
     129and instead display an "application suspended" message.
    126130
    127131Keep in mind that multiple instances of the graphics app may run simultaneously;
     
    200204== Displaying text ==
    201205
    202 Older versions of the BOINC graphics API library included functions for rendering ''texture fonts'' using font files of the form ''*.txf''.  These have been eliminated, and we have instead added support for displaying strings using !TrueType fonts in BOINC graphics applications.
     206BOINC supports the display of text using !TrueType fonts.
     207
    203208 * Add the files `api/ttfont.cpp` and `api/ttfont.h` to your application (they are not included in any BOINC library.)
    204  * You will need to link with the [http://www.freetype.org FreeType2] and [http://sourceforge.net/projects/ftgl/files/FTGL%20Source/ FTGL] libraries.  Depending on how you build the FreeType2 library, FreeType2 may require the libz and libbz2 libraries.  For Windows, prebuilt libraries are available in the `boinc_depends_win_vs2005` repository.  To build these libraries on the Mac, please see MacBuild.
    205  * We have put copies of the free [https://fedorahosted.org/liberation-fonts Liberation fonts] in the `api/ttf/` directory.  If you wish to use other !TrueType fonts, you will need to adjust the list of font names in `ttfont.cpp`.  (Another source of free fonts is the [http://www.gnu.org/software/freefont GNU Freefont project].)
    206  * Download the desired !TrueType fonts to the client where they are available to your graphics application.
    207 
    208 For examples, please see the `clientscr/ss_app.cpp` and `samples/exampple_app/uc2_graphics.cpp` in the BOINC SVN trunk.
    209 
    210 If your graphics application currently uses the older ''texture fonts'', note that the ttf_load_fonts() and txf_render_string() APIs are slightly different from the old txf_load_fonts() and txf_render_string() APIs, which have been eliminated.  Please see the `ttfont.cpp` and `ttfont.h` files for details.
     209 * Link with the [http://www.freetype.org FreeType2]
     210  and [http://sourceforge.net/projects/ftgl/files/FTGL%20Source/ FTGL] libraries.
     211  Depending on how you build the FreeType2 library, FreeType2 may require the libz and libbz2 libraries.
     212  For Windows, prebuilt libraries are available in the `boinc_depends_win_vs2005` repository.
     213  To build these libraries on the Mac, please see MacBuild.
     214 * Include the desired !TrueType fonts in your [AppVersionNew  app versions].
     215  The set of free [https://fedorahosted.org/liberation-fonts Liberation fonts] in included the `api/ttf/` directory.
     216  If you wish to use other !TrueType fonts,
     217  you'll need to adjust the list of font names in `ttfont.cpp`.
     218  (Another source of free fonts is the [http://www.gnu.org/software/freefont GNU Freefont project].)
     219 * To display text, use the following API functions:
     220{{{
     221float white[4] = {1., 1., 1., 1.};
     222APP_INIT_DATA aid;
     223boinc_get_init_data(aid);
     224
     225// read font files; they're in the project directory
     226//
     227ttf_load_fonts(aid.project_dir);
     228...
     229ttf_render_string(
     230   x, y, z,            // where to display string
     231   500,                // size
     232   white,              // color
     233   "App suspended"     // the text
     234   0,                  // which font (see ttfont.cpp)
     235                       // default is Sans-Regular (0)
     236);
     237
     238}}}
     239
     240Other parameters to '''ttf_render_string()''' let you specify rotation; see ttfont.h.
     241For examples, see the `clientscr/ss_app.cpp` and `samples/exampple_app/uc2_graphics.cpp` in the BOINC trunk.