Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Managed C++ and Direct3D

Managed C++ and Direct3D

Managed C++ and Direct3D

I have a code snippet and it will not compile.

PresentParameters *pp = new PresentParameters();
pp->Windowed = true;
pp->SwapEffect = SwapEffect::Discard;

this->m_Device = new Device(0, DeviceType::Hardware, target, CreateFlags::SoftwareVertexProcessing, pp);

"target" is a System::Windows::Forms::Control object. The constructor seems to be ok and all data being passed to it as well. I get this compile-time error:

error C2664: 'Microsoft::DirectX::Direct3D::Device::Device(int,Microsoft::DirectX::Direct3D::DeviceType,System::IntPtr,Microsoft::DirectX::Direct3D::CreateFlags,Microsoft::DirectX::Direct3D::PresentParameters __gc * __gc[])' : cannot convert parameter 5 from 'Microsoft::DirectX::Direct3D::PresentParameters __gc *' to 'System::IntPtr'

This makes no sense because in this constructor there is no parameter that needs to be an IntPtr... the constructor is this

Device(int, DeviceType, Control __gc *, CreateFlags, PresentParameters __gc * __gc[]);

Does anyone know why this will not compile?

RE: Managed C++ and Direct3D

Just to clear something up as well. In the Error above it shows the constructor with System::IntPtr as parameter number 3. This is incorrect! the parameter is actually supposed to be "Control __gc *". I have no clue why it shows up in the error this way. Also, if I make the 5th paramter "pp" to NULL it will compile just fine (this will not work at run-time though).

RE: Managed C++ and Direct3D

How does this make sense!!!

I changed the call to the constructor to this

this->m_Device = new Device(0, DeviceType::Hardware, target, CreateFlags::SoftwareVertexProcessing, (IntPtr)&pp);

I did this to satisfy the compilers complaining about Parameter 5 cannot be cast from <whatever> to System::IntPtr! After I made this change and tried to compile, it spit this back at me!

d:\Lab\MapEditor\D3D.cpp(60): error C2664: 'Microsoft::DirectX::Direct3D::Device::Device(int,Microsoft::DirectX::Direct3D::DeviceType,System::IntPtr,Microsoft::DirectX::Direct3D::CreateFlags,Microsoft::DirectX::Direct3D::PresentParameters __gc * __gc[])' : cannot convert parameter 5 from 'System::IntPtr' to 'System::IntPtr'

Now, can someone please tell me how I can't convert a System::IntPte to a System::IntPtr?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close