Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /examples/vr-demo/main.c
ViewVC logotype

Diff of /examples/vr-demo/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5451, Mon Oct 23 04:20:24 2017 UTC revision 5452, Mon Oct 23 15:42:55 2017 UTC
# Line 8  Line 8 
8  /*  /*
9   * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)   * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
10   *   *
11   * COPYRIGHT (c) 2015 The University of Chicago   * COPYRIGHT (c) 2017 The University of Chicago
12   * All rights reserved.   * All rights reserved.
13   */   */
14    
# Line 93  Line 93 
93      GLuint      id;      GLuint      id;
94  } TexInfo_t;  } TexInfo_t;
95    
96  VR_World_t      *World;  VR_world_t      *World;
97  unsigned int    Width;          // view window width  unsigned int    Width;          // view window width
98  unsigned int    Height;         // view window height  unsigned int    Height;         // view window height
99  TexInfo_t       ReducedTexure = {       // Texture ID of reduced image  TexInfo_t       ReducedTexure = {       // Texture ID of reduced image
# Line 309  Line 309 
309      }      }
310  }  }
311    
312  void Compute (VR_World_t *wrld, bool fullSize, Nrrd *nRGB)  void Compute (VR_world_t *wrld, bool fullSize, Nrrd *nRGB)
313  {  {
314      printf ("computing %s... ", fullSize ? "" : "(fast) "); fflush(stdout);      printf ("computing %s... ", fullSize ? "" : "(fast) "); fflush(stdout);
315      double t0 = airTime();      double t0 = airTime();
316    // setup raycast parameters    // setup raycast parameters
317      if (fullSize) {      if (fullSize) {
318          VR_InVarSet_imgResU (wrld, FULL_WID);          VR_input_set_imgResU (wrld, FULL_WID);
319          VR_InVarSet_imgResV (wrld, FULL_HT);          VR_input_set_imgResV (wrld, FULL_HT);
320          VR_InVarSet_rayStep (wrld, FULL_STEP);          VR_input_set_rayStep (wrld, FULL_STEP);
321      }      }
322      else {      else {
323          VR_InVarSet_imgResU (wrld, REDUCED_WID);          VR_input_set_imgResU (wrld, REDUCED_WID);
324          VR_InVarSet_imgResV (wrld, REDUCED_HT);          VR_input_set_imgResV (wrld, REDUCED_HT);
325          VR_InVarSet_rayStep (wrld, REDUCED_STEP);          VR_input_set_rayStep (wrld, REDUCED_STEP);
326      }      }
327    // recompute    // recompute
328      if (VR_Initially (wrld)) {      if (VR_create_strands (wrld)) {
329        // error        // error
330          fprintf(stderr, "Error initializing world: %s", VR_GetErrors(wrld));          fprintf(stderr, "Error initializing world: %s", VR_get_errors(wrld));
331          exit(1);          exit(1);
332      }      }
333      int nSteps = VR_Run (wrld, 0);      int nSteps = VR_run (wrld, 0);
334      printf(" %d steps in %5.3f seconds\n", nSteps, airTime() - t0);      printf(" %d steps in %5.3f seconds\n", nSteps, airTime() - t0);
335    // get output image    // get output image
336      if (VR_OutputGet_outRGBA (wrld, nRGB)) {      if (VR_output_get_outRGBA (wrld, nRGB)) {
337        // error        // error
338          fprintf(stderr, "Error getting nrrd data: %s", VR_GetErrors(wrld));          fprintf(stderr, "Error getting nrrd data: %s", VR_get_errors(wrld));
339          exit(1);          exit(1);
340      }      }
341  }  }
# Line 377  Line 377 
377      glfwSetKeyCallback (win, KeyCB);      glfwSetKeyCallback (win, KeyCB);
378    
379    // initialize the Diderot program    // initialize the Diderot program
380      VR_World_t *wrld = VR_New ();      VR_world_t *wrld = VR_new_world ();
381      if (wrld == 0) {      if (wrld == 0) {
382          fprintf(stderr, "Cannot create world\n");          fprintf(stderr, "Cannot create world\n");
383          glfwTerminate();          glfwTerminate();
384          return 1;          return 1;
385      }      }
386      World = wrld;      World = wrld;
387      VR_Init (wrld);      VR_init_world (wrld);
388    
389    // initialize inputs    // initialize inputs
390      VR_InVarSet_valOpacMid (wrld, OpacMid);      VR_input_set_valOpacMid (wrld, OpacMid);
391      VR_InVarSetByName_hand (wrld, "data/vfrhand-nohip.nhdr");      VR_input_set_by_name_hand (wrld, "data/vfrhand-nohip.nhdr");
392    
393    // nrrd for getting computational state    // nrrd for getting computational state
394      Nrrd *nRGB = nrrdNew();      Nrrd *nRGB = nrrdNew();
# Line 402  Line 402 
402              float mid = OpacMid - OPAC_DELTA;              float mid = OpacMid - OPAC_DELTA;
403              if (mid >= MIN_OPAC_MID) {              if (mid >= MIN_OPAC_MID) {
404                  OpacMid = mid;                  OpacMid = mid;
405                  VR_InVarSet_valOpacMid(World, mid);                  VR_input_set_valOpacMid(World, mid);
406                  NeedsRecompute = true;                  NeedsRecompute = true;
407              }              }
408          }          }
# Line 411  Line 411 
411              float mid = OpacMid + OPAC_DELTA;              float mid = OpacMid + OPAC_DELTA;
412              if (mid <= MAX_OPAC_MID) {              if (mid <= MAX_OPAC_MID) {
413                  OpacMid = mid;                  OpacMid = mid;
414                  VR_InVarSet_valOpacMid(World, mid);                  VR_input_set_valOpacMid(World, mid);
415                  NeedsRecompute = true;                  NeedsRecompute = true;
416              }              }
417          }          }
# Line 442  Line 442 
442      }      }
443    
444    // shutdown the world    // shutdown the world
445      VR_Shutdown (wrld);      VR_shutdown (wrld);
446    
447    // Terminate GLFW    // Terminate GLFW
448      glfwTerminate();      glfwTerminate();

Legend:
Removed from v.5451  
changed lines
  Added in v.5452

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0