Jump to content

  • Log In with Google      Sign In   
  • Create Account


DD surfaces... global or passed


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Sixpack   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 December 1999 - 02:01 PM

Just wanted to get your( guys/gals) feelings on this-

When using DirectDraw (whether it be encapsulated in a class or stand alone), do you pass the surfaces to functions or do you leave them as global variables?

I've seen this done both ways, but my feeling is that performance suffers when they are passed.

Six


Sponsor:

#2 lshadow   Members   -  Reputation: 123

Like
Likes
Like

Posted 07 December 1999 - 03:42 AM

Most of the time I pass them globally. But now I'm working on an engine, and I want the user to be able to use as many surfaces as they want, so for that I have to pass them in the function.

But I don't think performance suffers that much when passing surfaces in a function (I know it does suffer some though).


#3 Sieggy   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 December 1999 - 06:34 AM

Someone correct me if am wrong but what is given to you by Direct Draw is a pointer rather than the actual surface itself. Hence if you pass the LPDIRECTDRAWSURFACE object to a function all you are really passing is the pointer, a simple 4 bytes, and not the entire surface. So I guess it would be a performance drain but only a nominal one.

#4 Sixpack   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 December 1999 - 08:00 AM

I guess what I was getting at was this:

Declare as global or in winmain (and thus pass into the game loop)?

Perhaps I didn't word it clearly enough.. still probably not . It was a question I've had for a couple months, and I finally got around to posting it--or what was left of it in my mind.

Six


#5 Sieggy   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 December 1999 - 09:44 AM

Personally I prefer the nice organization that a well thought out set of C++ classes offer as opposed to global data. IMHO, it makes it easier to program in the long run, especially as you're engine grows in complexity, and if done correctly you can limit performance hits from accessing encapsulated data.

#6 Sixpack   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 December 1999 - 02:10 PM

Sieggy,
Which leads me back to the original question; in a broader sense. Is your class declared globally or in main?

Six


#7 Sieggy   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 December 1999 - 06:23 AM

SixPack,

While most view it as a sacrilege, I suppose, I use a skeleton MFC structure. Now that preference aside, I have my major interfaces to Direct3D kept as members of my application's window class which is inherited from CFrameWindow. It handles all my major coordination of rendering. My application specific surfaces like my tiles and such are stored in classes that represent that object type. For instance CTile allows me to code behavior specific for that object type as well as provide access to its surface.
I probably dragged this out too much! If I was using winapi style code I probably would still do a similar construction as I described above: wrap my major interfaces and surfaces into a scene managment class stored in main and my other surfaces into classes that cooresponded to their object's function. I like the idea that a class can hold data, manipulate, and store it "behind the scene" so to speak, and the querying class does not have to know about what was going. You can't really guarantee this kind of relationship with global data so I avoid use of globals. Some poeple still aren't real big fanatics of the object oriented style but I think its incredibly powerfull, IMHO. I long answer, but does that answer you're question?


#8 lshadow   Members   -  Reputation: 123

Like
Likes
Like

Posted 08 December 1999 - 02:01 PM

ahhh... winmain or globally. I'd definately go with globally. I don't think I've seen a program yet that has declared direct draw variables in winmain. Well that's my recomendation!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS