Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FreeVRRoutines.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the      
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: FreeVRRoutines.C,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.24 $       $Date: 2019/01/17 21:20:59 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * routines to get memory from and return memory to the 
00020  * FreeVR shared memory arena
00021  ***************************************************************************/
00022 
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 #include "Inform.h"
00026 #include "FreeVRRoutines.h"
00027 #include "VMDApp.h"
00028 #include "FreeVRDisplayDevice.h"
00029 #include "FreeVRScene.h"
00030 
00031 #include <freevr.h>
00032 
00033 void *malloc_from_FreeVR_memory(size_t size) {
00034   return vrShmemAlloc(size);
00035 }
00036 
00037 void free_to_FreeVR_memory(void *data) {
00038   vrShmemFree(data);
00039 }
00040 
00041 // get megs o' memory from FreeVR, and create the arena
00042 // Warning:  Don't make me do this twice.
00043 void grab_FreeVR_memory(size_t megs) {
00044   size_t size = ((megs>1) ? megs : 1) * 1024L * 1024L;
00045   size_t sz=0;
00046 
00047   while (((sz = vrShmemInit(size)) == 0) && (size > 64*1024*1024)) {
00048     msgErr << "Failed to create FreeVR arena of size " 
00049            << (size / (1024*1024)) 
00050            << ", reducing allocation by half." << sendmsg;
00051     size >>= 1; // cut allocation in half
00052   }
00053  
00054   if (sz == 0) 
00055     msgErr << "Failed to create FreeVR arena.  We're gonna die!" << sendmsg;
00056   else
00057     msgInfo << "Created arena, size " << (sz / (1024*1024)) 
00058             << "MB." << sendmsg;
00059 }
00060 
00061 
00062 // set up the graphics, called from FreeVRInitApplication
00063 void freevr_gl_init_fn(void) {
00064 }
00065 
00066 static FreeVRScene *freevrscene;
00067 static DisplayDevice *freevrdisplay;
00068 
00069 void set_freevr_pointers(Scene *scene, DisplayDevice *display) {
00070   freevrscene = (FreeVRScene *)scene;
00071   freevrdisplay = display;
00072 }
00073 
00074 // call the child display renderer, and wait until they are done
00075 void freevr_renderer(DisplayDevice *display, void *rendinfo) {
00076   //printf((char*)"hey in freevr_renderer -- rendinfo = %p\n", rendinfo);
00077 #if 1
00078   freevrscene->draw(freevrdisplay, (vrRenderInfo *)rendinfo);   /* BS: the use of this "freevrdisplay" global isn't necessary now that we've got it as an argument. */
00079 #else
00080   freevrscene->draw(freevrdisplay);     /* BS: the use of this "freevrdisplay" global isn't necessary now that we've got it as an argument. */
00081 #endif
00082 }
00083 

Generated on Thu Mar 28 02:43:14 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002