Re: Problem with converting Managed Direct3D tutorial 2 from C# to C++

From: Phil Taylor (phil_at_private-citizen.com)
Date: 12/27/04


Date: Mon, 27 Dec 2004 09:43:01 -0800

does the VB get created?

you dont check any return codes, and assume all calls succeed. so of course
if a call fails, you get an exception because you are then using NULL
objects.

the debug runtime output stream will contain more info. make sure you are
using the debug runtime, turn up the debug level in the control panel
applet, turn on unmanaged debugging in the IDE, and examine the debug
output.

"Palek" <thisisnot@avalidaddre.ss> wrote in message
news:310DEA35-4B07-4010-AD7E-ED88F11D8079@microsoft.com...
> This may be the simplest problem yet that this board has ever seen, but
> alas
> I cannot find a solution on my own. I will greatly appreciate any help or
> hints I can get.
>
> I am using Visual C++ 2005 Express, .NET SDK 2.0 and the DirectX 9.0
> December Update on a Windows XP SP2 machine. Here is the code that's
> giving
> me migraines.
>
> <snip>
> private: System::Void OnCreateDevice(Object^ sender, EventArgs^ e)
> {
> Device^ dev = dynamic_cast<Device^>(sender);
> CustomVertex::TransformedColored^ vertTemp = gcnew
> CustomVertex::TransformedColored(Vector4(0, 0, 0, 0), 0);
> vertexBuffer = gcnew VertexBuffer(vertTemp->GetType(), 3, dev,
> Usage::None,
> CustomVertex::TransformedColored::Format, Pool::Default);
> vertexBuffer->Created += gcnew System::EventHandler(this,
> &Form1::OnCreateVertexBuffer);
> this->OnCreateVertexBuffer(vertexBuffer, nullptr);
> }
>
> private: System::Void OnCreateVertexBuffer(Object^ sender, EventArgs^ e)
> {
> VertexBuffer^ vb = dynamic_cast<VertexBuffer^>(sender);
> array<CustomVertex::TransformedColored^>^ verts = gcnew
> array<CustomVertex::TransformedColored^>(3);
> verts[0] = gcnew CustomVertex::TransformedColored(150, 50, 0.5f, 1,
> System::Drawing::Color::Aqua.ToArgb());
> verts[1] = gcnew CustomVertex::TransformedColored(250, 250, 0.5f, 1,
> System::Drawing::Color::Brown.ToArgb());
> verts[2] = gcnew CustomVertex::TransformedColored(50, 250, 0.5f, 1,
> System::Drawing::Color::LightPink.ToArgb());
> GraphicsStream^ stm = vb->Lock(0, 0, LockFlags::None);
> try {
> stm->Write(verts);
> }
> catch (InvalidOperationException^ ex) {
> String^ szMessage = ex->ToString();
> MessageBox::Show(szMessage, L"Whoopie-do");
> }
> vb->Unlock();
> }
> </snip>
> The rest of my program is exactly the same as the tutorial application in
> the Direct3D documentation, except that it is rewritten in C++ of course.
> Up
> to the point of completing tutorial 1 it was working fine, meaning that I
> got
> a little window cleared to a blue background. After adding the code above
> (and the necessary lines to render the scene), I keep receiving an
> InvalidOperationException error for the Write operation to the
> GraphicsStream
> - hence the try-catch addition to get the program to even run. The
> MessageBox
> reveals that within the Write method
> Microsoft.DirectX.DXHelp.GetObjectSize
> is called, which in turn calls Microsoft.DirectX.DXHelp.GetTypeSize, and
> this
> is where the exception is thrown.
>
> Does anyone have any ideas how I could correct this problem? Thank you
> very
> much in advance.



Relevant Pages

  • Re: CreateDevice fails
    ... the debug runtime output always contains info for a failure. ... Richard [Microsoft Direct3D MVP] wrote: ... Standard questions apply: ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Something wrong with GeForce DDR
    ... > if you cant ask the customer to install the debug runtime and get more ... > did the call with multisample none also fail then? ... >> there is always debug runtime output for failed calls. ... >> Unable to create IDirect3DDevice9 on GeForce DDR. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Terrain weirdness
    ... what size chunk? ... what are the caps for max vertex? ... what does the debug runtime output say in both cases? ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Something wrong with GeForce DDR
    ... if you cant ask the customer to install the debug runtime and get more ... It happened on the customer end. ... > there is always debug runtime output for failed calls. ... > Unable to create IDirect3DDevice9 on GeForce DDR. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: IndexBuffer
    ... [Please do not mail me a copy of your followup] ... but I thought the runtime would throw an exception if this ... debug runtime installed? ... Legalize Adulthood! ...
    (microsoft.public.win32.programmer.directx.managed)