Archived

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

nanobyte

What is a wrapper?

Recommended Posts

nanobyte    122
I have heard a lot of people talking about wrappers, usually .lib files. Im guessing they are used to simplify programming by sticking functions, etc. into a lib file? If so, how do I make these myself? Thanks

Share this post


Link to post
Share on other sites
brad_beveridge    122
You''re kinda right. Wrappers tend to "wrap up" more complex code with simpler code. So if when you call func X you also always have to call Y & Z, you could wrap it with
void funcXcallAll()
{
X();
Y();
Z();
}

This is obviously a trivial example

Brad

Share this post


Link to post
Share on other sites
LOWORBIT    122
Ya, wrappers are created to run common tasks quickly and easily. Also I personally try to be modular with any wrappers i make so i can use them on multiple projects.
An example is the wrapper i wrought for various parts of Direct X. I wrought one for DirectInput,DirectSound,DirectDraw,and DirectMusic. I tried to keep it simple, want to open direct input for a keyboard, you make two calls in my wrapper

OpenDI(hInst)
OpenDIKey(hWnd)

An in each of those funtions (which are part of a class) it handles the respected things, so I don''t have to type out create devivce and handle the devices. Note these are in a class and only a few functions of the wrapper. eg getting data, updating and so forth. There is no one way to make a wrapper, but they save you time. So later on you can grab a wrapper you made a while ago and quickly have that part of the program up and running.

-Scott

Share this post


Link to post
Share on other sites
Julio    116
you don''t have to make a new lib file though. most people just make reusable code (classes) for a redundant operation.



How many Microsoft employees does it take to screw in a light bulb?
None, they just declare drakness as a new standard.

Share this post


Link to post
Share on other sites
SikCiv    122
If you like, download my D3DXSprite wrapper library to give you an idea how to get your own wrapper up and running. Its basically a D3D (2D) Graphics Lib that takes care of initialization, all the textures, and destruction. A sample app that utilizes the wrapper is included as well.
Hope it helps

  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites