CUDA Syntax Highlighting in Eclipse 2012-11-19

Enable syntax highlighting for CUDA files in Eclipse:

  • Window -> Preferences -> in C/C++ -> File Types -> New
  • Enter “*.cu” and select “C++ Source File”
  • Repeat and enter “*.cuh” and select “C++ Header File”

Prevent Eclipse from complaining about global and others: In your code, either include cuda_runtime.h or add the following:

 #ifdef __CDT_PARSER__
 #define __global__
 #define __device__
 #define __shared__
 #endif

See http://forums.nvidia.com/index.php?showtopic=90943&view=findpost&p=1249657 for a similar trick related to kernel invocations, but note that its use is discouraged.

Material Point Method (MPM) Reference 2012-11-18

Here are several useful references that I have found relating to the use of the Material Point Method in modeling flexible objects.

Quaternion and Vector Math 2012-11-15

UPDATE: The definitions of R3 and R4 were missing, code has been updated

#####UPDATE: Added a function to get a quaternion from and angle and an axis

Often times I find myself needing to use quaternions to store rotations in my code. They are compact and easy to use, the math however is not always intuitive.

OpenGL Camera 2012-11-14

UPDATE: For a modern opengl version using GLM please see this newer post
UPDATE: Some definitions were mission from code, quaternion and vector classes now included with code

When i’m writing a dynamics code I usually need to visually debug my simulations to make sure everything is initialized properly, looks correct, etc. I’ve found that using OpenGL along with GLUT provides a lightweight solution that I can implement quickly. Usually when I implement a basic rendering code I have a static camera, which in the grand scheme of things is not very useful. So after googling OpenGL quaternion cameras I came up with the following solution. To use this code a basic quaternion class is included. This will be covered in a later post.