Game Development Community

Trying to render a line

by Vincent D · in Torque Game Engine Advanced · 01/13/2008 (8:00 am) · 5 replies

Can someone please tell me what I'm doing wrong here:
Point3F end = mCurrVelocity;
	   end.normalize(mClampF((mCurrPosition - mInitialPosition).len(), 1.0, 100));
	   end = mCurrPosition - end;

	   GFX->setZEnable(false);
	   GFX->setCullMode( GFXCullNone );

	   PrimBuild::begin(GFXLineList, 2);
	   PrimBuild::color(ColorF(1.0, 1.0, 0.55));
	   PrimBuild::vertex3f(mCurrPosition.x, mCurrPosition.y, mCurrPosition.z);
	   PrimBuild::vertex3f(end.x, end.y, end.z);
	   PrimBuild::end();

	   GFX->setZEnable(true);
This is so frustrating because I just don't see why this won't work. I don't have much experience with rendering so I'm just copying how it's done elsewhere in the engine.

Anyway, I would really like to know what I did wrong :)

thanks in advance, Vincent

#1
01/13/2008 (9:54 am)
Point list or just a line ?
I think there is missing a render state and buffer to render the primitive.

Look at this example:
www.codesampler.com/dx9src/dx9src_2.htm#dx9_primitive_types
#2
01/13/2008 (11:03 am)
Just a line. The setRenderState method isn't used in other parts of the engine where the same thing hapens ( a line is drawn). And the buffer is created using the PrimBuild::begin function isn't?
#3
01/13/2008 (1:31 pm)
I think this should work (i've not tested it)
GFX->drawLine(x1,y1,x2,y2,color);
#4
01/13/2008 (3:12 pm)
This is probably a transform problem. Where is it getting called from?
#5
01/13/2008 (9:40 pm)
@ Picasso, I think that would draw a 2d line

@ Pat, it's called in Projectile::prepRenderImage(..) below
if (state->isObjectRendered(this))
   {
      prepBatchRender( state );
   }
    // here it is called