Public Group

# Vertex Buffers? (EDIT: SOLVED) (Direct3D)

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

## Recommended Posts

Aren't most 3D games consisting of more model rendering than using primitives? If so why should I learn vertex buffers instead of trying to learn how to render models? [Edited by - dist0rted on July 22, 2006 12:39:00 PM]

##### Share on other sites
well in order to render a model you need to dump all the vertex positions and tex coord etc. into a vertex buffer that gets locked to the video memory. index buffers are useful as you can use one vertex's information to describe many verticies.

So basically you need to learn about VBs/IBs because that is how DirectX renders. The primitives you are talking about are the polygons used to create the model.

##### Share on other sites
Ah, I figured they were only used to make a faster method than DrawPrimitiveUP(). The reason why I asked is because until I started trying to define a custom VertexBuffer and IndexBuffer class, all my code was fine. Now I'm getting errors every time I declare a class/struct where it says "error C2236: unexpected 'struct' '<class name here>'. Did you forget a ';'?"

##### Share on other sites
Draw[Indexed]Primitive() (i.e., vertex buffers) should be your standard rendering method. Draw[Indexed]PrimitiveUP() should be used only for quick-and-dirty debug rendering, if at all. It is quite slow.

##### Share on other sites
Quote:
 Original post by dist0rtedAh, I figured they were only used to make a faster method than DrawPrimitiveUP(). The reason why I asked is because until I started trying to define a custom VertexBuffer and IndexBuffer class, all my code was fine. Now I'm getting errors every time I declare a class/struct where it says "error C2236: unexpected 'struct' ''. Did you forget a ';'?"

Well, *did* you forget a ';'? (Remember that you need one after each class/struct body.)

##### Share on other sites
Of course not, as a matter of fact - here's the code for the header file with errors:

CDGApplication.h:
#pragma once#include "dgproject.h"struct CDGApplication{	CDGApplication(void);	virtual ~CDGApplication(void) { Shutdown(); }	HINSTANCE m_hInstance;	HWND m_hWnd;	MSG m_Msg;	WNDCLASSEX m_WndClass;	char *m_pszAppTitle;	DGINT m_nWidth;	DGINT m_nHeight;	DGBOOL32 m_bWindowed;	LPDIRECT3D9 m_pD3D;	LPDIRECT3DDEVICE9 m_pd3dDevice;	D3DPRESENT_PARAMETERS m_PresentParameters;	static LRESULT WINAPI m_fnWndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam);	DGRESULT Init(char *pszAppTitle, DGINT nWidth, DGINT nHeight, DGBOOL32 bWindowed);	void EventLoop(void);	void Shutdown(void);	virtual DGRESULT OneTimeSceneInit(void) { return DG_OK; }	virtual DGRESULT InitDeviceObjects(void) { return DG_OK; }	virtual DGRESULT RestoreDeviceObjects(void) { return DG_OK; }	virtual DGRESULT InvalidateDeviceObjects(void) { return DG_OK; }	virtual DGRESULT DeleteDeviceObjects(void) { return DG_OK; }	virtual DGRESULT Render(void) { return DG_OK; }	virtual DGRESULT FinalCleanup(void) { return DG_OK; }};

##### Share on other sites
Quote:
 Original post by dist0rtedOf course not, as a matter of fact - here's the code for the header file with errors:CDGApplication.h:*** Source Snippet Removed ***

You may have forgotten a ';' somewhere inside dgproject.h. Remember, when you include a file, its contents are practically copied in place of the include statement. So if you're 100% sure that there are no problems in a specific file, but the compiler still generates errors, look into your includes.

##### Share on other sites
I swear upon all that's holy, none of my files had changed besides the four new files I created: CDGVertexBuffer.h/cpp and CDGIndexBuffer.h/cpp. After defining those classes gave me errors, I deleted them and now I'm getting errors on CDGApplication (it's the only class I have now where I define method functions in a seperate source file, now).

##### Share on other sites
a syntax error is hardly reason enough for you to not learn the necesseties of your graphics API of choice :) Vertex Arrays are a very important step in graphics programming, don't let a trivial error like this get in the way of becoming a better graphics programmer.

As V0dKA said, this missing semicolon could be elsewhere in your program (often times errors point you in the totally wrong direction). The most likely culprit is any file that is being included in the file the error is coming from.

good luck

##### Share on other sites
Freaky things happen with Visual Studio. I once fixed errors by moving the definition of a function into a different file. I would similarly be willing to swear upon everything that's holy that there was nothing wrong with the old file.

Try temporarily moving just the function definitions to just after your main() or WinMain(), or whatever it would be in your case.

Beyond that, I have no clue...

1. 1
Rutin
24
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631749
• Total Posts
3002031
×