Sign in to follow this  
Stargorger

Noobie question....But technical.

Recommended Posts

Stargorger    120
Alright, so, I realize this question stems from total ignorance and blind n00bness, but what ARE game libraries (specifically graphics ones, like Ogre and Irrlicht) for? I mean, I have read about them over and over again, read their websites, FAQs, etc... but it all assumes you already have a need for or know why you would need one. I guess I don't understand the point of using them if you're just going to have to write the code from the dirt-up anyway.???

Share this post


Link to post
Share on other sites
stimarco    1071
Quote:
Original post by Stargorger


Alright, so, I realize this question stems from total ignorance and blind n00bness, but what ARE game libraries (specifically graphics ones, like Ogre and Irrlicht) for? I mean, I have read about them over and over again, read their websites, FAQs, etc... but it all assumes you already have a need for or know why you would need one.

I guess I don't understand the point of using them if you're just going to have to write the code from the dirt-up anyway.???


Because you don't do that!

I could build my own chair given the wood, nails and basic woodworking tools. But why should I? It's so much easier to just buy one from a shop.

A code library is like buying a ready-made product instead of building it from a kit or raw materials: Most car manufacturers are quite capable of designing every single model of car they produce from scratch, but why bother reinventing engines, wheels and speedometers each and every time? Far easier to just re-use the same ones you used before. Especially if they're already very good designs.

A graphics library (also known as a graphics "engine", because programmers like to make things seem more complicated than necessary), is just a bunch of pre-written code. It saves me having to write my own, freeing me to concentrate on the fun stuff, like game logic, AI, or whatever I feel needs to have my time and resources lavished upon it.

There's only so much time and money you can spend on a project, so why waste it on building something you can just walk into a shop (so to speak) and grab off the shelf?

(FYI: "GTA III" used such a graphics library. Rockstar have since built their own, in-house, libraries, as EA have effectively killed off Criterion's Renderware.)

Share this post


Link to post
Share on other sites
Stargorger    120
Ah. Gotcha. But I mean, you're still going to have to learn THAT code, learn how to implement it, etc... in order to get it to render the game. I don't mean stuff like DirectX, I mean rendering engines, like you said.

Share this post


Link to post
Share on other sites
stimarco    1071
Quote:
Original post by Stargorger
Ah. Gotcha. But I mean, you're still going to have to learn THAT code, learn how to implement it, etc... in order to get it to render the game. I don't mean stuff like DirectX, I mean rendering engines, like you said.


You don't have to learn anything other than the library's API -- its interface. You certainly don't have to "implement it". Instead of writing a ton of code to load model data, I'd just call "TLModelLoad()" (or whatever). All you need to learn is the knobs, levers and twiddly bits that let you control the library.

I probably couldn't build my own 3D graphics engine, but when I first played with Renderware 3.0, (later "Renderware Graphics"), way back in 2000, I was rendering models and stuff on the screen within a couple of hours. Contrast that with spending months (if not years!) building my own code to do the same thing and you can see how much time was saved.

I know a chap who is building his own libraries and tools from scratch in his spare time. He's a pro and very experienced at this, but he's building his own complete game development library and toolchain from the ground up. (One of his earlier game engines became the starting point for Renderware 3.x, so he knows his stuff.)

He started work a couple of years ago in his spare time. It is now 2008 and he is finally at the point where he can start bringing the elements together: networking, 3D graphics, GUI, audio, editing tools and more. It's taken him *years* to build all this and he's still not quite done. (He knew it would take a long time, and he's done all this three times before as a pro.)

If you want a similar career, then by all means write your own tools and libraries from scratch; no actual harm will come to you! However, if your focus is on making *games*, then you should avoid making more work for yourself.

Share this post


Link to post
Share on other sites
Stargorger    120
Ah. Ok.

Apparently, despite understanding programming in general, and learning languages like C++, I still am a total idiot when it comes to conceptual programming: that is, figuring out which tools to use to accomplish the job. Oh I understand basic stuff, like "use DirectX or OpenGL for graphics libraries", but I still am having a hard time understanding how, exactly, external scripting tools work. I've read some of the documentum on the graphics libraries here, (Ogre, Irrlicht, etc...) and yet they all look like I'd have to A: create my main game loop, B: call on Irrlicht/Ogre/whatever to start their pathing, C: HAVE A SEPERATE CODE for said engine that would THEN call on its own resources to run the graphics. Which, to me, seems like redundant work. If I'm still going to have to program the engine to display stuff when/as I want anyway, does it really save that much time over doing it myself?

Share this post


Link to post
Share on other sites
Kylotan    10008
Yes, hence Sean already answering that question when you worded it slightly differently the first time around. A game program contains lots of low level routines, whether it's things like translating input, storing images in memory, streaming and mixing sounds, moving and colliding objects according to Newtonian physics, finding paths from one part of a map to another, and so on. Writing good code for all these things is a lot of work. If you can get that work already done for you, that is a big benefit. There is no redundant work - you concentrate on the higher level code and the libraries perform the lower level code.

An analogy: if we want to make a cake, we go to the shop to buy eggs, sugar, and flour. The fact that we have to make the cake ourselves out of those ingredients, doesn't mean that we may as well have grown our own sugar, raised our own hens, and ground our own flour. We can concentrate on the baking and they can concentrate on the ingredients.

Share this post


Link to post
Share on other sites
Stargorger    120
Alllllright.

That makes sense. It's all so clear now ;-)

Ok. So, the natural follow-up to this question is... is it beneficial, or will it cripple the higher-level programming, to implement an alternate library or engine for each function in the game? IE, "while using Irrlicht for graphics and Lua for UI may help, trying to use those in conjunction with PhysX and OpenAL is just ridiculous"?

I"m just trying to judge what, if any, of the lower-level direct-block programming (that stuff that alternate engines ought to take care of) I will need to design myself. I'm trying to guage how much work I can save myself before I start trying to design the code for an Array or Library I'll have to write myself.

Thanks again

Share this post


Link to post
Share on other sites
jbadams    25712
Quote:
Original post by Stargorger
If I'm still going to have to program the engine to display stuff when/as I want anyway, does it really save that much time over doing it myself?
Well yes, you are still going to have to write some code to tell your chosen library you want to display (or whatever the library does) something, but think of it this way: would you rather have to write a small amount of code telling an engine what you want to display, or write a small amount of code telling your own functions what to display as well as having to write those functions.

You'd obviously end up (in the case of complex functionality) writing a lot more code if you need to produce the same functionality provided by a library rather than using something already written. If you're using a library, you also don't neccesarily have to know how to implement the functionality provided for yourself - just how to use the library.



Say I create a really small library, SquareDrawer3000! which provides a single function. We'll use some BASIC-like pseudo-code rather than an actual programming language here, but the function in my library might be something like:

// A square drawing function which takes the x and y coordinates at which you wish to draw your square and outputs it to the screen.
DRAW_SQUARE(x_position, y_position):
OUTPUT square at location (x_position, y_position)
END DRAW_SQUARE


So, you now come along and want to write a program which draws 3 squares.

You could do it like this:

OUTPUT square at location(1, 3)
OUTPUT square at location(6, 7)
OUTPUT square at location(8, 2)

...and that would work fine, in our little pretend pseudocode language that will get you 3 squares on the screen. It's not very good programming though, if you wanted a larger number of squares you'd be doing a lot of work, so rather than writing out that line of code each time you could write a function that draws squares... which would pretty much be the same as the one in my library.

Now, drawing a square on screen isn't very hard and so duplicating my function isn't very hard and won't take long, but if you're doing something more complex (like displaying a 3d model) then the difference in productivity between writing your own version or using a library will be pretty big. You also might not know how to write the function yourself, but you don't have to know how if you're using my library - instead you just have to know which function to call from my library (in our silly example it's the only function [wink]).


Does that help?

Share this post


Link to post
Share on other sites
jbadams    25712
Woops, looks like I was a bit slow and missed some conversation whilst typing.

Quote:
Ok. So, the natural follow-up to this question is... is it beneficial, or will it cripple the higher-level programming, to implement an alternate library or engine for each function in the game? IE, "while using Irrlicht for graphics and Lua for UI may help, trying to use those in conjunction with PhysX and OpenAL is just ridiculous"?
It depends, and figuring these things out will come with experience. Some libraries work well together and will save you plenty of time, while others may be quite difficult to use together but will still be worth using rather than writing your own versions in the long run.

In other cases two libraries may be difficult enough to use together that it would not be worth the time and effort of doing so -- in which case you could look at alternatives to use instead of one of the two, or consider only using one library and writing your own code for the other functionality.


Depending on your needs you may also sometimes be able to find an all-in-one library which you could use for a project rather than a selection of seperate libraries.

Share this post


Link to post
Share on other sites
Stargorger    120
I like your example ;-)

Alright, I think I get it now. Yes yes, I see the benefit. ;-) Never meant to be a 'hater.

SO. An example of one of those all in one libraries would be... CrystalSpace? DarkBasic? What? Which one would count as a library for those kinds of scripting functions, rather than just a drag-and-drop engine?

Share this post


Link to post
Share on other sites
Kylotan    10008
They're not 'scripting functions' incidentally. It's important not to use the wrong terminology as it means a completely different thing. Scripting, in the context of game development, means the use of a secondary programming language embedded within your program to aid development. What you're actually referring to are more 'library functions'.

CrystalSpace is a 3D renderer - it provides 3D functionality and that's about it.
DarkBasic is a programming language - you learn its syntax and use its environment to create games, and it handles the low level details for you.
Something like SDL is a library - it too handles low level details, but you use it from within an existing programming language, like C++.

I think, you're possibly looking a little too far ahead. You should start with a simple API/library/engine and make simple games using whatever it provides for you. Browsing their websites usually gives you a good idea of whether it can make what you want. And from that game making experience, you'll learn what functionality you're missing, and know what to look for.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this