Skip to main content
gamedev.net
🔒 Locked

Reusable modules

Started by Tron3k 1 reply 200+ views
Original Post
Tron3k
Tron3k
Hi! My question is: Let''s say you have a bunch of routines you use a lot that are all related (eg. DirectX/OpenGL initialization). You want to be able to reuse them in other projects. Would you put them in a class or a singleton or just leave them as plain old functions? Would you have them as functions in a namespace? For example, I have a class that handles initializing OpenGL and a class that loads my map files. I wasn''t sure if this is the right way to do things, because always calling functions through classes might be slow. I appreciate any input. Firebird Entertainment
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
IndirectX
IndirectX
I have classes, functions, and macros in a namespace. If you have just a function, there''s no need to put it in a class.
---visit #directxdev on afternet <- not just for directx, despite the name
Daishim
Daishim
I take the approach with some simple data classes, and these data classes hold their visual information like their images. Then I have a main video class that has pointers to these lists and methods where it scans through these lists and checks for things that need to be drawn and where. It''s worked quite well for a couple of projects thus far and a quite rapid method of establishing the base architecture. There really is no right or wrong way, it''s mostly preference and style.

I know only that which I know, but I do not know what I know.

I know only that which I know, but I do not know what I know.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.