The MASM Forum

General => The Laboratory => Topic started by: Farabi on December 18, 2013, 03:59:59 PM

Title: GPU Vertex Rotation Code
Post by: Farabi on December 18, 2013, 03:59:59 PM

fGPURotateVertex  proc uses esi edi lpVertex:dword,RotX:real4,RotY:real4,RotZ:real4
LOCAL x[16]:dword
LOCAL buff[256]:dword
mov esi,lpVertex

invoke glPushMatrix
invoke glMatrixMode,GL_MODELVIEW
invoke glLoadIdentity
invoke glRotatef,RotX,FP4(1.),FP4(0.),FP4(0.)
invoke glRotatef,RotY,FP4(0.),FP4(1.),FP4(0.)
invoke glRotatef,RotZ,FP4(0.),FP4(0.),FP4(1.)
invoke glTranslatef,[esi].VERTEX.x,[esi].VERTEX.y,[esi].VERTEX.z
invoke glGetFloatv,GL_MODELVIEW_MATRIX,addr x
invoke glPopMatrix

lea edi,x

fld dword ptr[edi+12*4]
fstp [esi].VERTEX.x
fld dword ptr[edi+13*4]
fstp [esi].VERTEX.y
fld dword ptr[edi+14*4]
fstp [esi].VERTEX.z


ret
fGPURotateVertex endp


Very simple and fast, the faster your GPU the faster this code is.