Advertisement

reinterpret_cast

Started by February 26, 2002 10:15 PM
4 comments, last by Donald1 22 years, 9 months ago
Hi all,new to gamedev.net & game programming.Looking for help on how to write a reinterpret_cast to get the surface up and running.Im using Vc++ 6 and heres the error, C2664: ''CreateSurface'' : cannot convert parameter 1 from ''struct _DDSURFACEDESC2 *'' to ''struct _DDSURFACEDESC *'' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Thanks Donald
If you''ve never gotten that error before, I suggest you RTFM or get more experience. Either way, I think you can fix the problem by typecasting it like this:
MySurface = (_DDSURFACEDESC *)CreateSurface(...);


You might also want to consider why it''s asking you to do this. Are you certain you want to use a DDSURFACEDESC instead of the (seemingly-newer) DDSURFACEDESC2?

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

[twitter]warrenm[/twitter]

Advertisement
Actually, you probably can''t even do that, if one isn''t derived from the other or there''s no constructor that can handle it.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

[twitter]warrenm[/twitter]

Try checking to see if there''s a different function you should be using: ie. one that takes a pointer to a DDSURFACEDESC2 instead of a DDSURFACEDESC. Sadly, my memory of DirectX details has lapsed somewhat, but ask on the DirectX forum if you can''t work it out.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]
Talk about weird,i just got done copying code from a page on here cant remember the name something genius anyhow word for word and it worked.So i decided to find the bug and got rid of what i copyed and put mine back and its compiling fine.Thanks for the help also i did to much RTFMing.
Donald
Just Figured it out left out the 7 in my call to directdraw.
if(FAILED(lpdd7->CreateSurface(&ddsd, &lpddsprimary, NULL))).
Donald

This topic is closed to new replies.

Advertisement