Jump to content
  • Advertisement
Sign in to follow this  
dist0rted

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.

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

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
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.)

Share this post


Link to post
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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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...

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!