Should evey object have it's own LPDIRECT3DDEVICE9?

Started by
14 comments, last by D3DXVECTOR3 19 years, 11 months ago
Every D3D object contains a pointer to the D3D Device already...4 bytes isn''t a big deal, and is probably less cumbersome than passing the pointer for function calls.

Personally, I use a singleton-based system with a global macro that allows me to simply call:

RenderEngine.GetDevice()->DrawPrimitive()

Nice, clean, easy.

Wee.

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

Advertisement
Yes Etnu that is what I have been advocating and seems to be what most people do. Its not the overhead of passing the pointer around but rather the clumsiness of it and the alternative of storing multiple pointers to the same memory scares me - but then I tend to code defensively
------------------------See my games programming site at: www.toymaker.info
If adding a device pointer to your objects adds 50MB, you
have a serious spectre problem.

Unless you're creating 12500000 objects.

One 100x100 32-bit bitmap uses 40000 bytes of memory.
One device pointer uses 4 bytes. One bitmap = enough
memory for 10,000 pointers.

This is a beginner phobia that will desolve over time.

[edited by - Jiia on May 18, 2004 11:42:52 PM]
what i do is when initialising the class that requires the device is initialise it with the dx code and then use the getdevice() function if it is required later from what ever objects you are using eg vertexbuffers

eg in loadMesh() you initialise your program with the device

and with renderMesh() you use gMesh->getDevice() to get the device back

im not sure if this is regarded as a bad way, anyone know? eg slower?

[edited by - johnnyBravo on May 19, 2004 1:28:40 AM]
To answer that we would need to know what goes on in the dx code when that call is invoked i.e. the source code. Unless some kind Microsoft person would give the answer
------------------------See my games programming site at: www.toymaker.info
I have found the reason going from 50MB to 100MB. its on one of the textures I load. 5 Textures and the largest is ''only'' 512*512. But still I''d like to know what the best solution is. I see some idea''s on how you some of you do it so I will look into that.

Wait a sec, I have the sode from ALLEGIANCE, time to take a look into it on how they have done it

This topic is closed to new replies.

Advertisement