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

FreeVRRoutines.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2011 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.21 $       $Date: 2011/06/11 03:24:16 $
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 <stdlib.h>
00024 #include "Inform.h"
00025 #include "FreeVRRoutines.h"
00026 #include "VMDApp.h"
00027 #include "FreeVRDisplayDevice.h"
00028 #include "FreeVRScene.h"
00029 
00030 #include <freevr.h>
00031 
00032 void *malloc_from_FreeVR_memory(size_t size) {
00033   return vrShmemAlloc(size);
00034 }
00035 
00036 void free_to_FreeVR_memory(void *data) {
00037   vrShmemFree(data);
00038 }
00039 
00040 // get megs o' memory from FreeVR, and create the arena
00041 // Warning:  Don't make me do this twice.
00042 void grab_FreeVR_memory(size_t megs) {
00043   size_t size = ((megs>1) ? megs : 1) * 1024L * 1024L;
00044   size_t sz=0;
00045 
00046   while (((sz = vrShmemInit(size)) == 0) && (size > 64*1024*1024)) {
00047     msgErr << "Failed to create FreeVR arena of size " 
00048            << (size / (1024*1024)) 
00049            << ", reducing allocation by half." << sendmsg;
00050     size >>= 1; // cut allocation in half
00051   }
00052  
00053   if (sz == 0) 
00054     msgErr << "Failed to create FreeVR arena.  We're gonna die!" << sendmsg;
00055   else
00056     msgInfo << "Created arena, size " << (sz / (1024*1024)) 
00057             << "MB." << sendmsg;
00058 }
00059 
00060 
00061 // set up the graphics, called from FreeVRInitApplication
00062 void freevr_gl_init_fn(void) {
00063 }
00064 
00065 static Scene *freevrscene;
00066 static DisplayDevice *freevrdisplay;
00067 
00068 void set_freevr_pointers(Scene *scene, DisplayDevice *display) {
00069   freevrscene = scene;
00070   freevrdisplay = display;
00071 }
00072 
00073 // call the child display renderer, and wait until they are done
00074 void freevr_renderer(void) {
00075   freevrscene->draw(freevrdisplay);
00076 }
00077 

Generated on Sat May 26 01:47:59 2012 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002