Is this me or DirectX?

Reply

Join Date: Jun 2009
Posts: 14
Reputation: fuggles is an unknown quantity at this point 
Solved Threads: 0
fuggles fuggles is offline Offline
Newbie Poster

Is this me or DirectX?

 
0
  #1
Jul 13th, 2009
I am trying this:
  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
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: Is this me or DirectX?

 
0
  #2
Jul 14th, 2009
it's D3DCOLOR_XRGB.. (You have B and G the wrong way).
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Game Development Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC