Jump to content
  • Advertisement
Sign in to follow this  
bavaratie

memory usage and 3D object loading

This topic is 4865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im building my second 3D engine now... my last program was to slow.. i have some irritating because everyone gives other answers... this is my final try i gues :p >> - objects: can i use 3DS objects for large arreas? i mscared that it will absob all my memory... - moving in a world: is replacing the camera realy that slow that i should turn the world? - push and pop is best way to build up my world each frame? - textures: till now i use bmp, are their smaller and at the sametime faster possibilitys? any other sugestions to keep cpu and memory usage low? thnks in advance

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by bavaratie
- objects: can i use 3DS objects for large arreas? i mscared that it will absob all my memory...

The file format you use is irrelevant. The polygon count of the objects, and their visibility, is what you should concentrate on. Look into topics such as spatial partitioning (octree, quadtree, etc.) and frustum culling to make sure that geometry which can't be seen by the player isn't drawn. You'll save a lot of GPU calls.

Quote:
Original post by bavaratie
- moving in a world: is replacing the camera realy that slow that i should turn the world?

Well, you always "turn the world" anyway. The view position in a 3D application never changes; that's an illusion. You move the geometry in the scene with the modelview matrix. You don't mention how you're positioning the camera, but this is generally a trivial matter. Any camera transform can be converted to a matrix, and loaded into the modelview matrix with one call to glLoadMatrix. Even if you don't convert it to a matrix, it's only one call to gluLookAt (with position, look-at vector and up vector), or three calls to glRotatef and one to glTranslatef (with Euler angles orientation and position).

Quote:
Original post by bavaratie
- push and pop is best way to build up my world each frame?

Yes, generally it is. Just be aware that there's a limit to the number of times you can call glPushMatrix. The matrix stack in OpenGL isn't infinite (you can find out what it is on your machine using glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, depth). It should be at least 16).

Quote:
Original post by bavaratie
- textures: till now i use bmp, are their smaller and at the sametime faster possibilitys?

"Faster" isn't that much of an issue; a 256x256 BMP file won't take that much longer in real terms to load than a 256x256 JPEG file (which has to be decompressed first), and it will only add milliseconds to your game's loading. I'd look into the DDS, JPEG, TGA and PNG formats. They're all very useful, and all can employ some kind of compression (from simple run-length encoding in TGA to complex algorithms in JPEG). PNG is my file format of choice. The compression is loss-less, so it retains the quality of a BMP file, but can be up to 10 times smaller than the BMP file would be. Due to the complexity of loading JPEG and PNG files, it's easier to use a library. PNG has libpng, JPEG has libjpeg. Alternatively, you could use something like DevIL, which supports loading and saving of a large number of image formats.

Quote:
Original post by bavaratie
any other sugestions to keep cpu and memory usage low?

Use instances as much as you can. Try not to load a texture, for example, any more than once. If two or more objects want to use a particular texture, make sure that they use the same one. This applies to meshes, sounds and many other things. Obviously, many things can't be instanced (they're unique to the object which holds them), but you can save a lot of system and video RAM with instancing...

Share this post


Link to post
Share on other sites
I can't add much, but I just thought I'd mention that compressed images are, in my experience at least, much faster to load than others. The hard drive is the bottleneck here, the time it takes to decompress is not significant. But I suspect that is not a real issue for you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!