How du you do? 'Bout globals

Started by
3 comments, last by Saandman 21 years, 6 months ago
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
________________________________pro.gram.mer - an organism that turns caffeine into code
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
Yratelev
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
Minister of Propaganda : leighstringer.com : Nobody likes the man who brings bad news - Sophocles (496 BC - 406 BC), Antigone
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
________________________________pro.gram.mer - an organism that turns caffeine into code
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
Minister of Propaganda : leighstringer.com : Nobody likes the man who brings bad news - Sophocles (496 BC - 406 BC), Antigone

This topic is closed to new replies.

Advertisement