Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
16 views1 page

glTVControl New GLControl (New Ope

The document outlines the initialization of a GLControl for OpenTK graphics with specified dimensions and positioning. It includes a method to set up the viewport for either an orthographic projection for a top view or a perspective projection for a normal view, adjusting the matrix accordingly. The method utilizes OpenGL functions to configure the projection based on the specified view type.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

glTVControl New GLControl (New Ope

The document outlines the initialization of a GLControl for OpenTK graphics with specified dimensions and positioning. It includes a method to set up the viewport for either an orthographic projection for a top view or a perspective projection for a normal view, adjusting the matrix accordingly. The method utilizes OpenGL functions to configure the projection based on the specified view type.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

glTVControl = new GLControl(new OpenTK.Graphics.

GraphicsMode(32, 24, 8, 4));


// glTVControl.Dock = DockStyle.Fill;
glTVControl.Left = 400;
glTVControl.Top = 40;
glTVControl.Width = 400;
glTVControl.Height = 400;
this.Controls.Add(glTVControl);

private void SetupViewportOrthoGraphic(bool isTopView)


{
glTVControl.MakeCurrent();
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();

if (isTopView)
{
// Orthographic Projection for Top View
// Orthographic projection for top view
GL.Ortho(-gridSize, gridSize, -gridSize, gridSize, -10, 10);

// GL.Ortho(-50, 50, -50, 50, -100, 100); // Left, Right, Bottom, Top,
Near, Far
}
else
{
// Perspective Projection for Normal View
float aspectRatio = Width / (float)Height;
Matrix4 perspective = Matrix4.CreatePerspectiveFieldOfView(
MathHelper.DegreesToRadians(45.0f), // Field of View
aspectRatio,
0.1f, // Near Clipping Plane
1000.0f // Far Clipping Plane
);
GL.LoadMatrix(ref perspective);
}

You might also like