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

CUDADispCmds.cu

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: CUDADispCmds.cu,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.4 $        $Date: 2011/12/23 23:56:19 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * DispCmds - different display commands which take data and put it in
00020  *      a storage space provided by a given VMDDisplayList object.
00021  *
00022  * Notes:
00023  *      1. All coordinates are stored as 3 points (x,y,z), even if meant
00024  * for a 2D object.  The 3rd coord for 2D objects will be ignored.
00025  ***************************************************************************/
00026 
00027 #include <string.h>
00028 #include <stdlib.h>
00029 #include <stdio.h>
00030 #include <math.h>
00031 
00032 #include "Scene.h"
00033 #include "DispCmds.h"
00034 #include "utilities.h"
00035 #include "Matrix4.h"
00036 #include "VMDDisplayList.h"
00037 
00038 
00039 //*************************************************************
00040 // draw a mesh consisting of vertices, facets, colors, normals etc.
00041 void DispCmdTriMesh::cuda_putdata(const float * vertices_d,
00042                                   const float * normals_d,
00043                                   const float * colors_d,
00044                                   int num_facets,
00045                                   VMDDisplayList * dobj) {
00046   // make a triangle mesh (no strips)
00047   DispCmdTriMesh *ptr;
00048   if (colors_d == NULL) {
00049     ptr = (DispCmdTriMesh *)
00050                 (dobj->append(DTRIMESH_C3F_N3F_V3F, sizeof(DispCmdTriMesh) +
00051                                         sizeof(float) * num_facets * 3 * 6));
00052   } else {
00053     ptr = (DispCmdTriMesh *)
00054                 (dobj->append(DTRIMESH_C3F_N3F_V3F, sizeof(DispCmdTriMesh) +
00055                                         sizeof(float) * num_facets * 3 * 9));
00056   }
00057 
00058   if (ptr == NULL)
00059     return;
00060 
00061   ptr->numverts=num_facets * 3;
00062   ptr->numfacets=num_facets;
00063 
00064   float *c=NULL, *n=NULL, *v=NULL;
00065   if (colors_d == NULL) {
00066     ptr->pervertexcolors=0;
00067     ptr->getpointers(n, v);
00068   } else {
00069     ptr->pervertexcolors=1;
00070     ptr->getpointers(c, n, v);
00071     cudaMemcpy(c, colors_d,   ptr->numverts * 3 * sizeof(float), cudaMemcpyDeviceToHost);
00072   }
00073 
00074   cudaMemcpy(n, normals_d,  ptr->numverts * 3 * sizeof(float), cudaMemcpyDeviceToHost);
00075   cudaMemcpy(v, vertices_d, ptr->numverts * 3 * sizeof(float), cudaMemcpyDeviceToHost);
00076 }
00077 
00078 
00079 

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