943,712 Members | Top Members by Rank

Ad:
Jul 13th, 2009
0

Is this me or DirectX?

Expand Post »
I am trying this:
c++ Syntax (Toggle Plain Text)
  1. #include <windows.h>
  2. #include <windowsx.h>
  3. #include <d3d9.h>
  4.  
  5. #pragma comment (lib, "d3d9.lib")
  6.  
  7. LPDIRECT3D9 d3d;
  8. LPDIRECT3DDEVICE9 d3ddev;
  9.  
  10. void initD3D(HWND hWnd);
  11. void render_frame(void);
  12. void cleanD3D(void);
  13.  
  14. LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
  15.  
  16. int WINAPI WinMain(HINSTANCE hInstance,
  17. HINSTANCE hPrevInstance,
  18. LPSTR lpCmdLine,
  19. int nCmdShow)
  20. {
  21. HWND hWnd;
  22. WNDCLASSEX wc;
  23.  
  24. ZeroMemory(&wc, sizeof(WNDCLASSEX));
  25.  
  26. wc.cbSize = sizeof(WNDCLASSEX);
  27. wc.style = CS_HREDRAW | CS_VREDRAW;
  28. wc.lpfnWndProc = WindowProc;
  29. wc.hInstance = hInstance;
  30. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  31. wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
  32. wc.lpszClassName = "WindowClass";
  33.  
  34. RegisterClassEx(&wc);
  35.  
  36. hWnd = CreateWindowEx(NULL,
  37. "WindowClass",
  38. "Our First Direct3D Program",
  39. WS_OVERLAPPEDWINDOW,
  40. 300, 300,
  41. 800, 800,
  42. NULL,
  43. NULL,
  44. hInstance,
  45. NULL);
  46.  
  47. ShowWindow(hWnd, nCmdShow);
  48.  
  49. initD3D(hWnd);
  50.  
  51. MSG msg;
  52.  
  53. while(TRUE)
  54. {
  55. while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  56. {
  57. TranslateMessage(&msg);
  58. DispatchMessage(&msg);
  59. }
  60. if(msg.message == WM_QUIT)
  61. break;
  62.  
  63. render_frame();
  64. }
  65.  
  66. cleanD3D();
  67.  
  68. return msg.wParam;
  69. }
  70.  
  71. void initD3D(HWND hWnd)
  72. {
  73. d3d = Direct3DCreate9(D3D_SDK_VERSION);
  74.  
  75. D3DPRESENT_PARAMETERS d3dpp;
  76.  
  77. ZeroMemory(&d3dpp, sizeof(d3dpp));
  78. d3dpp.Windowed = TRUE;
  79. d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
  80. d3dpp.hDeviceWindow = hWnd;
  81.  
  82. d3d->CreateDevice(D3DADAPTER_DEFAULT,
  83. D3DDEVTYPE_HAL,
  84. hWnd,
  85. D3DCREATE_SOFTWARE_VERTEXPROCESSING,
  86. &d3dpp,
  87. &d3ddev);
  88. }
  89.  
  90. void render_frame(void)
  91. {
  92.  
  93. d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRBG(0, 40, 0), 1.0f, 0);
  94.  
  95. d3ddev->BeginScene();
  96.  
  97.  
  98.  
  99. d3ddev->EndScene();
  100.  
  101. d3ddev->Present(NULL, NULL, NULL, NULL);
  102. }
  103.  
  104.  
  105. void cleanD3D(void)
  106. {
  107. d3ddev->Release();
  108. d3d->Release();
  109. }

And I get this error:

Error 1 error C3861: 'D3DCOLOR_XRBG': identifier not found c:\documents and settings\User\my documents\visual studio 2008\projects\first_direct3d\first_direct3d\main.cpp 93
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
fuggles is offline Offline
66 posts
since Jun 2009
Jul 14th, 2009
0

Re: Is this me or DirectX?

it's D3DCOLOR_XRGB.. (You have B and G the wrong way).
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Game Development Forum Timeline: borland's turbo c++ 2006
Next Thread in Game Development Forum Timeline: 2d Ball representation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC