Jump to content
  • Advertisement
Sign in to follow this  
Zammy

[dx9.0 Nov2007] ID3DXLine::Draw problem

This topic is 3670 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I cannot make my line to draw on the screen. Here is the code: class HelloD3DApp : public D3DApp { public: HelloD3DApp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP); ~HelloD3DApp(); bool checkDeviceCaps(); void onLostDevice(); void onResetDevice(); void updateScene(float dt); void drawScene(); private: ID3DXFont* mFont; ID3DXLine* mLine; D3DXVECTOR2 mVector[4]; }; HelloD3DApp::HelloD3DApp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP) : D3DApp(hInstance,winCaption,devType,requestedVP) { srand(time_t(0)); if(!checkDeviceCaps()) { MessageBox(0,"checkDeviceCaps() Failed",0,0); PostQuitMessage(0); } D3DXFONT_DESC fontDesc; fontDesc.Height = 80; fontDesc.Weight = 40; fontDesc.Weight = FW_BOLD; fontDesc.MipLevels = 0; fontDesc.Italic = true; fontDesc.CharSet = DEFAULT_CHARSET; fontDesc.OutputPrecision = OUT_DEFAULT_PRECIS; fontDesc.Quality = DEFAULT_QUALITY; fontDesc.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; _tcscpy(fontDesc.FaceName, _T("Times New Roman")); HR(D3DXCreateFontIndirect(gd3dDevice, &fontDesc,&mFont)); //creating a line HR(D3DXCreateLine(gd3dDevice,&mLine)); //vector2d mVector[0].x=22; mVector[0].y=22; mVector[1].x=555; mVector[1].y=555; mVector[2].x=555; mVector[2].y=666; mVector[3].x=666; mVector[3].y=666; } void HelloD3DApp::drawScene() { HR(gd3dDevice->Clear(0,0,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255),1.0f,0)); RECT formatRect; GetClientRect(mhMainWnd,&formatRect); HR(gd3dDevice->BeginScene()); mFont->DrawTextA ( 0, // no pointer to ID3DXSprite interface _T("Hello Direct 3D"), // just a string literal -1, // null terminating &formatRect, // the area on the screen DT_CENTER | DT_VCENTER, // center horizontally and vertically D3DCOLOR_XRGB(rand() % 256,rand() % 256,rand() % 256) ); //HR(mLine->Begin()); HR(mLine->Draw(mVector,4,D3DCOLOR_ARGB(0,255,255,255))); //HR(mLine->End()); HR(gd3dDevice->EndScene()); HR(gd3dDevice->Present(0,0,0,0)); }

Share this post


Link to post
Share on other sites
Advertisement
You have mLine->Begin() and mLine->End() commented out.

You also set the alpha of the color to 0, which isn't a good idea.

Share this post


Link to post
Share on other sites
Ok thank you!
The problem was that I am using 0 alpha value thus it does not show on the screen at all. Once I changed it to 255 it showed on the screen no problem.
Btw it does not need to be between mLine->Begin() and mLine->End().
In the documentation it says that those functions are added automatically.

Working code:

HR(mLine->Draw(mVector,4,D3DCOLOR_ARGB(255,0,0,0)));

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!