Ive actually managed to get DirectX 9 working with Direct X, however i am now getting odd error messages around a function. I can't see any syntax issues myself but thought i'd check to see if anyone can shed any light on it.

g_pd3dDevice->CreateVertexBuffer( 3 * sizeof(CUSTOMVERTEX) , 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL);

These are the error messages. Removing the above line, the program compiles correctly, so it seems something to do with how Dev C++ handles this function.

  • 108 C:\Dev-Cpp\DirectX8.cpp expected `)' before ';' token
  • 108 C:\Dev-Cpp\DirectX8.cpp expected primary-expression before ',' token
  • 108 C:\Dev-Cpp\DirectX8.cpp expected `;' before ')' token

Grateful of any assistance in this
Thanks

Recommended Answers

All 3 Replies

For some reason, the compiler seems to think that you have a open parenthesis.
To be honest, it could be from the line before.

I won't pretend to know about DX9, I don't make games.
Perhaps one of the all caps defines you are using is in fact a function.

IDirect3DDevice9::CreateVertexBuffer( ) via MSDN:

HRESULT CreateVertexBuffer(
  [in]           UINT Length,
  [in]           DWORD Usage,
  [in]           DWORD FVF,
  [in]           D3DPOOL Pool,
  [out, retval]  IDirect3DVertexBuffer9 **ppVertexBuffer,
  [in]           HANDLE *pSharedHandle
);

Your code:
g_pd3dDevice->CreateVertexBuffer( 3 * sizeof(CUSTOMVERTEX) , 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL);

Length = 3*sizeof(CUSTOMVERTEX);
Usage = 0;
FVF = D3DFVF_CUSTOMVERTEX;
Pool = D3DPOOL_DEFAULT;
// &g_pVB
pSharedHandle = NULL;

If you were to define these things individually, what would your compiler say?

Mostly guessing .. your filename DirectX8.cpp somewhat suggests that the code might actually be originally for DirectX 8 - if that's so, you should check whether CreateVertexBuffer()'s signature has changed in-between the 8 vs. 9 versions (i.e., has DirectX 9 CreateVertexBuffer() dropped a parameter?).

Thanks to you both. Mitrmkar - i used DirectX 8 first, just couldn't get it to compile. So although you are right that the filename is DirectX8.cpp, the code is DirectX 9.
In the end i copied the file and made a new project in Dev C++ and it compiled fine..so i have no idea at all why it was flagging issues with the code as it works fine!
Put this down to DevC++ bug?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.