Archived

This topic is now archived and is closed to further replies.

SetPixel funtion pointers

This topic is 6252 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 have a set of functions for plotting pixels in different colour depth''s. eg void PlotPixel16 (USHORT *buffer, int lpitch, int x, int y, DWORD color); I have a function pointer that gets pointed to the correct pixel plotting function depending on the colour depth. I''ve just realized that the buffer has to be cast to a diffferent type for different colour depths, therefore the PlotPixel functions have diffrent declarations and the function pointer doesn''t like that. How should I do this? I spose i could have the buffer as a *void then cast it to the right data type (in the plot pixel funtion), but what performance impact would that have? Also can you inline function pointers? ----------------------------- -cow_in_the_well http://cowswell.gda.ods.org/ - Panic -

Share this post


Link to post
Share on other sites
I think using function pointers is a good idea in this case. Just set the appropriate function at the initialization section of your program.

-------------------------------
I'll screw up whoever screws around with the gamedev forum!

..-=gLaDiAtOr=-..

Share this post


Link to post
Share on other sites
Yes, that''s correct. You need to have a void* and then type-cast it in each function.

-------------------------------
I'll screw up whoever screws around with the gamedev forum!

..-=gLaDiAtOr=-..

Share this post


Link to post
Share on other sites