Drawing a simple rectangle

Hello - I'm trying to use XNA to draw a simple rectangle at the moment, using DrawIndexedPrimitives. I've tried tweaking and adding many different things but I can't even get anything to show, just the plain black screen (and yes, everything else like textures are rendering fine).
Here's my code:

Declarations:

Protected vb As VertexBuffer, ib As IndexBuffer
Protected vertexData As VertexPositionColor(), indexData As Integer()

DeviceCreated event:

vb = New VertexBuffer( _
graphics.GraphicsDevice, _
GetType(VertexPositionColor), _
4, _
ResourceUsage.WriteOnly, _
ResourcePool.Managed)

ib = New IndexBuffer( _
graphics.GraphicsDevice, _
GetType(Integer), _
6, _
ResourceUsage.WriteOnly, _
ResourcePool.Managed)

vertexData = New VertexPositionColor(3) {}

vertexData(0) = New VertexPositionColor(New Vector3(0, 0, 0), Color.White)
vertexData(1) = New VertexPositionColor(New Vector3(100, 0, 0), Color.White)
vertexData(2) = New VertexPositionColor(New Vector3(0, 100, 0), Color.White)
vertexData(3) = New VertexPositionColor(New Vector3(100, 100, 0), Color.White)

indexData = New Integer(5) {}

indexData(0) = 0
indexData(1) = 1
indexData(2) = 2
indexData(3) = 1
indexData(4) = 2
indexData(5) = 3

vb.SetData(Of VertexPositionColor)(vertexData, 0, vertexData.Length, SetDataOptions.None)
ib.SetData(Of Integer)(indexData, 0, indexData.Length, SetDataOptions.None)

Drawing/Rendering:

Using vertexDecl As New VertexDeclaration(graphicsDevice, VertexPositionColor.VertexElements)
graphicsDevice.Indices = ib
graphicsDevice.Vertices(0).SetSource(vb, 0, VertexPositionColor.SizeInBytes)
graphicsDevice.VertexDeclaration = vertexDecl

graphicsDevice.DrawIndexedPrimitives( _
PrimitiveType.TriangleList, _
0, 0, vertexData.Length, 0, _
indexData.Length / 3)
End Using

It seems to me that this is a simple problem, but there are no simple tutorials for this yet. I would appreciate very much if someone could take a look at tell me, or at least suggest what's wrong. :) Thanks in advance...

[2291 byte] By [Alex-MyRpg] at [2007-12-25]
# 1
Anyone? Wow, I thought there were meant to be some experienced developers around here... and this is about as simple a question as one could get it seems :S I still appreciate any sort of direction...
Alex-MyRpg at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 2

Alex-MyRpg wrote:
Anyone? Wow, I thought there were meant to be some experienced developers around here... and this is about as simple a question as one could get it seems :S I still appreciate any sort of direction...

Just a helpful hint...being rude or insulting to the members of the forum isn't going to help you get your question answered. I've only been sealing with 2d sprites so far do I can't help you but you may want to change your tone.

BillReiss at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 3
No, you completely misunderstood me. Sorry that you were offended - I was getting impatient as I'm at a critical point in devlopment, but I actually meant that people were ignoring me because it is a simple question and they think that the solution should be plain and obvious. All I'm trying to say is that this is important to me, and I appreciate a reply even if it's just: "This feature isn't possible with XNA at the moment, please wait for the next release," or even, "This is a more complicated task than you may think" Please understand that having no documentation, only a few tutorials on limited subjects (though the tutorials that do exist are generally of good quality and helpful), and receiving few replies on any of my threads, it is no simple task to use XNA. I am merely trying to bring to the attention of the experts out there that there help is needed and gratefully accepted, as I said in my previous posts!
Alex-MyRpg at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 4
Are you using a shader or Effect? I'd start with the BasicEffect. You need to tell the GraphicsDevice "how" you want to draw the rectangle, which is what an Effect is for.
MitchWalker-MSFT at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 5
Thank you for your reply... I guess the pros are out there, just busy. :) Anyway I *have* tried that but it seemed to produce an error on "CommitChanges", though I was probably doing something wrong. I'm not really familiar with this, because this wasn't needed in MDX 1.1/2.0. I'll search around but if you could provide a link/brief code sample that would be great.
Alex-MyRpg at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 6

I'm into 2D stuff at the moment but I think you might want to take a look here

There is already posted a lot more closely related to your question,

the answer should be already there

if you search like a 'pro' you don't need to get impatient.....

excuse my noobish reply

cheers

Shellacc at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 7
thanks, but i think i'll just wait until the XNA team add the feature. ;) it seems extremeley excessive to create a shader from a fancy effect file just to draw a line. Either way, that page certainly doesn't show up near the top of any common search regarding the topics, but nice job finding it! :P :)
AlexReg at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 8
It may seem like a lot of work to do, but it's not so bad. I have a really simple project up on my site that's intended to be used as a starting point for writing a program with effects, vertex buffers, index buffers and so on. It's called "Simple Program". There's not a lot on the site at the moment so you should be able to find it pretty easily, or you can just search for "simple".

Hopefully it helps

DerekNedelman at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 9
Yeah I know it's not *that* bad but it's still overkill. Just think how much simpler it is in GDI+ (even though it may be a bit slower - but I'm starting to doubt even that in the case of lines). Thanks for the suggestion, I may check it out.
Alex-MyRpg at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...