Neoforce ControlsNeoforce ControlsDiscussionsDiscussionsSupportSupportDrawing 3d Objects inside controlsDrawing 3d Objects inside controls
Previous Previous
 
Next Next
New Post
 3/1/2010 8:14 PM
 

Hi

Been using your GUI for my game, and it's been working great.

But i have a problem right now, i was wondering if it was possible to draw 3D elements inside the windows/controls, i've overriden the draw event, and was trying to draw a quad, but i keep getting an error when i'm drawing it: "A valid vertex buffer (and a valid index buffer if you are using indexed primitives) must be set on the device before any draw operations may be performed." So is this even possible, or am i just doing something wrong.

The quad isn't using vertex buffers or index buffers, it's just a normal DrawUserIndexedPrimtives call

_graphics.DrawUserIndexedPrimitives
<VertexPositionNormalTexture>(
PrimitiveType.TriangleList,
QuadtoDraw.verts, 0, 4,
QuadtoDraw.Indexes, 0, 2);

New Post
 3/3/2010 5:46 AM
 
Hi,

this should be possible, I will try it and let you know how it works.

Tom Shane
New Post
 3/7/2010 9:12 PM
 

I have done this and it works best if you use a RenderTarget and then draw just the texture to the window. I can provide sample code if you like. It can be a little tricky getting the correct setup on the RenderTarget and DepthStencilBuffer.

New Post
 3/8/2010 1:55 PM
 

Hey

I'd very much like to see that code. i tried something along those lines, and got my drawing working, but it seemed slow and lagging. the game still maintained a steady 60 FPS. Note i'm i was running this with fixedtimestep, without it maintains around 2500fps, so it's not the the game itself that is slow, but probably my way doing this.

New Post
 3/9/2010 2:33 AM
 
 Modified By Matt  on 3/9/2010 3:36:45 AM

Well if you were using a render target then Neoforce only updates at the target frame rate, which defaults at 60 fps.

Here is a video of my test program.

http://www.youtube.com/watch?v=-sqhD-...

I don't have this exact code available right now (I am modifiying it for a physics app) but it's really quite simple I will try an write up another example by this weekend and post it up for you.

It basically just creates a RenderTarget and DepthStencilBuffer, renders whatever you want to it and then sets the resulting texture to an ImageBox. Some things to note is that you must call Invalidate() for the ImageBox or the ClientArea of the window. Also Neoforce sets up it's own RenderTargets not ready for 3D rendering that's why I created my own. You can render directly to a Neoforce window but you must make sure ALL of the graphics device settings are correct to include creating and setting a DepthStencilBuffer.

New Post
 3/11/2010 9:24 PM
 

Here is a basic demo. Only thing not working is the input, but that is because I had no intentions of using windows, only buttons and track bars and possibly menus.

http://www.mediafire.com/?2mojtoymeyi

New Post
 3/15/2010 4:33 PM
 

Hi

Sorry for the late reply, been quite buys :) But thanks to your example i got my code working nicely now :) thanks alot :)

New Post
 6/24/2010 11:25 AM
 
 Modified By Noir707  on 6/24/2010 11:40:58 AM
Hi,
I'm quite new to NeoForce controls and to XNA in general.
I downloaded your demo from mediafire and compiled it.
Compilation is successfull (only 3 warnings about never used things).
Trying to run it I get the following error:

System.InvalidOperationException was unhandled
Message="An unexpected error has occurred."
Source="Microsoft.Xna.Framework"
StackTrace:
in Microsoft.Xna.Framework.Graphics.RenderTarget.CreateRenderTarget(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Int32 numberLevels, SurfaceFormat format, MultiSampleType multiSampleType, Int32 multiSampleQuality, RenderTargetUsage usage, Boolean isTexture2D, _D3DSURFACE_DESC* pDesc)
in Microsoft.Xna.Framework.Graphics.RenderTarget..ctor(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Int32 numberLevels, SurfaceFormat format, MultiSampleType multiSampleType, Int32 multiSampleQuality, RenderTargetUsage usage, Boolean isTexture2D)
in Microsoft.Xna.Framework.Graphics.RenderTarget2D..ctor(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Int32 numberLevels, SurfaceFormat format, MultiSampleType multiSampleType, Int32 multiSampleQuality, RenderTargetUsage usage)
in Box2DEditor.Game1.LoadContent() in Box2DEditor\Box2DEditor\Game1.cs:riga 201
in Microsoft.Xna.Framework.Game.Initialize()
in Box2DEditor.Game1.Initialize() in Box2DEditor\Box2DEditor\Game1.cs:riga 178
in Microsoft.Xna.Framework.Game.Run()
in Box2DEditor.Program.Main(String[] args) in Box2DEditor\Box2DEditor\Program.cs:riga 14

I can't understand what is the problem..could you please help me?

EDIT:
Ok, solved.
I changed the renderTarget constructor copying the one from the source samples of NeoForce and i changed the depthBuffer constructor for a second error.
Now it is working.
I think I'll study a bit about renderTarget.

Thank you for the demo :)
Previous Previous
 
Next Next
Neoforce ControlsNeoforce ControlsDiscussionsDiscussionsSupportSupportDrawing 3d Objects inside controlsDrawing 3d Objects inside controls