Skip to main content

more options


Low-level Graphics Primitives

OpenGL and DirectX are graphics libraries used for all sorts of graphics applications, from games to architectural drawing. To use them, you have to write code that talks with the library in terms of graphics primitives like spheres or strips of polygons. The most demanding scientific applications can benefit from being written with low-level graphics libraries, but it is rarely something you would want to undertake yourself. In the sample DirectX code below, you draw a line by building its points.

for ( int splineIdx=0; splineIdx<4; splineIdx++ )  {
  p[splineIdx] = new Vector3(coords[splineIdx,0],coords[splineIdx,1],
                    coords[splineIdx,2]);
}
m_device.DrawUserPrimitives(PrimitiveType.LineStrip, p, 0, m_vertexCnt);

DirectX is a Microsoft-specific library, offering slightly better speed on Windows. OpenGL is on every Windows machine, as well, but is cross-platform. The great John Carmack (of Quake fame) said he didn't know why you would want to take three days to learn DirectX when you can learn OpenGL in a day. If you aren't named John Carmack, it might take you longer to learn, but OpenGL is the more straightforward of these two main options.

OpenGL and DirectX are graphics libraries used for all sorts of graphics applications, from games to architectural drawing. To use them, you have to write code that talks with the library in terms of graphics primitives like spheres or strips of polygons. The most demanding scientific applications can benefit from being written with low-level graphics libraries, but it is rarely something you would want to undertake yourself. In the sample DirectX code below, you draw a line by building its points.

for ( int splineIdx=0; splineIdx<4; splineIdx++ )  {
  p[splineIdx] = new Vector3(coords[splineIdx,0],coords[splineIdx,1],
                    coords[splineIdx,2]);
}
m_device.DrawUserPrimitives(PrimitiveType.LineStrip, p, 0, m_vertexCnt);

DirectX is a Microsoft-specific library, offering slightly better speed on Windows. OpenGL is on every Windows machine, as well, but is cross-platform. The great John Carmack (of Quake fame) said he didn't know why you would want to take three days to learn DirectX when you can learn OpenGL in a day. If you aren't named John Carmack, it might take you longer to learn, but OpenGL is the more straightforward of these two main options.