本文整理汇总了C#中OpenGL.MatrixMode方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.MatrixMode方法的具体用法?C# OpenGL.MatrixMode怎么用?C# OpenGL.MatrixMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL
的用法示例。
在下文中一共展示了OpenGL.MatrixMode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateProjectionMatrix
/// <summary>
/// Creates the projection matrix for the given screen size.
/// </summary>
/// <param name="gl">The OpenGL instance.</param>
/// <param name="screenWidth">Width of the screen.</param>
/// <param name="screenHeight">Height of the screen.</param>
public void CreateProjectionMatrix(OpenGL gl, float screenWidth, float screenHeight)
{
// Create the projection matrix for our screen size.
const float S = 0.46f;
float H = S * screenHeight / screenWidth;
projectionMatrix = glm.pfrustum(-S, S, -H, H, 1, 100);
// When we do immediate mode drawing, OpenGL needs to know what our projection matrix
// is, so set it now.
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.LoadIdentity();
gl.MultMatrix(projectionMatrix.to_array());
gl.MatrixMode(OpenGL.GL_MODELVIEW);
}
示例2: Project
/// <summary>
/// This function projects through the camera, to OpenGL, ie. it
/// creates a projection matrix.
/// </summary>
public virtual void Project(OpenGL gl)
{
// Load the projection identity matrix.
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.LoadIdentity();
// Perform the projection.
TransformProjectionMatrix(gl);
// Get the matrix.
float[] matrix = new float[16];
gl.GetFloat(OpenGL.GL_PROJECTION_MATRIX, matrix);
for(int i=0; i<4; i++)
for(int j=0; j<4; j++)
projectionMatrix[i,j] = matrix[(i*4) + j];
// Back to the modelview matrix.
gl.MatrixMode(OpenGL.GL_MODELVIEW);
}
示例3: CreatePolygon
/// <summary>
/// This is the main function of the class, it'll create a triangulated polygon
/// from and SceneObject.
/// </summary>
/// <param name="gl">The gl.</param>
/// <param name="sourceObject">The object to convert.</param>
/// <param name="guarenteedView">A camera that can see the whole object.</param>
/// <returns>
/// A polygon created from 'sourceObject'.
/// </returns>
public Polygon CreatePolygon(OpenGL gl, IRenderable sourceObject, Camera guarenteedView)
{
// Save the current camera data.
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.PushMatrix();
// Look through the camera that can see the object.
guarenteedView.Project(gl);
// Start triangulation.
Begin(gl);
// Draw the object.
sourceObject.Render(gl, RenderMode.Design);
// End triangulation.
End(gl);
Polygon newPoly = Triangle;
newPoly.Name = (sourceObject is SceneElement ? ((SceneElement)sourceObject).Name : "Object") + " (Triangulated Poly)";
return newPoly;
}
示例4: CreatePolygon
/// <summary>
/// This is the main function of the class, it'll create a triangulated polygon
/// from and SceneObject.
/// </summary>
/// <param name="sourceObject">The object to convert.</param>
/// <param name="guarenteedView">A camera that can see the whole object.</param>
/// <returns>A polygon created from 'sourceObject'.</returns>
public Polygon CreatePolygon(OpenGL gl, SceneObject sourceObject, Cameras.Camera guarenteedView)
{
// Save the current camera data.
gl.MatrixMode(OpenGL.PROJECTION);
gl.PushMatrix();
// Look through the camera that can see the object.
guarenteedView.Project(gl);
// Start triangulation.
Begin(gl);
// Draw the object.
sourceObject.Draw(gl);
// End triangulation.
End(gl);
Polygon newPoly = Triangle;
newPoly.Name = sourceObject.Name + " (Triangulated Poly)";
return newPoly;
}
示例5: SetAttributes
/// <summary>
/// Sets the attributes.
/// </summary>
/// <param name="gl">The OpenGL instance.</param>
public override void SetAttributes(OpenGL gl)
{
if (enableNormalize.HasValue) gl.EnableIf(OpenGL.GL_NORMALIZE, enableNormalize.Value);
if (matrixMode.HasValue) gl.MatrixMode(matrixMode.Value);
}
示例6: RenderImmediateMode
/// <summary>
/// Renders the scene in immediate mode.
/// </summary>
/// <param name="gl">The OpenGL instance.</param>
public void RenderImmediateMode(OpenGL gl)
{
// Setup the modelview matrix.
gl.MatrixMode(OpenGL.GL_MODELVIEW);
gl.LoadIdentity();
gl.MultMatrix(modelviewMatrix.to_array());
// Push the polygon attributes and set line mode.
gl.PushAttrib(OpenGL.GL_POLYGON_BIT);
gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Lines);
// Render the trefoil.
var vertices = trefoilKnot.Vertices;
gl.Begin(BeginMode.Triangles);
foreach (var index in trefoilKnot.Indices)
gl.Vertex(vertices[index].x, vertices[index].y, vertices[index].z);
gl.End();
// Pop the attributes, restoring all polygon state.
gl.PopAttrib();
}
示例7: Project
/// <summary>
/// This function projects through the camera, to OpenGL, ie. it
/// creates a projection matrix.
/// </summary>
public virtual void Project(OpenGL gl)
{
// Load the projection identity matrix.
gl.MatrixMode(OpenGL.PROJECTION);
gl.LoadIdentity();
// Perform the projection.
TransformProjectionMatrix(gl);
// If we have the lookAtTarget set to true, look at it now.
if(lookAtTarget)
LookAt(gl);
// Get the matrix.
float[] matrix = new float[16];
gl.GetFloat(OpenGL.PROJECTION_MATRIX, matrix);
for(int i=0; i<4; i++)
for(int j=0; j<4; j++)
projectionMatrix.data[j][i] = matrix[(i*4) + j];
// Back to the modelview matrix.
gl.MatrixMode(OpenGL.MODELVIEW);
// if(lookAtTarget)
// LookAt(gl);
}