Re: DrawUserPrimitives error "Operation is not valid due to the current state of the object"
- From: Stephan Rose <kermos@xxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 12 Aug 2006 04:27:29 +0200
On Sat, 12 Aug 2006 08:36:37 +1000, "Wayne Allen" <uuandem@xxxxxxxxx>
wrote:
I have repositioned the line, but the error still occurs. Any other ideas?
My OnPaint handler now looks like this:
protected: virtual void OnPaint(PaintEventArgs ^e) override {
// How long has elapsed
double gameTime = _elapsedTimer->ElapsedMilliseconds / 1000.0;
double elapsedTime = gameTime - _lastTime;
_lastTime = gameTime;
this->Text = String::Format("The framerate is {0}",
FrameRate::CalculateFrameRate());
_device->BeginScene();
_device->Clear(ClearFlags::Target, Color::Black, 1.0f, 0);
_device->Transform->View = Matrix::LookAtLH(Vector3(0.0, 0.0, 5.0),
Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0));
_device->Transform->Projection =
Matrix::PerspectiveFovLH((float)Math::PI/4, (float)this->Width /
(float)this->Height, 1.0, 100.0);
_device->RenderState->Lighting = false;
_device->RenderState->CullMode = Cull::None;
_device->VertexFormat =
Microsoft::DirectX::Direct3D::CustomVertex::PositionColored::Format;
// The error occurs at this line
_device->DrawUserPrimitives(PrimitiveType::LineStrip, 6,
CreateCrossHairVertexArrayTop());
_device->EndScene();
_device->Present();
this->Invalidate();
}
The only other thing I can think of is that maybe there is a stream
source set that shouldn't be.
Before setting the vertex format, add this line.
device.SetStreamSource(0, null, 0);
Oh and move the Clear above BeginScene.
Hereis what my begin render code looks like on my engine (in C#):
device.Clear(ClearFlags.Target|ClearFlags.ZBuffer,Color.Black,1.0f,0);
device.BeginScene();
device.SetStreamSource(0, null, 0);
device.VertexFormat = StandardVertex.Format;
// DrawUserPrimitive calls follow
device.EndScene();
device.Present(clientArea,window,true);
I have additional parameters for Present since my app has multiple MDI
windows it needs to render to. You don't need to worry about those
additional paramters in Present for your purposes.
But that's it...
--
Stephan
2003 Yamaha R6
kimi no koto omoidasu hi
nante nai no wa
kimi no koto wasureta toki ga nai kara
.
- References:
- DrawUserPrimitives error "Operation is not valid due to the current state of the object"
- From: Wayne Allen
- Re: DrawUserPrimitives error "Operation is not valid due to the current state of the object"
- From: Stephan Rose
- Re: DrawUserPrimitives error "Operation is not valid due to the current state of the object"
- From: Wayne Allen
- Re: DrawUserPrimitives error "Operation is not valid due to the current state of the object"
- From: Stephan Rose
- Re: DrawUserPrimitives error "Operation is not valid due to the current state of the object"
- From: Stephan Rose
- Re: DrawUserPrimitives error "Operation is not valid due to the current state of the object"
- From: Wayne Allen
- DrawUserPrimitives error "Operation is not valid due to the current state of the object"
- Prev by Date: Re: DrawUserPrimitives error "Operation is not valid due to the current state of the object"
- Next by Date: From GDI+ to DirectX
- Previous by thread: Re: DrawUserPrimitives error "Operation is not valid due to the current state of the object"
- Next by thread: Re: DX Window always on top after fullscreen switch
- Index(es):
Relevant Pages
|
Loading