• Advertisement

Archived

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

How du you do? 'Bout globals

This topic is 5625 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

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
Advertisement
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
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
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
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

  • Advertisement