Sign in to follow this  

Abstract Light Classes

This topic is 4713 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

I'm currently designing my very first DirectX project, a rather simple graphics engine. Right now I'm working on the lighting system, and I would like to know if the method I'm using for representing lights is efficient: Currently I created a generic light class, which contains all the data required by a direct3D light source. This is the data that is handled throughout the engine. When it comes to rendering, the ID of this light source is sent to the video handler, where there is a linked list of all the registered light sources. Once the handler finds the light within the list, it will put it in its assigned spot within the D3DLIGHT9 array, which contains room for 8 light sources. The video handler takes care to transform the engine light data into direct3D light data, and then put the converted light into the array. Am I using an inefficient method? Am I working too much? Any comments would be appreciated.

Share this post


Link to post
Share on other sites
Quote:
Original post by Asterisk Man
I'm currently designing my very first DirectX project, a rather simple graphics engine.


First off, the terms 'first project' and 'engine' should never go in the same sentence. But I'll humor you by continuing to give my suggestions.

Quote:
Original post by Asterisk Man
Right now I'm working on the lighting system, and I would like to know if the method I'm using for representing lights is efficient:

Currently I created a generic light class, which contains all the data required by a direct3D light source. This is the data that is handled throughout the engine.


Sounds okay so far.

Quote:
Original post by Asterisk ManWhen it comes to rendering, the ID of this light source is sent to the video handler, where there is a linked list of all the registered light sources. Once the handler finds the light within the list, it will put it in its assigned spot within the D3DLIGHT9 array, which contains room for 8 light sources. The video handler takes care to transform the engine light data into direct3D light data, and then put the converted light into the array.


It sounds as though you're walking the linked list everytime a light is bound. This is an O(n) linear search which is definitely not efficient. Aside from that I don't see any major pitfalls with your design.

Feel free to ask if you need further guidance.

[Edited by - Sages on January 20, 2005 7:50:24 PM]

Share this post


Link to post
Share on other sites
Yeah, I realize it sounds too ambitious to even attempt making a graphics engine while learning directX, but so far it's working out for me.

Regarding the light searching, would it be a better idea to check if the light is already in one of the d3dlight locations, along with another search algorithm? That way I can use that array both as a cache for lights, and as a final location for processed lights.

Share this post


Link to post
Share on other sites

This topic is 4713 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.

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