Skip to main content
GameDev.net gamedev.net
🔒 Locked

STL Vs C

Started by Naveed Ahmed Oct 11, 2000 at 9:30 AM 5 replies 850+ views
Original Post
Naveed Ahmed
Naveed Ahmed
Does STL slows your code, when used with OpenGL, I hav''nt checked it yet, but I am suing STL in my code, using Vector container. A friend of mine who is writing 3D engine at pixel level, using DirectDraw told me that when he used STL a notic drop in frame rate was observed. Anyone else used STL with OpenGL?
Graham Reeds
Graham Reeds
Generally, STL is slower than doing your own routines. However, STL is designed to be bullet-proof, so it is good for getting your code up and running about with minimum of hassle (I think that STL was designed with normal apps in mind rather than games). When you''ve "finished" your game you then go back and if STL is taking up a significant percentage of processor time, you code your own versions of the functions you use out of STL.

Else you can leave it in and not have to worry about bugs in that part of your code!!




Stay Lucky, Graham "Mournblade" Reeds.
Stay Lucky, Graham "Mournblade" Reeds.The Ivory Tower
Risteard
Risteard
STL SLOWER?
I don''t know where you got the info that STL is slow, but it''s dead wrong. STL was built for SPEED. Period. Iterators do no bounds checking, and the algo''s in STL are optimized for pure speed. If STL is slowing you down, LIKELY you are choosing the wrong algo or container for what you need.

If you don''t believe me, just try looking at the book Game Programming Gems which STRONGLY recommends STL.


Richard Ashkettle

Morbo
Morbo
Like most things C++, the STL _can_ be slow if you don''t use it right.

For example, the vector class is a dynamic array. This means that use a heavy-weight object in the vector (like std::vector), it''s going to have to copy around a lot of bytes to resize the array. If you really want to stick with a vector, store pointers instead (std::vector), and just remember to free them at the end. Or, even better, use a list (bi-directionaly linked list).

But Risteard is correct, STL was designed to be fast and effecient. You just have to know which containers to use when. I personally don''t like the syntax it uses for a lot of things, so I just write light-weight wrappers. Learn how to work with STL, and you can save yourself whole heaps of time.

Morbo
Graham Reeds
Graham Reeds
Okay - I stand corrected.


Stay Lucky, Graham "Mournblade" Reeds.
http://homepage.dtn.ntl.com/grahamr
Stay Lucky, Graham "Mournblade" Reeds.The Ivory Tower
real_man
real_man
What is STL?

Where can I find a link explaining it?
Cel
Cel
STL - Standard Template Library

Its a set of pre made abstract data structures for the purpose of making lists/sets etc of data at a very abstract level (ie dont have to make a list for a certain data type etc).

Any intermediate C++ text book should have info on STL and templates, or a search on the net should find something.

Cel
Cel aka Razehttp://chopper2k.qgl.org

Topic Locked

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

Sign in to reply to this topic.