Skip to main content
gamedev.net
🔒 Locked

Dynamic maths library implementation

Started by samgzman 1 reply 450+ views
Original Post
samgzman
samgzman
Lets say one wanted to implement a maths library which selected optimized math routines (class methods) for the system it ran on at run-time. It seems to me that the most logical way to implement such a system would be to use an abstract class (of a vecor or matrix) and then derive child classes for each system optimization and also a standard one w/ no hardware enhancements. Then, use a class facotry to spawn the proper object instance from the appropriate class. However, from what i read, this approach might not be the best due to the overhead that comes w/ virtual functions. I have read the other topics which suggest compiling different versions, but my main objective is to create a system that adapts at runtime. Anyone have any thoughts or suggestions as to the most clever and efficient implementation??
PeterTarkus
PeterTarkus
There is a projet called SoftWire which allows you to conditionally execute assembler code. I haven''t used it yet, it is interesting though and designed for problems like that.

I forget http://softwire.sourceforge.net I think is the address.
snk_kid
snk_kid
I think if you look at the Strategy design pattern it might be helpful but i dont think a dynamic math library would be very effcient especially for vector & matrices where you will use them heavily, i think you''d be better off using static polymorphism and implement strategy pattern as template parameter the only problem is you wont be able to change the strategy at runtime.

Topic Locked

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

Sign in to reply to this topic.