game programming with librarys

Started by
4 comments, last by DavidSargent 12 years, 9 months ago
hi i know this will sound pointless but i feel the answer is going to give me a better understanding of game programming
if you program a game with one graphics library could you change to another library with a minimal amount of recoding?

thanks
Dave
Advertisement
That really depends alot on the libraries in question, and the way you format your code.
For the most part, if your code is well written, you should have functions that will contain all library related code in them, and keep minimal touch with the rest of the non-methodized code, and it'll evantually only come down to replacing each line of code with the respective one from the new library(Keep in mind it won't always go smooth since not all libraries function in the same manner, and it's always possible that you'll have to rewrite your code from scratch in the extreme cases)

In the end, it's always viable to change your library, but there's no set amount of difficulty or time or recoding that you'll have to do, it all really depends on what you have, what you want and how you did it.

Since you're only asking in theory though, I'll go ahead and say this: Always program with the mindset of that there's a chance you'll have to replace your library if something doesn't quite work, work from the get-go with the purpose of keeping clean and well commented code, as well as one that's well seperated between game mechanics, distinct objects in the game, the main function and external library code you'll need.

Hope this could help. =)
Thanks reading thats has been really helpful :lol:
You might be interested in the distinction between an interface and implementation in object-oriented programming: Write your interface, which is nothing more than the system you interact with under the impression things get done. As long as your implementation (the thing that actually does the work), still does what it is supposed to do, it can use whatever libraries it damn well pleases.

Say if you have an interface with a method called Render(). Rendering to a frame in Direct3D uses different code than in OpenGL, but the task is still rendering to a frame! The interface, and the person who uses it, does not really care what is happening as long as it works, and works well.
If you look at something liek Ogre3d, it works with a number of things (opengl, diectx and more). All through a common interface. There's also no need to rebuild anything when switching between different API/libraries. I think it would be alot of work to get to that point though.

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.


You might be interested in the distinction between an interface and implementation in object-oriented programming: Write your interface, which is nothing more than the system you interact with under the impression things get done. As long as your implementation (the thing that actually does the work), still does what it is supposed to do, it can use whatever libraries it damn well pleases.

Say if you have an interface with a method called Render(). Rendering to a frame in Direct3D uses different code than in OpenGL, but the task is still rendering to a frame! The interface, and the person who uses it, does not really care what is happening as long as it works, and works well.


Thats a nice way of doing things thanks Sage im going to start implimenting that in my games.:D

This topic is closed to new replies.

Advertisement