I have an opengl application that loads dxf and draws it on the screen, every time I need to calculate the normals. is there any way to calculate normals in GPU instead of CPU? if so, how?
Yes it is possible. You will want to know about shaders in Cg .
Official book .
( ) . , " ", -. "" , GS .
(, ), . GPU.
, - .
IF GPU CUDA, OpenCL - , , , , , .
, , 5 ( ) " GPU" " GPU". . , , , ( ). ( ) GDC, SIGGRAPH, ATI SDK NVidia SDK.
.
GLSL. GLSL . , .
//glsl shader #version 120 #extension GL_EXT_geometry_shader4 : enable void main(void) { // Compute per-face normal vec4 d1 = gl_PositionIn[1] - gl_PositionIn[0]; vec4 d2 = gl_PositionIn[2] - gl_PositionIn[0]; gl_Normal = cross(d1,d2); // Emit all input vertices for(i=0; i< gl_VerticesIn; i++){ gl_Position = gl_PositionIn[i]; EmitVertex(); } EndPrimitive(); }
Take a look glEnable(GL_AUTO_NORMAL).
glEnable(GL_AUTO_NORMAL)