   error C2227: With ID3DXLine.
  Hello. I am trying to use ID3DXLine to draw lines in my program. I set a null pointer called pLine, then I used D3DXCreateLine like this "D3DXCreateLine(gd3dDevice, pLine);" I then did this:pLine->Begin();, but I got an error saying "left of '->Begin' must point to class/struct/union/generic type" Doesn't D3DXCreateLine make pLine a pointer to an ID3DXLine interface? If not what am I doing wrong? If so what am I doing wrong? Thanks for any help.   
  Paste actual code. Your description is nearly nonsensical.   ;  Ok. #include "d3dApp.h"#include <tchar.h>#include <crtdbg.h>LPD3DXLINE* pLine = 0;D3DXVECTOR2 lineVect[2]; void drawline(float x1, float y1, float x2, float y2); 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;};int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance,   PSTR cmdLine, int showCmd){// Enable run-time memory check for debug builds.#if defined(DEBUG) | defined(_DEBUG)_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );#endifD3DXCreateLine(gd3dDevice, pLine);HelloD3DApp app(hInstance, "Hello Direct3D", D3DDEVTYPE_HAL, D3DCREATE_HARDWARE_VERTEXPROCESSING);gd3dApp = &app;return gd3dApp->run();}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.Width = 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));}HelloD3DApp::~HelloD3DApp(){ReleaseCOM(mFont);}bool HelloD3DApp::checkDeviceCaps(){// Nothing to check.return true;}void HelloD3DApp::onLostDevice(){HR(mFont->OnLostDevice());}void HelloD3DApp::onResetDevice(){HR(mFont->OnResetDevice());}void HelloD3DApp::updateScene(float dt){}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());   drawline(20, 20, 25, 25);mFont->DrawText(0, _T("Hello Direct3D"), -1, &formatRect, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256));HR(gd3dDevice->EndScene());HR(gd3dDevice->Present(0, 0, 0, 0));}void drawline(float x1, float y1, float x2, float y2){lineVect[0].x = x1;lineVect[0].y = y1;lineVect[1].x = x2;lineVect[1].y = y2;pLine->Begin();pLine->Draw(lineVect, 2, D3DCOLOR_XRGB(0, 0, 255));pLine->End();}I am doing one of the exercises from Introduction to 3D Game Programming with Directx A shaders approach by Frank D. Luna.   ;  tryLPD3DXLINE pLine = 0;and then doD3DXCreateLine(gd3dDevice, &pLine);   ;  Thanks, I should have known it was something simple... I really should not program past midnight. But I am now getting: Unhandled exception at 0x00420bd7 in FDLBook.exe: 0xC0000005: Access violation reading location 0x00000000. What does that mean? Thanks again.   ;  Check if D3DXCreateLine fails (use the SUCCEEDED macro). If it does, your pointer stays NULL.Hint: Any address very close to zero in the message "Access violation reading location 0x00000000" is a strong hint that you accessed a NULL pointer.There's nothing in your shown code that created a D3DDevice before you call D3DXCreateLine. Are you passing a valid device pointer?;Quote:Original post by EndurionCheck if D3DXCreateLine fails (use the SUCCEEDED macro). If it does, your pointer stays NULL.Thanks. That is exactly what is happening. I checked both that and the device and CreateLine fails. What would make it fail?;  Huh, good question. Check out Direct3D Programming Tip #5: Use The Debug Runtime.   ;  Hi,It seems that you are passing your pointer to IDirect3DDevice9 into D3DXCreateLine() before it has been created in CreateDevice(). Try moving D3DXCreateLine() to after you create your font in HelloD3DApp's constructor.Hope that helps.   ;  Thanks Pedigree_D it works perfectly now. Also thanks Promit for the link.   