Help me whit OpenGlSimpleControl

Hi! Sorry I'm Spanish Girld, my english is something poor.

Actually, I'm using the OpenGlSimpleControl with windows Forms in Visual 2005, with C#.

I have drawed quads, triangles, and other polygons 3D and 2D. But I haven't got used to the keyboard to move the polygons. I want to use the events KeyUp or KeyDown for this purpose.

Could Anyone help me? Send me an example for this?

I hope that you understand me, sorry for my english.

Thanks everybody

My SimpleOpenGLControl is

My SimpleOpenGLControl is called "MapGLControl"

AdjustZoom and AdjustRotation are methods that just make sure the new value of Zoom/Rotation is correct.

When I render, I make use of the Rotation and Zoom variables. i.e.

Gl.glRotate3f( 0.0f, Rotation, 0.0f ); //Rotation is a float

Here's the code:

private void MapGLControl_KeyDown( object sender, KeyEventArgs e )
{
if( e.KeyCode == Keys.Z )
{
AdjustZoom( 1.0f );
}
else if( e.KeyCode == Keys.X )
{
AdjustZoom( -1.0f );
}
else if( e.KeyCode == Keys.Add )
{
AdjustRotation( 3.0f );
}
else if( e.KeyCode == Keys.Subtract )
{
AdjustRotation( -3.0f );
}
}

Thanks by your answer, I'll

Thanks by your answer, I'll try it.
But, I have using a function called renderize, which, draw the scene.

My code will be like this:

float zoom;

private void MapGLControl_KeyDown( object sender, KeyEventArgs e )
{
if( e.KeyCode == Keys.Z )
{
zoom = 1.0f;
}
else if( e.KeyCode == Keys.X )
{
zoom = -1.0f ;
}
}

in the function Renderize:

glTranslatef ( 0.0f,0.0f,zoom);

something like this. But this code don't work.

Based on that example,

Based on that example, you're not initializing zoom to anything, and pressing X or Z will just set zoom to 1.0 or -1.0; wouldn't it make more sense to increment/decrement it? Such as:

float zoom = 0.0f;

private void MapGLControl_KeyDown( object sender, KeyEventArgs e )
{
if( e.KeyCode == Keys.Z )
{
zoom += 1.0f;
}
else if( e.KeyCode == Keys.X )
{
zoom -= 1.0f;
}
}

BTW, you can't use KeyDown to check for certain special keys, such as the arrow keys...see the post Key Events for the solution to that problem.

Thank's, Could you send me a

Thank's, Could you send me a complete example of this??

At least, an expample whith a polygon 3D, which, can move whith keyboard. But complete, please.
I'll Thank you very much.

Example application sent.

Example application sent. Let me know if you didn't get it!

Theme by La Boite a site | Powered by Drupal