Archived

This topic is now archived and is closed to further replies.

Saandman

How du you do? 'Bout globals

Recommended Posts

Saandman    160
I''m just wondering, I''m having a hard time deciding how to do =) For example; if you are to use a vertex buffer in your d3d app, where would you declare it? As a global, or local whenever you instantiate it? // globals IDirect3DVertexBuffer8 *d3dVBuffer = NULL; ... initd3d() { d3dVBuffer = CreateBuffer(yadayada); } OR initd3d() { IDirect3DVertexBuffer8 *d3dVBuffer = NULL; yadayada CreateVertexBUffer(...); } Hope you get it =) /Sandman

Share this post


Link to post
Share on other sites
Yratelev    130
choose global, it never goes out of scope, so u can be sure u wont lose it. Plus when ur pointer goes out of scope, the memory is still active, so if u forget to delete it, ur ram gets clogged up with vertex buffers!

just some advice,

Yratelev

Share this post


Link to post
Share on other sites
pan narrans    1284
How about an Application class? The globals would become private member variables, and functions like init, frame, shutdown, etc, would become member functions.


pan narrans
Study + Hard Work + Loud Profanity = Good Code

Share this post


Link to post
Share on other sites
Saandman    160
Thanks for the advices! So globals all along it will be As I initially started off.

About that App class; yeah I''ve given it a try before and I''ll do it once more, but later on..

Thanks
/Sandman

Share this post


Link to post
Share on other sites
pan narrans    1284
quote:
Original post by Saandman
Thanks for the advices! So globals all along it will be As I initially started off.


Erm, I think you should read Yratelev''s post again. You may have missed something: i.e. sarcasm


pan narrans
Study + Hard Work + Loud Profanity = Good Code

Share this post


Link to post
Share on other sites