Advertisement
Guest User

D3D RenderCursors MU Remastered Project by Nemesis

a guest
Jan 15th, 2021
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. struct CURSORVERTEX
  2. {
  3. FLOAT x, y, z, w; // The transformed position for the vertex
  4. DWORD dwColor; // Color
  5. };
  6. #define D3DFVF_CURSORVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
  7.  
  8. #define CURSOR_SIZE 60.0f
  9.  
  10. // Device for rendering the real-time objects like cursors
  11. IDirect3DDevice9Ex* g_pDevRealTime = NULL;
  12.  
  13. // cursor vertex buffer
  14. IDirect3DVertexBuffer9* g_pCursorVB = NULL;
  15.  
  16. void MoveCursor( UINT posX, UINT posY )
  17. {
  18. float x = static_cast<float>(posX);
  19. float y = static_cast<float>(posY);
  20.  
  21. // Initialize vertices for rendering a quad
  22. CURSORVERTEX vertices[4];
  23.  
  24. vertices[0].x = x;
  25. vertices[0].y = y;
  26. vertices[0].z = 0.5f;
  27. vertices[0].w = 1.0f;
  28.  
  29. vertices[1].x = x + CURSOR_SIZE;
  30. vertices[1].y = y + CURSOR_SIZE*0.6f;
  31. vertices[1].z = 0.5f;
  32. vertices[1].w = 1.0f;
  33.  
  34. vertices[2].x = x + CURSOR_SIZE*0.6f;
  35. vertices[2].y = y + CURSOR_SIZE;
  36. vertices[2].z = 0.5f;
  37. vertices[2].w = 1.0f;
  38.  
  39. vertices[3].x = x + CURSOR_SIZE;
  40. vertices[3].y = y + CURSOR_SIZE;
  41. vertices[3].z = 0.5f;
  42. vertices[3].w = 1.0f;
  43.  
  44. for(int i=0; i<4; i++)
  45. vertices[i].dwColor = 0xff0000;
  46.  
  47. VOID* pVertices;
  48. if( FAILED( g_pCursorVB->Lock( 0, sizeof(vertices), (void**)&pVertices, 0 ) ) )
  49. return;
  50. memcpy( pVertices, vertices, sizeof(vertices) );
  51. g_pCursorVB->Unlock();
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement