Changeset 1351


Ignore:
Timestamp:
Mar 20, 2009 7:36:52 PM (15 years ago)
Author:
gah
Message:

my first cut at flowvisviewer client based on work by dsk

Location:
trunk/packages/vizservers
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/configure

    r1309 r1351  
    65096509
    65106510
     6511oldLIBS=$LIBS
     6512LIBS=-lavcodec
     6513
     6514for ac_func in img_convert
     6515do
     6516as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
     6517{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
     6518$as_echo_n "checking for $ac_func... " >&6; }
     6519if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
     6520  $as_echo_n "(cached) " >&6
     6521else
     6522  cat >conftest.$ac_ext <<_ACEOF
     6523/* confdefs.h.  */
     6524_ACEOF
     6525cat confdefs.h >>conftest.$ac_ext
     6526cat >>conftest.$ac_ext <<_ACEOF
     6527/* end confdefs.h.  */
     6528/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
     6529   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
     6530#define $ac_func innocuous_$ac_func
     6531
     6532/* System header to define __stub macros and hopefully few prototypes,
     6533    which can conflict with char $ac_func (); below.
     6534    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
     6535    <limits.h> exists even on freestanding compilers.  */
     6536
     6537#ifdef __STDC__
     6538# include <limits.h>
     6539#else
     6540# include <assert.h>
     6541#endif
     6542
     6543#undef $ac_func
     6544
     6545/* Override any GCC internal prototype to avoid an error.
     6546   Use char because int might match the return type of a GCC
     6547   builtin and then its argument prototype would still apply.  */
     6548#ifdef __cplusplus
     6549extern "C"
     6550#endif
     6551char $ac_func ();
     6552/* The GNU C library defines this for functions which it implements
     6553    to always fail with ENOSYS.  Some functions are actually named
     6554    something starting with __ and the normal name is an alias.  */
     6555#if defined __stub_$ac_func || defined __stub___$ac_func
     6556choke me
     6557#endif
     6558
     6559int
     6560main ()
     6561{
     6562return $ac_func ();
     6563  ;
     6564  return 0;
     6565}
     6566_ACEOF
     6567rm -f conftest.$ac_objext conftest$ac_exeext
     6568if { (ac_try="$ac_link"
     6569case "(($ac_try" in
     6570  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
     6571  *) ac_try_echo=$ac_try;;
     6572esac
     6573eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
     6574$as_echo "$ac_try_echo") >&5
     6575  (eval "$ac_link") 2>conftest.er1
     6576  ac_status=$?
     6577  grep -v '^ *+' conftest.er1 >conftest.err
     6578  rm -f conftest.er1
     6579  cat conftest.err >&5
     6580  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6581  (exit $ac_status); } && {
     6582         test -z "$ac_cxx_werror_flag" ||
     6583         test ! -s conftest.err
     6584       } && test -s conftest$ac_exeext && {
     6585         test "$cross_compiling" = yes ||
     6586         $as_test_x conftest$ac_exeext
     6587       }; then
     6588  eval "$as_ac_var=yes"
     6589else
     6590  $as_echo "$as_me: failed program was:" >&5
     6591sed 's/^/| /' conftest.$ac_ext >&5
     6592
     6593        eval "$as_ac_var=no"
     6594fi
     6595
     6596rm -rf conftest.dSYM
     6597rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
     6598      conftest$ac_exeext conftest.$ac_ext
     6599fi
     6600ac_res=`eval 'as_val=${'$as_ac_var'}
     6601                 $as_echo "$as_val"'`
     6602               { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
     6603$as_echo "$ac_res" >&6; }
     6604as_val=`eval 'as_val=${'$as_ac_var'}
     6605                 $as_echo "$as_val"'`
     6606   if test "x$as_val" = x""yes; then
     6607  cat >>confdefs.h <<_ACEOF
     6608#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
     6609_ACEOF
     6610
     6611fi
     6612done
     6613
     6614LIBS=$oldLIBS
     6615
    65116616{ $as_echo "$as_me:$LINENO: checking for nVidia Cg installation" >&5
    65126617$as_echo_n "checking for nVidia Cg installation... " >&6; }
  • trunk/packages/vizservers/configure.in

    r1309 r1351  
    186186AC_CHECK_HEADERS([ffmpeg/avcodec.h libavcodec/avcodec.h ffmpeg/avformat.h libavformat/avformat.h ffmpeg/avutil.h libavutil/avutil.h])
    187187
     188oldLIBS=$LIBS
     189LIBS=-lavcodec
     190AC_CHECK_FUNCS(img_convert)
     191LIBS=$oldLIBS
     192
    188193AC_MSG_CHECKING([for nVidia Cg installation])
    189194CG_DIR=""
  • trunk/packages/vizservers/nanoscale/config.h.in

    r1309 r1351  
    1515/* Define to 1 if you have the <ffmpeg/avutil.h> header file. */
    1616#undef HAVE_FFMPEG_AVUTIL_H
     17
     18/* Define to 1 if you have the `img_convert' function. */
     19#undef HAVE_IMG_CONVERT
    1720
    1821/* Define to 1 if you have the <inttypes.h> header file. */
  • trunk/packages/vizservers/nanovis/Command.cpp

    r1328 r1351  
    815815    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    816816#endif
    817     NanoVis::ppm_write("nv>print -bytes");
     817    NanoVis::ppm_write("nv>image -bytes %d -type print");
    818818    NanoVis::resize_offscreen_buffer(w, h);
    819819    return TCL_OK;
     
    18061806
    18071807static int
    1808 FlowCaptureOp(ClientData cdata, Tcl_Interp *interp, int objc,
    1809              Tcl_Obj *const *objv)
    1810 {
    1811     Rappture::Outcome result;
    1812     int total_frame_count;
    1813 
    1814     if (Tcl_GetIntFromObj(interp, objv[2], &total_frame_count) != TCL_OK) {
    1815         return TCL_ERROR;
    1816     }
     1808FlowVideoOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1809            Tcl_Obj *const *objv)
     1810{
     1811    int width, height;          // Resolution of video.
     1812    int numFrames;              // Total number of frames.
     1813    float frameRate;            // Frame rate of the video.
     1814    float bitRate;              // Bit rate of the vide.
     1815
     1816    if ((Tcl_GetIntFromObj(interp, objv[2], &width) != TCL_OK) ||
     1817        (Tcl_GetIntFromObj(interp, objv[3], &height) != TCL_OK) ||
     1818        (Tcl_GetIntFromObj(interp, objv[4], &numFrames) != TCL_OK) ||
     1819        (GetFloatFromObj(interp, objv[5], &frameRate) != TCL_OK) ||
     1820        (GetFloatFromObj(interp, objv[6], &bitRate) != TCL_OK)) {
     1821        return TCL_ERROR;
     1822    }
     1823    if ((width<0) || (width>SHRT_MAX) || (height<0) || (height>SHRT_MAX)) {
     1824        Tcl_AppendResult(interp, "bad dimensions for video", (char *)NULL);
     1825        return TCL_ERROR;
     1826    }
     1827    if ((frameRate < 0.0f) || (frameRate > 30.0f)) {
     1828        Tcl_AppendResult(interp, "bad frame rate \"", Tcl_GetString(objv[5]),
     1829                         "\"", (char *)NULL);
     1830        return TCL_ERROR;
     1831    }
     1832    if ((bitRate < 0.0f) || (frameRate > 30.0f)) {
     1833        Tcl_AppendResult(interp, "bad bit rate \"", Tcl_GetString(objv[6]),
     1834                         "\"", (char *)NULL);
     1835        return TCL_ERROR;
     1836    }
     1837       
    18171838    if (NanoVis::licRenderer) {
    18181839        NanoVis::licRenderer->activate();
     
    18221843    }
    18231844
     1845    // Save the old dimensions of the offscreen buffer.
     1846    int oldWidth, oldHeight;
     1847    oldWidth = NanoVis::win_width;
     1848    oldHeight = NanoVis::win_height;
     1849
     1850    if ((width != oldWidth) || (height != oldHeight)) {
     1851        // Resize to the requested size.
     1852        NanoVis::resize_offscreen_buffer(width, height);
     1853    }
     1854
    18241855    char fileName[128];
    18251856    sprintf(fileName,"/tmp/flow%d.mpeg", getpid());
    18261857
    1827 
    18281858    Trace("FLOW started\n");
    18291859
    1830     Rappture::AVTranslate movie(NanoVis::win_width, NanoVis::win_height);
     1860    Rappture::Outcome result;
     1861    Rappture::AVTranslate movie(width, height, frameRate, bitRate);
    18311862
    18321863    int pad = 0;
     
    18371868    movie.init(result, fileName);
    18381869
    1839     for (int frame_count = 0; frame_count < total_frame_count; frame_count++) {
    1840 
     1870    for (int i = 0; i < numFrames; i++) {
    18411871        // Generate the latest frame and send it back to the client
    18421872        if (NanoVis::licRenderer &&
     
    18541884        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    18551885
    1856         // this is done before bmp_write_to_file because bmp_write_to_file
     1886        // This is done before bmp_write_to_file because bmp_write_to_file
    18571887        // turns rgb data to bgr
    1858         movie.append(result, NanoVis::screen_buffer,pad);
     1888        movie.append(result, NanoVis::screen_buffer, pad);
    18591889        // NanoVis::bmp_write_to_file(frame_count, fileName);
    18601890    }
     
    18741904    Rappture::Buffer data;
    18751905    data.load(fileName);
    1876     char command[512];
    1877     sprintf(command,"nv>file -bytes %lu\n", (unsigned long)data.size());
    1878     NanoVis::sendDataToClient(command,data.bytes(), data.size());
    1879     if (remove(fileName) != 0) {
    1880         fprintf(stderr, "Error deleting flow movie file: %s\n", fileName);
    1881         fflush(stderr);
    1882     }
    1883 
     1906
     1907    // Build the command string for the client.
     1908    char command[200];
     1909    sprintf(command,"nv>image -bytes %lu -type movie\n",
     1910            (unsigned long)data.size());
     1911
     1912    NanoVis::sendDataToClient(command, data.bytes(), data.size());
     1913    if (unlink(fileName) != 0) {
     1914        Tcl_AppendResult(interp, "can't unlink temporary movie file \"",
     1915                fileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
     1916        return TCL_ERROR;
     1917    }
    18841918    return TCL_OK;
    18851919}
     
    19621996static Rappture::CmdSpec flowSliceOps[] = {
    19631997    {"position",  1, FlowSlicePositionOp, 5, 5, "axis value",},
    1964     {"visible",   1, FlowSliceVisibleOp,  5, 5, "bool axis",},
     1998    {"visible",   1, FlowSliceVisibleOp,  5, 5, "axis bool",},
    19651999};
    19662000static int nFlowSliceOps = NumCmdSpecs(flowSliceOps);
     
    19812015
    19822016static int
    1983 FlowParticleVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc,
     2017FlowParticlesVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc,
    19842018             Tcl_Obj *const *objv)
    19852019{
     
    19932027}
    19942028
    1995 static Rappture::CmdSpec flowParticleOps[] = {
    1996     {"visible",    1, FlowParticleVisibleOp,  4, 4, "on|off",},
     2029static Rappture::CmdSpec flowParticlesOps[] = {
     2030    {"visible",    1, FlowParticlesVisibleOp,  4, 4, "on|off",},
    19972031};
    1998 static int nFlowParticleOps = NumCmdSpecs(flowParticleOps);
    1999 
    2000 static int
    2001 FlowParticleOp(ClientData cdata, Tcl_Interp *interp, int objc,
     2032static int nFlowParticlesOps = NumCmdSpecs(flowParticlesOps);
     2033
     2034static int
     2035FlowParticlesOp(ClientData cdata, Tcl_Interp *interp, int objc,
    20022036             Tcl_Obj *const *objv)
    20032037{
    20042038    Tcl_ObjCmdProc *proc;
    20052039
    2006     proc = Rappture::GetOpFromObj(interp, nFlowParticleOps, flowParticleOps,
     2040    proc = Rappture::GetOpFromObj(interp, nFlowParticlesOps, flowParticlesOps,
    20072041                                  Rappture::CMDSPEC_ARG2, objc, objv, 0);
    20082042    if (proc == NULL) {
     
    20132047
    20142048static int
    2015 FlowPlayOp(ClientData cdata, Tcl_Interp *interp, int objc,
     2049FlowNextOp(ClientData cdata, Tcl_Interp *interp, int objc,
    20162050             Tcl_Obj *const *objv)
    20172051{
    2018     if (NanoVis::licRenderer &&
    2019         !NanoVis::licRenderer->isActivated()) {
     2052    if (!NanoVis::licRenderer->isActivated()) {
    20202053        NanoVis::licRenderer->activate();
    20212054    }
    2022     if (NanoVis::particleRenderer &&
    2023         !NanoVis::particleRenderer->isActivated()) {
     2055    if (!NanoVis::particleRenderer->isActivated()) {
    20242056        NanoVis::particleRenderer->activate();
    20252057    }
     
    20282060
    20292061    // Generate the latest frame and send it back to the client
    2030     if (NanoVis::licRenderer &&
    2031         NanoVis::licRenderer->isActivated()) {
     2062    if (NanoVis::licRenderer->isActivated()) {
    20322063        NanoVis::licRenderer->convolve();
    20332064    }
    2034     if (NanoVis::particleRenderer &&
    2035         NanoVis::particleRenderer->isActivated()) {
    2036         NanoVis::particleRenderer->advect();
    2037     }
     2065    NanoVis::particleRenderer->advect();
    20382066    NanoVis::offscreen_buffer_capture();  //enable offscreen render
    20392067    NanoVis::display();
    2040 
    20412068    NanoVis::read_screen();
     2069
    20422070    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    20432071
    20442072    // NanoVis::bmp_write_to_file(frame_count, fileName);
    2045 
    20462073    Trace("FLOW end\n");
    20472074    return TCL_OK;
     
    20862113
    20872114static Rappture::CmdSpec flowOps[] = {
    2088     {"capture",   1, FlowCaptureOp,       3, 3, "frames",},
    20892115    {"data",      1, FlowDataOp,          3, 0, "oper ?args?",},
    20902116    {"lic",       1, FlowLicOp,           3, 3, "on|off",},
    2091     {"particle",  2, FlowParticleOp,      3, 0, "oper ?args?",},
    2092     {"play",      2, FlowPlayOp,          2, 2, "",},
     2117    {"particles", 2, FlowParticlesOp,     3, 0, "oper ?args?",},
     2118    {"next",      2, FlowNextOp,          2, 2, "",},
    20932119    {"reset",     1, FlowResetOp,         2, 2, "",},
    20942120    {"slice",     1, FlowSliceOp,         3, 0, "oper ?args?",},
    2095     {"vectorid",  1, FlowVectorIdOp,      3, 3, "index",},
     2121    {"vectorid",  2, FlowVectorIdOp,      3, 3, "index",},
     2122    {"video",     2, FlowVideoOp,         7, 7,
     2123        "width height numFrames frameRate bitRate ",},
    20962124};
    20972125static int nFlowOps = NumCmdSpecs(flowOps);
     
    21032131 *   flow capture frames filename
    21042132 *   flow lic on|off
    2105  *   flow particle visible on|off
    2106  *   flow particle slice <volumeId>
    2107  *   flow particle slicepos <value>
    2108  *   flow play
     2133 *   flow particles visible on|off
     2134 *   flow slice visible axis on|off
     2135 *   flow slice position axis value
     2136 *   flow next
    21092137 *   flow reset
    21102138 *   flow vectorid <volumeId>
  • trunk/packages/vizservers/nanovis/Makefile.in

    r1310 r1351  
    3636DX_INC_SPEC     = -I$(DX_DIR)/include
    3737DX_LIB_SPEC     = -L$(DX_DIR)/lib_linux -lDXcallm
    38 FF_LIB_SPEC     = -lavformat -lavcodec
     38FF_LIB_SPEC     = -lavformat -lavcodec -lavutil
    3939# might also need -lavutil
    4040GL_INC_SPEC     = -I/usr/include/GL
     
    7171                $(RP_LIB_SPEC) \
    7272                $(DX_LIB_SPEC) \
    73                 $(FF_LIB_SPEC) \
    7473                $(IMG_LIB_SPEC) \
    7574                $(R2_LIB_SPEC) \
     
    7978                $(CG_LIB_SPEC) \
    8079                $(GL_LIB_SPEC) \
     80                $(FF_LIB_SPEC) \
    8181                $(EXTRA_LIBS) \
    8282                -Wl,-rpath,$(LD_RUN_PATH)
  • trunk/packages/vizservers/nanovis/RpAVTranslate.cpp

    r1338 r1351  
    1313 */
    1414
    15 #include "RpAVTranslate.h"
     15
     16#include "nvconf.h"
    1617
    1718#include <cstdlib>
     
    1920#include <cstring>
    2021#include <cmath>
    21 
    2222#include <fstream>
    2323#include <assert.h>
     24
     25extern "C" {
     26#ifdef HAVE_FFMPEG_MEM_H
     27#include <ffmpeg/mem.h>
     28#endif
     29#ifdef HAVE_LIBAVUTIL_MEM_H
     30#include <libavutil/mem.h>
     31#endif
     32}
     33
     34#include "RpAVTranslate.h"
    2435
    2536#ifndef M_PI
     
    2940using namespace Rappture;
    3041
    31 extern int img_convert(AVPicture *dst, int dst_pix_fmt,
    32                 const AVPicture *src, int src_pix_fmt,
    33                 int src_width, int src_height);
    34 
    35 AVTranslate::AVTranslate(size_t width, size_t height )
     42AVTranslate::AVTranslate(size_t width, size_t height) :
     43    _width (width),
     44    _height (height),
     45    _bitRate(400000),
     46    _frameRate(25.0f),
     47    _videoOutbufSize(200000),
     48    _videoOutbuf(NULL),
     49    _fmtPtr(NULL),
     50    _ocPtr(NULL),
     51    _avStreamPtr(NULL),
     52    _pictPtr(NULL),
     53    _rgbPictPtr(NULL)
     54{
     55}
     56
     57AVTranslate::AVTranslate(size_t width, size_t height, size_t bitRate,
     58                         float frameRate)
    3659  : _width (width),
    3760    _height (height),
    38     _bit_rate(400000),
    39     _stream_frame_rate(25),
    40     _video_outbuf_size (200000),
    41     _video_outbuf (NULL),
    42     _fmt (NULL),
    43     _oc (NULL),
    44     _video_st (NULL),
    45     _picture(NULL),
    46     _rgb_picture(NULL)
    47 {}
    48 
    49 AVTranslate::AVTranslate(size_t width, size_t height, size_t bit_rate,
    50                          double frame_rate)
    51   : _width (width),
    52     _height (height),
    53     _bit_rate(bit_rate),
    54     _stream_frame_rate(frame_rate),
    55     _video_outbuf_size (200000),
    56     _video_outbuf (NULL),
    57     _fmt (NULL),
    58     _oc (NULL),
    59     _video_st (NULL),
    60     _picture(NULL),
    61     _rgb_picture(NULL)
    62 {}
     61    _bitRate(bitRate),
     62    _frameRate(frameRate),
     63    _videoOutbufSize(200000),
     64    _videoOutbuf(NULL),
     65    _fmtPtr(NULL),
     66    _ocPtr(NULL),
     67    _avStreamPtr(NULL),
     68    _pictPtr(NULL),
     69    _rgbPictPtr(NULL)
     70{
     71}
    6372
    6473/**
     
    8493AVTranslate::init(Outcome &status, const char *filename)
    8594{
     95    status.addContext("Rappture::AVTranslate::init()");
    8696    /* initialize libavcodec, and register all codecs and formats */
    8797    av_register_all();
     
    8999    /* auto detect the output format from the name. default is
    90100       mpeg. */
    91     _fmt = guess_format(NULL, filename, NULL);
    92     if (_fmt == NULL) {
     101    _fmtPtr = guess_format(NULL, filename, NULL);
     102    if (_fmtPtr == NULL) {
    93103        /*
    94104        printf(  "Could not deduce output format from"
    95105                 "file extension: using MPEG.\n");
    96106        */
    97         _fmt = guess_format("mpeg", NULL, NULL);
    98     }
    99     if (_fmt == NULL) {
     107        _fmtPtr = guess_format("mpeg", NULL, NULL);
     108    }
     109    if (_fmtPtr == NULL) {
    100110        status.addError("Could not find suitable output format");
    101         status.addContext("Rappture::AVTranslate::init()");
    102         return false;
    103     }
    104 
     111        return false;
     112    }
     113
     114#ifdef notdef
    105115    /* allocate the output media context */
    106     _oc = av_alloc_format_context();
    107     if (!_oc) {
     116    _ocPtr = av_alloc_format_context();
     117#else
     118    _ocPtr = avformat_alloc_context();
     119#endif
     120    if (!_ocPtr) {
    108121        status.addError("Memory error while allocating format context");
    109122        return false;
    110123    }
    111     _oc->oformat = _fmt;
    112     snprintf(_oc->filename, sizeof(_oc->filename), "%s", filename);
     124    _ocPtr->oformat = _fmtPtr;
     125    snprintf(_ocPtr->filename, sizeof(_ocPtr->filename), "%s", filename);
    113126
    114127    /* add the video stream using the default format codecs
    115128       and initialize the codecs */
    116     _video_st = NULL;
    117     if (_fmt->video_codec != CODEC_ID_NONE) {
    118         if ( (!addVideoStream(status, _fmt->video_codec,&_video_st)) ) {
    119             status.addContext("Rappture::AVTranslate::init()");
     129    _avStreamPtr = NULL;
     130    if (_fmtPtr->video_codec != CODEC_ID_NONE) {
     131        if ( (!addVideoStream(status, _fmtPtr->video_codec,&_avStreamPtr)) ) {
    120132            return false;
    121133        }
     
    124136    /* set the output parameters (must be done even if no
    125137       parameters). */
    126     if (av_set_parameters(_oc, NULL) < 0) {
     138    if (av_set_parameters(_ocPtr, NULL) < 0) {
    127139        status.addError("Invalid output format parameters");
    128         status.addContext("Rappture::AVTranslate::init()");
    129         return false;
    130     }
    131 
    132     dump_format(_oc, 0, filename, 1);
     140        return false;
     141    }
     142
     143    dump_format(_ocPtr, 0, filename, 1);
    133144
    134145    /* now that all the parameters are set, we can open the
    135146       video codec and allocate the necessary encode buffers */
    136     if (_video_st) {
     147    if (_avStreamPtr) {
    137148        if (!openVideo(status)) {
    138             status.addContext("Rappture::AVTranslate::init()");
    139149            return false;
    140150        }
     
    142152
    143153    /* open the output file, if needed */
    144     if (!(_fmt->flags & AVFMT_NOFILE)) {
    145         if (url_fopen(&_oc->pb, filename, URL_WRONLY) < 0) {
     154    if (!(_fmtPtr->flags & AVFMT_NOFILE)) {
     155        if (url_fopen(&_ocPtr->pb, filename, URL_WRONLY) < 0) {
    146156            status.addError("Could not open '%s'", filename);
    147             status.addContext("Rappture::AVTranslate::init()");
    148157            return false;
    149158        }
     
    151160
    152161    /* write the stream header, if any */
    153     av_write_header(_oc);
    154     return true;
    155 }
    156 
    157 bool
    158 AVTranslate::append(Outcome &status, uint8_t *rgb_data, size_t line_pad)
    159 {
    160 
    161     if (rgb_data == NULL) {
    162         status.addError("rdb_data pointer is NULL");
    163         status.addContext("Rappture::AVTranslate::append()");
    164         return false;
    165     }
    166 
    167     uint8_t *pdatat = _rgb_picture->data[0];
    168     uint8_t *rgbcurr = rgb_data;
    169 
     162    av_write_header(_ocPtr);
     163    return true;
     164}
     165
     166bool
     167AVTranslate::append(Outcome &status, uint8_t *rgbData, size_t linePad)
     168{
     169    status.addContext("Rappture::AVTranslate::append()");
     170    if (rgbData == NULL) {
     171        status.addError("rdbData pointer is NULL");
     172        return false;
     173    }
     174
     175    uint8_t *destPtr = _rgbPictPtr->data[0];
     176    uint8_t *srcPtr = rgbData;
    170177    for (size_t y = 0; y < _height; y++) {
    171178        for (size_t x = 0; x < _width; x++) {
    172             pdatat[0] = rgbcurr[0];
    173             pdatat[1] = rgbcurr[1];
    174             pdatat[2] = rgbcurr[2];
    175 
    176             rgbcurr += 3;
    177             pdatat +=3;
     179            destPtr[0] = srcPtr[0];
     180            destPtr[1] = srcPtr[1];
     181            destPtr[2] = srcPtr[2];
     182            srcPtr += 3;
     183            destPtr +=3;
    178184        }
    179         rgbcurr += line_pad;
    180     }
    181 
     185        srcPtr += linePad;
     186    }
     187
     188#ifdef HAVE_IMG_CONVERT
    182189    // use img_convert instead of sws_scale because img_convert
    183190    // is lgpl nad sws_scale is gpl
    184     img_convert((AVPicture *)_picture, PIX_FMT_YUV420P,
    185                 (AVPicture *)_rgb_picture, PIX_FMT_RGB24,
     191    img_convert((AVPicture *)_pictPtr, PIX_FMT_YUV420P,
     192                (AVPicture *)_rgbPictPtr, PIX_FMT_RGB24,
    186193                _width, _height);
     194#endif  /*HAVE_IMG_CONVERT*/
    187195    writeVideoFrame(status);
    188196
     
    197205
    198206    /* close each codec */
    199     if (_video_st) {
     207    if (_avStreamPtr) {
    200208        closeVideo(status);
    201209    }
    202210
    203211    /* write the trailer, if any */
    204     av_write_trailer(_oc);
     212    av_write_trailer(_ocPtr);
    205213
    206214    /* free the streams */
    207     for(i = 0; i < _oc->nb_streams; i++) {
    208         av_freep(&_oc->streams[i]->codec);
    209         // _oc->streams[i]->codec = NULL;
    210 
    211         av_freep(&_oc->streams[i]);
    212         // _oc->streams[i] = NULL;
    213     }
    214 
    215     if (!(_fmt->flags & AVFMT_NOFILE)) {
     215    for(i = 0; i < _ocPtr->nb_streams; i++) {
     216        av_freep(&_ocPtr->streams[i]->codec);
     217        // _ocPtr->streams[i]->codec = NULL;
     218
     219        av_freep(&_ocPtr->streams[i]);
     220        // _ocPtr->streams[i] = NULL;
     221    }
     222
     223    if (!(_fmtPtr->flags & AVFMT_NOFILE)) {
    216224        /* close the output file */
    217         url_fclose(_oc->pb);
     225        url_fclose(_ocPtr->pb);
    218226    }
    219227
    220228    /* free the stream */
    221     av_free(_oc);
    222     _oc = NULL;
     229    av_free(_ocPtr);
     230    _ocPtr = NULL;
    223231    return true;
    224232}
     
    227235/* add a video output stream */
    228236bool
    229 AVTranslate::addVideoStream(Outcome &status, CodecID codec_id, AVStream **st)
    230 {
    231     AVCodecContext *c;
    232     // AVStream *st;
    233 
    234     if (!st) {
     237AVTranslate::addVideoStream(Outcome &status, CodecID codec_id,
     238                            AVStream **streamPtrPtr)
     239{
     240    status.addContext("Rappture::AVTranslate::add_video_stream()");
     241    if (streamPtrPtr == NULL) {
    235242        status.addError("AVStream **st is NULL");
    236         status.addContext("Rappture::AVTranslate::add_video_stream()");
    237         return false;
    238     }
    239 
    240     *st = av_new_stream(_oc, 0);
    241     if (!(*st)) {
     243        return false;
     244    }
     245
     246    AVStream *streamPtr;
     247    streamPtr = av_new_stream(_ocPtr, 0);
     248    if (streamPtr == NULL) {
    242249        status.addError("Could not alloc stream");
    243         status.addContext("Rappture::AVTranslate::add_video_stream()");
    244         return false;
    245     }
    246 
    247     c = (*st)->codec;
    248     c->codec_id = codec_id;
    249     c->codec_type = CODEC_TYPE_VIDEO;
     250        return false;
     251    }
     252
     253    AVCodecContext *codecPtr;
     254    codecPtr = streamPtr->codec;
     255    codecPtr->codec_id = codec_id;
     256    codecPtr->codec_type = CODEC_TYPE_VIDEO;
    250257
    251258    /* put sample parameters */
    252     c->bit_rate = _bit_rate;
     259    codecPtr->bit_rate = _bitRate;
    253260    /* resolution must be a multiple of two */
    254     c->width = _width;
    255     c->height = _height;
     261    codecPtr->width = _width;
     262    codecPtr->height = _height;
    256263    /* time base: this is the fundamental unit of time (in seconds) in terms
    257264       of which frame timestamps are represented. for fixed-fps content,
    258265       timebase should be 1/framerate and timestamp increments should be
    259266       identically 1. */
    260     c->time_base.den = _stream_frame_rate;
    261     c->time_base.num = 1;
    262     c->gop_size = 12; /* emit one intra frame every twelve frames at most */
    263     c->pix_fmt = PIX_FMT_YUV420P;
    264     if (c->codec_id == CODEC_ID_MPEG2VIDEO) {
     267    codecPtr->time_base.den = _frameRate;
     268    codecPtr->time_base.num = 1;
     269    codecPtr->gop_size = 12;    /* emit one intra frame every twelve frames at
     270                                 * most */
     271    codecPtr->pix_fmt = PIX_FMT_YUV420P;
     272    if (codecPtr->codec_id == CODEC_ID_MPEG2VIDEO) {
    265273        /* just for testing, we also add B frames */
    266         c->max_b_frames = 2;
    267     }
    268     if (c->codec_id == CODEC_ID_MPEG1VIDEO) {
     274        codecPtr->max_b_frames = 2;
     275    }
     276    if (codecPtr->codec_id == CODEC_ID_MPEG1VIDEO) {
    269277        /* Needed to avoid using macroblocks in which some coeffs overflow.
    270278           This does not happen with normal video, it just happens here as
    271279           the motion of the chroma plane does not match the luma plane. */
    272         c->mb_decision=2;
     280        codecPtr->mb_decision=2;
    273281    }
    274282    // some formats want stream headers to be separate
    275     if(    !strcmp(_oc->oformat->name, "mp4")
    276         || !strcmp(_oc->oformat->name, "mov")
    277         || !strcmp(_oc->oformat->name, "3gp")) {
    278         c->flags |= CODEC_FLAG_GLOBAL_HEADER;
    279     }
    280 
    281     return true;
    282 }
    283 
    284 bool
    285 AVTranslate::allocPicture(Outcome &status, int pix_fmt, AVFrame **p)
    286 {
    287     // AVFrame *p = NULL;
    288     uint8_t *p_buf = NULL;
    289     int size = 0;
    290 
    291     if (p == NULL) {
     283    if((strcmp(_ocPtr->oformat->name, "mp4") == 0) ||
     284       (strcmp(_ocPtr->oformat->name, "mov") == 0) ||
     285       (strcmp(_ocPtr->oformat->name, "3gp") == 0)) {
     286        codecPtr->flags |= CODEC_FLAG_GLOBAL_HEADER;
     287    }
     288    *streamPtrPtr = streamPtr;
     289    return true;
     290}
     291
     292bool
     293AVTranslate::allocPicture(Outcome &status, int pixFmt, AVFrame **framePtrPtr)
     294{
     295    status.addContext("Rappture::AVTranslate::allocPicture()");
     296    if (framePtrPtr == NULL) {
    292297        status.addError("AVFrame **p == NULL");
    293         status.addContext("Rappture::AVTranslate::allocPicture()");
    294         return false;
    295     }
    296 
    297     *p = avcodec_alloc_frame();
    298     if (*p == NULL) {
     298        return false;
     299    }
     300
     301    AVFrame *framePtr;
     302    framePtr = avcodec_alloc_frame();
     303    if (framePtr == NULL) {
    299304        status.addError("Memory error: Could not alloc frame");
    300         status.addContext("Rappture::AVTranslate::allocPicture()");
    301         return false;
    302     }
    303     size = avpicture_get_size(pix_fmt, _width, _height);
    304     p_buf = (uint8_t *) av_malloc(size);
    305     if (!p_buf) {
    306         av_free(*p);
    307         *p = NULL;
     305        return false;
     306    }
     307
     308    size_t size;
     309    size = avpicture_get_size(pixFmt, _width, _height);
     310
     311    uint8_t *bits;
     312    bits = (uint8_t *)av_malloc(size);
     313    if (bits == NULL) {
     314        av_free(framePtr);
    308315        status.addError("Memory error: Could not alloc picture buffer");
    309         status.addContext("Rappture::AVTranslate::allocPicture()");
    310         return false;
    311     }
    312     avpicture_fill((AVPicture *)(*p), p_buf, pix_fmt, _width, _height);
     316        return false;
     317    }
     318    avpicture_fill((AVPicture *)framePtr, bits, pixFmt, _width, _height);
     319    *framePtrPtr = framePtr;
    313320    return true;
    314321}
     
    320327    AVCodecContext *c;
    321328
    322     c = _video_st->codec;
     329    status.addContext("Rappture::AVTranslate::openVideo()");
     330    c = _avStreamPtr->codec;
    323331
    324332    /* find the video encoder */
     
    326334    if (!codec) {
    327335        status.addError("codec not found");
    328         status.addContext("Rappture::AVTranslate::open_video()");
    329336        return false;
    330337    }
     
    333340    if (avcodec_open(c, codec) < 0) {
    334341        status.addError("could not open codec");
    335         status.addContext("Rappture::AVTranslate::open_video()");
    336         return false;
    337     }
    338 
    339     _video_outbuf = NULL;
    340     if (!(_oc->oformat->flags & AVFMT_RAWPICTURE)) {
     342        return false;
     343    }
     344
     345    _videoOutbuf = NULL;
     346    if (!(_ocPtr->oformat->flags & AVFMT_RAWPICTURE)) {
    341347        /* allocate output buffer */
    342348        /* XXX: API change will be done */
     
    345351           they're freed appropriately (such as using av_free for buffers
    346352           allocated with av_malloc) */
    347         _video_outbuf = (uint8_t *) av_malloc(_video_outbuf_size);
    348     }
    349 
    350     /* allocate the encoded raw picture */
    351     if (!allocPicture(status, c->pix_fmt,&_picture)) {
    352         status.addContext("Rappture::AVTranslate::openVideo()");
    353         return false;
    354     }
    355 
    356     /*
    357     if (!picture) {
    358         status.addError("Could not allocate picture");
    359         status.addContext("Rappture::AVTranslate::openVideo()");
    360         return false;
    361     }
    362     */
    363 
    364     if (!allocPicture(status, PIX_FMT_RGB24,&_rgb_picture)) {
    365         status.addContext("Rappture::AVTranslate::openVideo()");
    366         return false;
    367     }
    368 
    369     /*
    370     if (!rgb_picture) {
    371         status.addError("Could not allocate temporary picture");
    372         status.addContext("Rappture::AVTranslate::open_video()");
    373         return false;
    374     }
    375     */
    376 
     353        _videoOutbuf = (uint8_t *) av_malloc(_videoOutbufSize);
     354    }
     355    /* Allocate the encoded raw picture */
     356    if (!allocPicture(status, c->pix_fmt, &_pictPtr)) {
     357        return false;
     358    }
     359    if (!allocPicture(status, PIX_FMT_RGB24, &_rgbPictPtr)) {
     360        status.addError("allocPicture: can't allocate picture");
     361        return false;
     362    }
    377363    return true;
    378364}
     
    381367AVTranslate::writeVideoFrame(Outcome &status)
    382368{
    383     int out_size, ret;
    384     AVCodecContext *c;
    385 
    386     c = _video_st->codec;
     369    AVCodecContext *codecPtr;
     370
     371    status.addContext("Rappture::AVTranslate::writeVideoframe()");
     372    codecPtr = _avStreamPtr->codec;
    387373
    388374    /* encode the image */
    389     out_size = avcodec_encode_video(c, _video_outbuf,
    390                                     _video_outbuf_size, _picture);
    391 
    392     /* if zero size, it means the image was buffered */
    393     if (out_size > 0) {
    394         AVPacket pkt;
    395         av_init_packet(&pkt);
    396 
    397         pkt.pts = av_rescale_q( c->coded_frame->pts,
    398                                 c->time_base,
    399                                 _video_st->time_base);
    400 
    401         if (c->coded_frame->key_frame) {
    402             pkt.flags |= PKT_FLAG_KEY;
    403         }
    404         pkt.stream_index = _video_st->index;
    405         pkt.data = _video_outbuf;
    406         pkt.size = out_size;
    407 
    408         /* write the compressed frame in the media file */
    409         ret = av_write_frame(_oc, &pkt);
    410     } else {
    411         ret = 0;
    412     }
    413 
    414     if (ret != 0) {
     375    int size;
     376    size = avcodec_encode_video(codecPtr, _videoOutbuf, _videoOutbufSize,
     377        _pictPtr);
     378    if (size < 0) {
    415379        status.addError("Error while writing video frame");
    416         status.addContext("Rappture::AVTranslate::writeVideoframe()");
    417380        return false;
    418381    }
     382    if (size == 0) {
     383        return true;            /* Image was buffered */
     384    }
     385    AVPacket pkt;
     386    av_init_packet(&pkt);
     387
     388    pkt.pts = av_rescale_q(codecPtr->coded_frame->pts, codecPtr->time_base,
     389                           _avStreamPtr->time_base);
     390    if (codecPtr->coded_frame->key_frame) {
     391        pkt.flags |= PKT_FLAG_KEY;
     392    }
     393    pkt.stream_index = _avStreamPtr->index;
     394    pkt.data = _videoOutbuf;
     395    pkt.size = size;
     396   
     397    /* write the compressed frame i the media file */
     398    if (av_write_frame(_ocPtr, &pkt) < 0) {
     399        status.addError("Error while writing video frame");
     400        return false;
     401    }
    419402    return true;
    420403}
     
    424407AVTranslate::closeVideo(Outcome &status)
    425408{
    426     avcodec_close(_video_st->codec);
    427 
    428     av_free(_picture->data[0]);
    429     _picture->data[0] = NULL;
    430 
    431     av_free(_picture);
    432     _picture = NULL;
    433 
    434     av_free(_rgb_picture->data[0]);
    435     _rgb_picture->data[0] = NULL;
    436 
    437     av_free(_rgb_picture);
    438     _rgb_picture = NULL;
    439 
    440     av_free(_video_outbuf);
    441     _video_outbuf = NULL;
     409    if (_avStreamPtr != NULL) {
     410        avcodec_close(_avStreamPtr->codec);
     411    }
     412    if (_pictPtr != NULL) {
     413        av_free(_pictPtr->data[0]);
     414        av_free(_pictPtr);
     415        _pictPtr = NULL;
     416    }
     417    if (_rgbPictPtr != NULL) {
     418        av_free(_rgbPictPtr->data[0]);
     419        av_free(_rgbPictPtr);
     420        _rgbPictPtr = NULL;
     421    }
     422    if (_videoOutbuf != NULL) {
     423        av_free(_videoOutbuf);
     424        _videoOutbuf = NULL;
     425    }
    442426    return true;
    443427}
  • trunk/packages/vizservers/nanovis/RpAVTranslate.h

    r1325 r1351  
    3535    AVTranslate(size_t width, size_t height);
    3636
    37     AVTranslate(size_t width, size_t height, size_t bit_rate,
    38                 double frame_rate);
     37    AVTranslate(size_t width, size_t height, size_t bitRate, float frameRate);
    3938
    4039    virtual ~AVTranslate();
    4140
    4241    bool init(Outcome &status, const char *filename );
    43     bool append(Outcome &status, uint8_t *rgb_data, size_t line_pad);
     42    bool append(Outcome &status, uint8_t *rgbData, size_t linePad);
    4443    bool done(Outcome &status);
    4544
    4645private:
    47     bool addVideoStream(Outcome &status, CodecID codec_id, AVStream **stream);
    48     bool allocPicture(Outcome &status, int pix_fmt, AVFrame **pic );
     46    bool addVideoStream(Outcome &status, CodecID codecId, AVStream **stream);
     47    bool allocPicture(Outcome &status, int pixFmt, AVFrame **pic );
    4948    bool openVideo(Outcome &status);
    5049    bool writeVideoFrame(Outcome &status);
     
    5352    size_t _width;
    5453    size_t _height;
    55     size_t _bit_rate;
    56     double _stream_frame_rate; // frames/seconds
    57     size_t _video_outbuf_size;
    58     uint8_t *_video_outbuf;
     54    size_t _bitRate;
     55    float _frameRate;           // frames/seconds
     56    size_t _videoOutbufSize;
     57    uint8_t *_videoOutbuf;
    5958
    60 
    61     AVOutputFormat *_fmt;
    62     AVFormatContext *_oc;
    63     AVStream *_video_st;
    64     AVFrame *_picture;
    65     AVFrame *_rgb_picture;
     59    size_t width(void) {
     60        return _width;
     61    }
     62    void width(size_t width) {
     63        _width = width;
     64    }
     65    size_t height(void) {
     66        return _width;
     67    }
     68    void height(size_t width) {
     69        _width = width;
     70    }
     71    size_t bitRate(void) {
     72        return _bitRate;
     73    }
     74    void bitRate(size_t bitRate) {
     75        _bitRate = bitRate;
     76    }
     77    float frameRate(void) {
     78        return _frameRate;
     79    }
     80    void frameRate(size_t frameRate) {
     81        _frameRate = frameRate;
     82    }
     83    AVOutputFormat *_fmtPtr;
     84    AVFormatContext *_ocPtr;
     85    AVStream *_avStreamPtr;
     86    AVFrame *_pictPtr, *_rgbPictPtr;
    6687
    6788};
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r1331 r1351  
    150150bool volume_mode = true;
    151151
    152 #ifdef notdef
    153 // color table for built-in transfer function editor
    154 float color_table[256][4];
    155 #endif
    156 
    157152// in Command.cpp
    158153extern Tcl_Interp *initTcl();
     
    412407    CGprogram program;
    413408    program = cgCreateProgramFromFile(context, CG_SOURCE, path, profile,
    414         entryPoint, NULL);
     409                                      entryPoint, NULL);
    415410    cgGLLoadProgram(program);
    416411
    417412    CGerror LastError = cgGetError();
    418413    if (LastError)
    419     {
    420        printf("Error message: %s\n", cgGetLastListing(context));
    421     }
     414        {
     415            printf("Error message: %s\n", cgGetLastListing(context));
     416        }
    422417
    423418    delete [] path;
     
    503498        if (vol->pointsetIndex != -1) {
    504499            if (((unsigned  int) vol->pointsetIndex) < pointSet.size() &&
    505         pointSet[vol->pointsetIndex] != NULL) {
     500                pointSet[vol->pointsetIndex] != NULL) {
    506501                delete pointSet[vol->pointsetIndex];
    507502                pointSet[vol->pointsetIndex] = 0;
     
    511506    }
    512507    volume[index] = new Volume(0.f, 0.f, 0.f, width, height, depth, 1.,
    513         n_component, data, vmin, vmax, nzero_min);
     508                               n_component, data, vmin, vmax, nzero_min);
    514509    return volume[index];
    515510}
     
    551546}
    552547
    553 #ifdef notdef
    554 //Update the transfer function using local GUI in the non-server mode
    555 void
    556 update_tf_texture()
    557 {
    558     glutSetWindow(NanoVis::render_window);
    559 
    560     //fprintf(stderr, "tf update\n");
    561     TransferFunction *tf = NanoVis::get_transfunc("default");
    562     if (tf == NULL) {
    563         return;
    564     }
    565 
    566     float data[256*4];
    567     for(int i=0; i<256; i++) {
    568         data[4*i+0] = color_table[i][0];
    569         data[4*i+1] = color_table[i][1];
    570         data[4*i+2] = color_table[i][2];
    571         data[4*i+3] = color_table[i][3];
    572         //fprintf(stderr, "(%f,%f,%f,%f) ", data[4*i+0], data[4*i+1], data[4*i+2], data[4*i+3]);
    573     }
    574 
    575     tf->update(data);
    576 
    577 #ifdef EVENTLOG
    578     float param[3] = {0,0,0};
    579     Event* tmp = new Event(EVENT_ROTATE, param, NvGetTimeInterval());
    580     tmp->write(event_log);
    581     delete tmp;
    582 #endif
    583 }
    584 #endif
    585 
    586548int
    587549NanoVis::render_legend(TransferFunction *tf, double min, double max,
    588                             int width, int height, const char* volArg)
     550                       int width, int height, const char* volArg)
    589551{
    590552    if (debug_flag) {
     
    660622    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, final_depth_rb);
    661623    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
    662             win_width, win_height);
     624                             win_width, win_height);
    663625    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
    664         GL_TEXTURE_2D, final_color_tex, 0);
     626                              GL_TEXTURE_2D, final_color_tex, 0);
    665627    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
    666         GL_RENDERBUFFER_EXT, final_depth_rb);
     628                                GL_RENDERBUFFER_EXT, final_depth_rb);
    667629
    668630    GLenum status;
     
    701663    //fprintf(stderr, "screen_buffer size: %d\n", sizeof(screen_buffer));
    702664    if (debug_flag) {
    703     fprintf(stderr, "screen_buffer size: %d %d\n", w, h);
     665        fprintf(stderr, "screen_buffer size: %d %d\n", w, h);
    704666    }
    705667   
     
    718680
    719681    if (debug_flag) {
    720     fprintf(stderr, "before deleteframebuffers\n");
     682        fprintf(stderr, "before deleteframebuffers\n");
    721683    }
    722684    glDeleteFramebuffersEXT(1, &final_fbo);
     
    750712    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, final_depth_rb);
    751713    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
    752         win_width, win_height);
     714                             win_width, win_height);
    753715    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
    754         GL_TEXTURE_2D, final_color_tex, 0);
     716                              GL_TEXTURE_2D, final_color_tex, 0);
    755717    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
    756         GL_RENDERBUFFER_EXT, final_depth_rb);
     718                                GL_RENDERBUFFER_EXT, final_depth_rb);
    757719   
    758720    GLenum status;
    759721    if (!CheckFBO(&status)) {
    760722        PrintFBOStatus(status, "final_fbo");
    761             DoExit(3);
     723        DoExit(3);
    762724    }
    763725
    764726    //CHECK_FRAMEBUFFER_STATUS();
    765727    if (debug_flag) {
    766     fprintf(stderr, "change camera\n");
     728        fprintf(stderr, "change camera\n");
    767729    }
    768730    //change the camera setting
     
    801763{
    802764    //random placement on a slice
    803     float* data = new float[particleRenderer->psys_width * particleRenderer->psys_height * 4];
    804     bzero(data, sizeof(float)*4* particleRenderer->psys_width * particleRenderer->psys_height);
     765    size_t n = particleRenderer->psys_width * particleRenderer->psys_height * 4;
     766    float* data = new float[n];
     767    memset(data, 0, sizeof(float)* n);
    805768
    806769    int index;
     
    822785                data[4*index+3]= rand() / ((float) RAND_MAX) * 0.5  + 0.5f; //shorter life span, quicker iterations
    823786            }
    824 /*
    825             else
    826             {
    827                 data[4*index] = 0;
    828                 data[4*index+1]= 0;
    829                 data[4*index+2]= 0;
    830                 data[4*index+3]= 0;
    831             }
    832 */
     787            /*
     788              else
     789              {
     790              data[4*index] = 0;
     791              data[4*index+1]= 0;
     792              data[4*index+2]= 0;
     793              data[4*index+3]= 0;
     794              }
     795            */
    833796        }
    834797    }
     
    912875NanoVis::initGL(void)
    913876{
    914    if (debug_flag) {
    915        fprintf(stderr, "in initGL\n");
    916    }
    917    //buffer to store data read from the screen
    918    if (screen_buffer) {
    919        delete[] screen_buffer;
    920        screen_buffer = NULL;
    921    }
    922    screen_buffer = new unsigned char[4*win_width*win_height];
    923    assert(screen_buffer != NULL);
    924 
    925    //create the camera with default setting
    926    cam = new NvCamera(0, 0, win_width, win_height,
    927                       def_eye_x, def_eye_y, def_eye_z,          /* location. */
    928                       def_target_x, def_target_y, def_target_z, /* target. */
    929                       def_rot_x, def_rot_y, def_rot_z);         /* angle. */
    930 
    931    glEnable(GL_TEXTURE_2D);
    932    glShadeModel(GL_FLAT);
    933    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    934 
    935    glClearColor(0,0,0,1);
    936    //glClearColor(0.7,0.7,0.7,1);
    937    glClear(GL_COLOR_BUFFER_BIT);
    938 
    939    //initialize lighting
    940    GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
    941    GLfloat mat_shininess[] = {30.0};
    942    GLfloat white_light[] = {1.0, 1.0, 1.0, 1.0};
    943    GLfloat green_light[] = {0.1, 0.5, 0.1, 1.0};
    944 
    945    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    946    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
    947    glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
    948    glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
    949    glLightfv(GL_LIGHT1, GL_DIFFUSE, green_light);
    950    glLightfv(GL_LIGHT1, GL_SPECULAR, white_light);
    951 
    952    // init table of transfer functions
    953    Tcl_InitHashTable(&tftable, TCL_STRING_KEYS);
    954 
    955    //check if performance query is supported
    956    if(check_query_support()){
    957      //create queries to count number of rendered pixels
    958      perf = new PerfQuery();
    959    }
    960 
    961    init_offscreen_buffer();    //frame buffer object for offscreen rendering
    962 
    963    //create volume renderer and add volumes to it
    964    vol_renderer = new VolumeRenderer();
    965 
    966    // create
    967    renderContext = new graphics::RenderContext();
     877    if (debug_flag) {
     878        fprintf(stderr, "in initGL\n");
     879    }
     880    //buffer to store data read from the screen
     881    if (screen_buffer) {
     882        delete[] screen_buffer;
     883        screen_buffer = NULL;
     884    }
     885    screen_buffer = new unsigned char[4*win_width*win_height];
     886    assert(screen_buffer != NULL);
     887
     888    //create the camera with default setting
     889    cam = new NvCamera(0, 0, win_width, win_height,
     890                       def_eye_x, def_eye_y, def_eye_z,          /* location. */
     891                       def_target_x, def_target_y, def_target_z, /* target. */
     892                       def_rot_x, def_rot_y, def_rot_z);         /* angle. */
     893
     894    glEnable(GL_TEXTURE_2D);
     895    glShadeModel(GL_FLAT);
     896    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     897
     898    glClearColor(0,0,0,1);
     899    //glClearColor(0.7,0.7,0.7,1);
     900    glClear(GL_COLOR_BUFFER_BIT);
     901
     902    //initialize lighting
     903    GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
     904    GLfloat mat_shininess[] = {30.0};
     905    GLfloat white_light[] = {1.0, 1.0, 1.0, 1.0};
     906    GLfloat green_light[] = {0.1, 0.5, 0.1, 1.0};
     907
     908    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
     909    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
     910    glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
     911    glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
     912    glLightfv(GL_LIGHT1, GL_DIFFUSE, green_light);
     913    glLightfv(GL_LIGHT1, GL_SPECULAR, white_light);
     914
     915    // init table of transfer functions
     916    Tcl_InitHashTable(&tftable, TCL_STRING_KEYS);
     917
     918    //check if performance query is supported
     919    if(check_query_support()){
     920        //create queries to count number of rendered pixels
     921        perf = new PerfQuery();
     922    }
     923
     924    init_offscreen_buffer();    //frame buffer object for offscreen rendering
     925
     926    //create volume renderer and add volumes to it
     927    vol_renderer = new VolumeRenderer();
     928
     929    // create
     930    renderContext = new graphics::RenderContext();
    968931   
    969    //create an 2D plane renderer
    970    plane_render = new PlaneRenderer(g_context, win_width, win_height);
     932    //create an 2D plane renderer
     933    plane_render = new PlaneRenderer(g_context, win_width, win_height);
    971934#if PROTOTYPE
    972    make_test_2D_data();
     935    make_test_2D_data();
    973936#endif  /* PROTOTYPE */
    974    plane_render->add_plane(plane[0], get_transfunc("default"));
    975 
    976    //assert(glGetError()==0);
    977 
    978 #ifdef notdef
    979    init_particle_system();
    980    NanoVis::init_lic();
    981 #endif
    982    if (debug_flag) {
    983        fprintf(stderr, "leaving initGL\n");
    984    }
     937    plane_render->add_plane(plane[0], get_transfunc("default"));
     938
     939    //assert(glGetError()==0);
     940
     941    if (debug_flag) {
     942        fprintf(stderr, "leaving initGL\n");
     943    }
    985944}
    986945
     
    12791238NanoVis::sendDataToClient(const char *command, const char *data, size_t dlen)
    12801239{
    1281 /*
    1282     char header[200];
    1283 
    1284     // Generate the PPM binary file header
    1285     sprintf(header, "P6 %d %d %d\n", win_width, win_height, PPM_MAXVAL);
    1286 
    1287     size_t header_length = strlen(header);
    1288     size_t data_length = win_width * win_height * 3;
    1289 
    1290     char command[200];
    1291     sprintf(command, "%s %lu\n", prefix,
    1292             (unsigned long)header_length + data_length);
    1293 */
    1294 
    1295 //    size_t wordsPerRow = (win_width * 24 + 31) / 32;
    1296 //    size_t bytesPerRow = wordsPerRow * 4;
    1297 //    size_t rowLength = win_width * 3;
     1240    /*
     1241      char header[200];
     1242
     1243      // Generate the PPM binary file header
     1244      sprintf(header, "P6 %d %d %d\n", win_width, win_height, PPM_MAXVAL);
     1245
     1246      size_t header_length = strlen(header);
     1247      size_t data_length = win_width * win_height * 3;
     1248
     1249      char command[200];
     1250      sprintf(command, "%s %lu\n", prefix,
     1251      (unsigned long)header_length + data_length);
     1252    */
     1253
     1254    //    size_t wordsPerRow = (win_width * 24 + 31) / 32;
     1255    //    size_t bytesPerRow = wordsPerRow * 4;
     1256    //    size_t rowLength = win_width * 3;
    12981257    size_t nRecs = 2;
    12991258
     
    13031262    // Write the nanovisviewer command, then the image header and data.
    13041263    // Command
    1305 // FIXME: shouldn't have to cast this
     1264    // FIXME: shouldn't have to cast this
    13061265    iov[0].iov_base = (char *)command;
    13071266    iov[0].iov_len = strlen(command);
    13081267    // Data
    1309 // FIXME: shouldn't have to cast this
     1268    // FIXME: shouldn't have to cast this
    13101269    iov[1].iov_base = (char *)data;
    13111270    iov[1].iov_len = dlen;
     
    13161275}
    13171276
    1318 #ifdef notdef
    1319 //draw vectors
    1320 void draw_arrows()
    1321 {
    1322     glColor4f(0.,0.,1.,1.);
    1323     for(int i=0; i<NMESH; i++){
    1324         for(int j=0; j<NMESH; j++){
    1325             Vector2 v = grid.get(i, j);
    1326 
    1327             int x1 = i*DM;
    1328             int y1 = j*DM;
    1329 
    1330             int x2 = x1 + v.x;
    1331             int y2 = y1 + v.y;
    1332 
    1333             glBegin(GL_LINES);
    1334             glVertex2d(x1, y1);
    1335             glVertex2d(x2, y2);
    1336             glEnd();
    1337         }
    1338     }
    1339 }
    1340 #endif
    1341 
    13421277
    13431278/*----------------------------------------------------*/
     
    13501285    glutSetWindow(render_window);
    13511286
    1352 #ifdef notdef
    1353     struct timespec ts;
    1354     ts.tv_sec = 0;
    1355     ts.tv_nsec = 300000000;
    1356     nanosleep(&ts, 0);
    1357 #endif
    13581287#ifdef XINETD
    13591288    xinetd_listen();
     
    13981327
    13991328
    1400 #ifdef notdef
    1401 
    1402 static int
    1403 particle_distance_sort(const void* a, const void* b)
    1404 {
    1405     if((*((Particle*)a)).aux > (*((Particle*)b)).aux) {
    1406         return -1;
    1407     } else {
    1408         return 1;
    1409     }
    1410 }
    1411 
    1412 void soft_read_verts()
    1413 {
    1414     glReadPixels(0, 0, psys->psys_width, psys->psys_height, GL_RGB, GL_FLOAT,
    1415          vert);
    1416     //fprintf(stderr, "soft_read_vert");
    1417 
    1418     //cpu sort the distance
    1419     Particle* p;
    1420     p = (Particle*)malloc(sizeof(Particle)*psys->psys_width*psys->psys_height);
    1421     for (int i=0; i<psys->psys_width * psys->psys_height; i++) {
    1422         float x = vert[3*i];
    1423         float y = vert[3*i+1];
    1424         float z = vert[3*i+2];
    1425         float dx, dy, dz;
    1426         dx = x - cam->x();
    1427         dy = y - cam->y();
    1428         dz = z - cam->z();
    1429         float dis = (dx * dx) + (dy * dy) + (dz * dz);
    1430         p[i].x = x;
    1431         p[i].y = y;
    1432         p[i].z = z;
    1433         p[i].aux = dis;
    1434     }
    1435 
    1436     qsort(p, psys->psys_width * psys->psys_height, sizeof(Particle), particle_distance_sort);
    1437 
    1438     for(int i=0; i<psys->psys_width * psys->psys_height; i++){
    1439         vert[3*i] = p[i].x;
    1440         vert[3*i+1] = p[i].y;
    1441         vert[3*i+2] = p[i].z;
    1442     }
    1443 
    1444     free(p);
    1445 }
    1446 #endif
    1447 
    1448 #ifdef notdef
    1449 //display the content of a texture as a screen aligned quad
    1450 void
    1451 display_texture(NVISid tex, int width, int height)
    1452 {
    1453     glPushMatrix();
    1454 
    1455     glEnable(GL_TEXTURE_2D);
    1456     glBindTexture(GL_TEXTURE_RECTANGLE_NV, tex);
    1457 
    1458     glViewport(0, 0, width, height);
    1459     glMatrixMode(GL_PROJECTION);
    1460     glLoadIdentity();
    1461     gluOrtho2D(0, width, 0, height);
    1462     glMatrixMode(GL_MODELVIEW);
    1463     glLoadIdentity();
    1464 
    1465     cgGLBindProgram(m_passthru_fprog);
    1466     cgGLEnableProfile(CG_PROFILE_FP30);
    1467 
    1468     cgGLSetParameter4f(m_passthru_scale_param, 1.0, 1.0, 1.0, 1.0);
    1469     cgGLSetParameter4f(m_passthru_bias_param, 0.0, 0.0, 0.0, 0.0);
    1470 
    1471     draw_quad(width, height, width, height);
    1472     cgGLDisableProfile(CG_PROFILE_FP30);
    1473 
    1474     glPopMatrix();
    1475 
    1476     //assert(glGetError()==0);
    1477 }
    1478 #endif
    1479 
    1480 
    1481 //draw vertices in the main memory
    1482 #ifdef notdef
    1483 void
    1484 soft_display_verts()
    1485 {
    1486     glDisable(GL_TEXTURE_2D);
    1487     glEnable(GL_BLEND);
    1488 
    1489     glPointSize(0.5);
    1490     glColor4f(0,0.8,0.8,0.6);
    1491     glBegin(GL_POINTS);
    1492     {
    1493         for(int i=0; i < psys->psys_width * psys->psys_height; i++){
    1494             glVertex3f(vert[3*i], vert[3*i+1], vert[3*i+2]);
    1495         }
    1496     }
    1497     glEnd();
    1498     //fprintf(stderr, "soft_display_vert");
    1499 }
    1500 #endif
    15011329
    15021330#if 0
     
    15341362                   float(ppass%pstage), float((pstage+pstage)-(ppass%pstage)-1));
    15351363    glUniform3fARB(oddevenMergeSort.getUniformLocation("Param2"),
    1536            float(psys_width), float(psys_height), float(ppass));
     1364                   float(psys_width), float(psys_height), float(ppass));
    15371365    glUniform1iARB(oddevenMergeSort.getUniformLocation("Data"), 0);
    15381366    staticdebugmsg("sort","stage "<<pstage<<" pass "<<ppass);
     
    16721500}
    16731501
    1674 #ifdef notdef
    1675 void
    1676 draw_axis()
    1677 {
    1678     glDisable(GL_TEXTURE_2D);
    1679     glEnable(GL_DEPTH_TEST);
    1680 
    1681     //red x
    1682     glColor3f(1,0,0);
    1683     glBegin(GL_LINES);
    1684     {
    1685         glVertex3f(0,0,0);
    1686         glVertex3f(1.5,0,0);
    1687     }
    1688     glEnd();
    1689 
    1690     //blue y
    1691     glColor3f(0,0,1);
    1692     glBegin(GL_LINES);
    1693     {
    1694         glVertex3f(0,0,0);
    1695         glVertex3f(0,1.5,0);
    1696     }
    1697     glEnd();
    1698 
    1699     //green z
    1700     glColor3f(0,1,0);
    1701     glBegin(GL_LINES);
    1702     {
    1703         glVertex3f(0,0,0);
    1704         glVertex3f(0,0,1.5);
    1705     }
    1706     glEnd();
    1707 
    1708     glEnable(GL_TEXTURE_2D);
    1709     glDisable(GL_DEPTH_TEST);
    1710 }
    1711 #endif
    1712 
    17131502void NanoVis::update()
    17141503{
     
    18921681    if (volume_mode) {
    18931682        if (debug_flag) {
    1894            fprintf(stderr, "in display: volume_mode\n");
     1683            fprintf(stderr, "in display: volume_mode\n");
    18951684        }
    18961685        //3D rendering mode
     
    19431732            grid->render();
    19441733        }
    1945         if (licRenderer && licRenderer->isActivated()) {
     1734        if ((licRenderer != NULL) && (licRenderer->isActivated())) {
    19461735            licRenderer->render();
    19471736        }
    1948         if (particleRenderer && particleRenderer->isActivated()) {
     1737        if ((particleRenderer != NULL) && (particleRenderer->isActivated())) {
    19491738            particleRenderer->render();
    19501739        }
     
    19601749
    19611750        if (debug_flag) {
    1962            fprintf(stderr, "in display: render heightmap\n");
     1751            fprintf(stderr, "in display: render heightmap\n");
    19631752        }
    19641753        for (unsigned int i = 0; i < heightMap.size(); ++i) {
     
    19681757        }
    19691758        glPopMatrix();
    1970    } else {
     1759    } else {
    19711760        //2D rendering mode
    19721761        perf->enable();
     
    20461835NanoVis::keyboard(unsigned char key, int x, int y)
    20471836{
    2048 /*
    2049    bool log = false;
    2050 
    2051    switch (key) {
    2052    case 'q':
    2053        DoExit(0);
    2054        break;
    2055    case '+':
    2056        lic_slice_z+=0.05;
    2057        licRenderer->set_offset(lic_slice_z);
    2058        break;
    2059    case '-':
    2060        lic_slice_z-=0.05;
    2061        licRenderer->set_offset(lic_slice_z);
    2062        break;
    2063    case ',':
    2064        lic_slice_x+=0.05;
    2065        //init_particles();
    2066        break;
    2067    case '.':
    2068        lic_slice_x-=0.05;
    2069        //init_particles();
    2070        break;
    2071    case '1':
    2072        //advect = true;
    2073        break;
    2074    case '2':
    2075        //psys_x+=0.05;
    2076        break;
    2077    case '3':
    2078        //psys_x-=0.05;
    2079        break;
    2080    case 'w': //zoom out
    2081        cam->z(cam->z() - 0.05);
    2082        log = true;
    2083        break;
    2084    case 's': //zoom in
    2085        cam->z(cam->z() + 0.05);
    2086        log = true;
    2087        break;
    2088    case 'a': //left
    2089        cam->x(cam->x() - 0.05);
    2090        log = true;
    2091        break;
    2092    case 'd': //right
    2093        cam->x(cam->x() + 0.05);
    2094        log = true;
    2095        break;
    2096    case 'i':
    2097        //init_particles();
    2098        break;
    2099    case 'v':
    2100        vol_renderer->switch_volume_mode();
    2101        break;
    2102    case 'b':
    2103        vol_renderer->switch_slice_mode();
    2104        break;
    2105    case 'n':
    2106        resize_offscreen_buffer(win_width*2, win_height*2);
    2107        break;
    2108    case 'm':
    2109        resize_offscreen_buffer(win_width/2, win_height/2);
    2110        break;
    2111    default:
    2112        break;
    2113    }
    2114 */
    21151837#ifdef EVENTLOG
    2116    if(log){
    2117        float param[3];
    2118        param[0] = cam->x();
    2119        param[1] = cam->y();
    2120        param[2] = cam->z();
    2121        Event* tmp = new Event(EVENT_MOVE, param, NvGetTimeInterval());
    2122        tmp->write(event_log);
    2123        delete tmp;
    2124    }
     1838    if(log){
     1839        float param[3];
     1840        param[0] = cam->x();
     1841        param[1] = cam->y();
     1842        param[2] = cam->z();
     1843        Event* tmp = new Event(EVENT_MOVE, param, NvGetTimeInterval());
     1844        tmp->write(event_log);
     1845        delete tmp;
     1846    }
    21251847#endif
    21261848}
     
    21711893#endif /*XINETD*/
    21721894
    2173 #ifdef notdef
    2174 
    2175 #ifdef XINETD
    2176 void
    2177 init_service()
    2178 {
    2179     if (!NanoVis::debug_flag) {
    2180         //open log and map stderr to log file
    2181         xinetd_log = fopen("/tmp/log.txt", "w");
    2182         close(2);
    2183         dup2(fileno(xinetd_log), 2);
    2184         dup2(2,1);
    2185     }
    2186     //flush junk
    2187     fflush(stdout);
    2188     fflush(stderr);
    2189 }
    2190 
    2191 void
    2192 end_service()
    2193 {
    2194     //close log file
    2195     fclose(xinetd_log);
    2196 }
    2197 #endif  /*XINETD*/
    2198 
    2199 void
    2200 init_event_log()
    2201 {
    2202     event_log = fopen("event.txt", "w");
    2203     assert(event_log!=0);
    2204 
    2205     struct timeval time;
    2206     gettimeofday(&time, NULL);
    2207     cur_time = time.tv_sec*1000. + time.tv_usec/1000.;
    2208 }
    2209 
    2210 void
    2211 end_event_log()
    2212 {
    2213     fclose(event_log);
    2214 }
    2215 
    2216 double
    2217 get_time_interval()
    2218 {
    2219     struct timeval time;
    2220     gettimeofday(&time, NULL);
    2221     double new_time = time.tv_sec*1000. + time.tv_usec/1000.;
    2222 
    2223     double interval = new_time - cur_time;
    2224     cur_time = new_time;
    2225     return interval;
    2226 }
    2227 #endif
    2228 
    22291895void
    22301896NanoVis::render()
    22311897{
    2232       if (NanoVis::licRenderer && NanoVis::licRenderer->isActivated())
    2233       {
    2234       NanoVis::licRenderer->convolve();
    2235       }
    2236 
    2237       if (NanoVis::particleRenderer && NanoVis::particleRenderer->isActivated())
    2238       {
    2239       NanoVis::particleRenderer->advect();
    2240       }
    2241 
    2242       NanoVis::update();
    2243 
    2244         display();
    2245         glutSwapBuffers();
    2246 
     1898    if ((NanoVis::licRenderer != NULL) &&
     1899        (NanoVis::licRenderer->isActivated())) {
     1900        NanoVis::licRenderer->convolve();
     1901    }
     1902
     1903    if ((NanoVis::particleRenderer != NULL) &&
     1904        (NanoVis::particleRenderer->isActivated())) {
     1905        NanoVis::particleRenderer->advect();
     1906    }
     1907
     1908    NanoVis::update();
     1909    display();
     1910    glutSwapBuffers();
    22471911}
    22481912
     
    22501914NanoVis::resize(int x, int y)
    22511915{
    2252         glViewport(0, 0, x, y);
     1916    glViewport(0, 0, x, y);
    22531917}
    22541918
     
    23642028        bmp_write_to_file(1, "/tmp");
    23652029    } else {
    2366         NanoVis::ppm_write("nv>image -bytes");
     2030        NanoVis::ppm_write("nv>image -type image -bytes");
    23672031    }
    23682032#endif
     
    24352099            if (optopt < 4) {
    24362100                fprintf(stderr, "argument missing for --%s option\n",
    2437                     long_options[optopt].name);
     2101                        long_options[optopt].name);
    24382102            } else {
    24392103                fprintf(stderr, "argument missing for -%c option\n", optopt);
     
    25362200    NanoVis::resize_offscreen_buffer(NanoVis::win_width, NanoVis::win_height);
    25372201
    2538 #ifndef XINETD
    2539 /*
    2540     CGprofile newProfile;
    2541     newProfile = cgGetProfile("fp30");
    2542     if (newProfile == CG_PROFILE_UNKNOWN)
    2543         printf("unknown profile\n");
    2544     else printf("fp30 know profile\n");
    2545 
    2546     int n = NanoVis::n_volumes;
    2547     std::ifstream fdata;
    2548     fdata.open("flow2d.dx", std::ios::in);
    2549     load_vector_stream(n, fdata);
    2550     Volume *volPtr = NanoVis::volume[n];
    2551 
    2552     if (volPtr != NULL) {
    2553         //volPtr->set_n_slice(256-n);
    2554         volPtr->set_n_slice(512-n);
    2555         volPtr->disable_cutplane(0);
    2556         volPtr->disable_cutplane(1);
    2557         volPtr->disable_cutplane(2);
    2558 
    2559         NanoVis::vol_renderer->add_volume(volPtr,
    2560                 NanoVis::get_transfunc("default"));
    2561     }
    2562 
    2563 
    2564     if (NanoVis::particleRenderer != NULL) {
    2565         NanoVis::particleRenderer->setVectorField(volPtr->id, 1.0f,
    2566             volPtr->height / (float)volPtr->width,
    2567             volPtr->depth  / (float)volPtr->width,
    2568             volPtr->wAxis.max());
    2569         NanoVis::initParticle();
    2570     }
    2571     if (NanoVis::licRenderer != NULL) {
    2572         NanoVis::licRenderer->setVectorField(volPtr->id,
    2573             1.0f / volPtr->aspect_ratio_width,
    2574             1.0f / volPtr->aspect_ratio_height,
    2575             1.0f / volPtr->aspect_ratio_depth,
    2576             volPtr->wAxis.max());
    2577         NanoVis::licRenderer->set_offset(NanoVis::lic_slice_z);
    2578         }
    2579 */
    2580 #endif
    25812202    glutMainLoop();
    2582 
    25832203    DoExit(0);
    25842204}
     
    25922212    resize_offscreen_buffer(width, height);
    25932213
    2594 /*
    2595     plane_render->set_screen_size(width, height);
    2596 
    2597     // generate data for the legend
    2598     float data[512];
    2599     for (int i=0; i < 256; i++) {
    2600         data[i] = data[i+256] = (float)(i/255.0);
    2601     }
    2602     plane[0] = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data);
    2603     int index = plane_render->add_plane(plane[0], tf);
    2604     plane_render->set_active_plane(index);
    2605 
    2606     offscreen_buffer_capture();
    2607     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
    2608 
    2609     //plane_render->render();
    2610     // INSOO : is going to implement here for the topview of the heightmap
    2611     heightmap->render(renderContext);
    2612 
    2613     // INSOO
    2614     glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);
    2615     //glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, screen_buffer); // INSOO's
    2616 */
     2214    /*
     2215      plane_render->set_screen_size(width, height);
     2216
     2217      // generate data for the legend
     2218      float data[512];
     2219      for (int i=0; i < 256; i++) {
     2220      data[i] = data[i+256] = (float)(i/255.0);
     2221      }
     2222      plane[0] = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data);
     2223      int index = plane_render->add_plane(plane[0], tf);
     2224      plane_render->set_active_plane(index);
     2225
     2226      offscreen_buffer_capture();
     2227      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
     2228
     2229      //plane_render->render();
     2230      // INSOO : is going to implement here for the topview of the heightmap
     2231      heightmap->render(renderContext);
     2232
     2233      // INSOO
     2234      glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);
     2235      //glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, screen_buffer); // INSOO's
     2236      */
    26172237
    26182238
     
    26292249    offscreen_buffer_capture();
    26302250    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
    2631         //glEnable(GL_TEXTURE_2D);
    2632         //glEnable(GL_DEPTH_TEST);
     2251    //glEnable(GL_TEXTURE_2D);
     2252    //glEnable(GL_DEPTH_TEST);
    26332253    //heightmap->render_topview(renderContext, width, height);
    26342254    //NanoVis::display();
  • trunk/packages/vizservers/pymolproxy/pymolproxy.c

    r1341 r1351  
    18401840    Tcl_CreateCommand(interp, "pan",           PanCmd,           &proxy, NULL);
    18411841    Tcl_CreateCommand(interp, "png",           PngCmd,           &proxy, NULL);
     1842    Tcl_CreateCommand(interp, "print",         PrintCmd,         &proxy, NULL);
    18421843    Tcl_CreateCommand(interp, "raw",           RawCmd,           &proxy, NULL);
    18431844    Tcl_CreateCommand(interp, "reset",         ResetCmd,         &proxy, NULL);
Note: See TracChangeset for help on using the changeset viewer.