PDA

View Full Version : FeedBack problem



09-11-2003, 09:56 PM
I am drawing a triangle on my Delphi Panel component that on my form. I want to get x,y,z values of 3 points after translate or rotate this triangle. My simple code is:

var
Buffer : array[ 0..30 ] of GLfloat;
.....
procedure TForm1.DrawShape( draw: boolean );
const
glfMaterialColor: Array[ 0..3 ] of
GLfloat = ( 1.0, 0.0, 0.0, 1.0 );
begin
glMatrixMode(GL_projection);
glLoadIdentity;
if draw = false then
begin
glFeedbackBuffer( length( Buffer ),
GL_3D, @Buffer );
glRenderMode( GL_FEEDBACK );
end;

glRotatef( Angle, 0.0, 0.0, 1.0 );

glMaterialfv(GL_FRONT,
GL_AMBIENT_AND_DIFFUSE, @glfMaterialColor);

glBegin( GL_TRIANGLES );
glNormal3f( 0.0, 0.0, 1.0 );
glVertex3f( 0.3, 0.4, 0.0 );
glVertex3f( -0.1, 0.1, 0.0 );
glVertex3f( 0.5, 0.1, 0.0 );
glEnd();

if draw = false
then glRenderMod(GL_RENDER);
end;

1-When I call 'draw' procedure with false parameter, new coordinates of triangle is filled in the Buffer. But only X values are correct...Y and Z values are incorrect..? Is there any wrong in this code?
2- Is there any way to obtain new coordinates of triangle in this range: [0..1]
I mean, this values will not be like screen coordinates. not like this:v1(230,329), v2(345,123)..
like this:v1(0.5,-0.1,0.0), v2(0.3,0.1,-0.2)