Vertex Buffers? (EDIT: SOLVED) (Direct3D)

Started by
13 comments, last by dist0rted 17 years, 9 months ago
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]
=============================All knowledge is good; only the way it is put to use is good or evil.
Advertisement
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.
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 ';'?"
=============================All knowledge is good; only the way it is put to use is good or evil.
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.
Quote:Original post by dist0rted
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 ';'?"


Well, *did* you forget a ';'? (Remember that you need one after each class/struct body.)
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; }};
=============================All knowledge is good; only the way it is put to use is good or evil.
Quote:Original post by dist0rted
Of 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.
.:<<-v0d[KA]->>:.
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).
=============================All knowledge is good; only the way it is put to use is good or evil.
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
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...
.:<<-v0d[KA]->>:.

This topic is closed to new replies.

Advertisement