当前位置: 首页>>代码示例>>C#>>正文


C# OpenGL.LoadIdentity方法代码示例

本文整理汇总了C#中SharpGL.OpenGL.LoadIdentity方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.LoadIdentity方法的具体用法?C# OpenGL.LoadIdentity怎么用?C# OpenGL.LoadIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharpGL.OpenGL的用法示例。


在下文中一共展示了OpenGL.LoadIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: openGLControl_OpenGLDraw

        /// <summary>
        /// Handles the OpenGLDraw event of the openGLControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param>
        public void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
        {
            //  Get the OpenGL object.
            gl = openGLControl.OpenGL;

            //  Clear the color and depth buffer.
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            //  Load the identity matrix.
            gl.LoadIdentity();

            //  Rotate around the Y axis.
            //gl.Rotate(rotation, 0.0f, 1.0f, 0.0f);
            cord = ComInput.Coordinates.Instance;
            this.ModelRotater(gl);

            gl.Enable(OpenGL.GL_BLEND);
            gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA);

            //  Draw a coloured parallelepiped.
            gl.Begin(OpenGL.GL_QUADS);

            gl.Color(0.0f, 1.0f, 0.0f);
            gl.Vertex(-2.0f, -0.25f, -1.0f);

            gl.Color(0.0f, 1.0f, 0.0f);
            gl.Vertex(2.0f, -0.25f, -1.0f);

            gl.Color(0.0f, 1.0f, 0.0f);
            gl.Vertex(2.0f, 0.25f, -1.0f);

            gl.Color(0.0f, 1.0f, 0.0f);
            gl.Vertex(-2.0f, 0.25f, -1.0f);
            //-------------------------------------
            gl.Color(1.0f, 0.0f, 0.0f);
            gl.Vertex(-2.0f, -0.25f, -1.0f);

            gl.Color(1.0f, 0.0f, 0.0f);
            gl.Vertex(-2.0f, -0.25f, 1.0f);

            gl.Color(1.0f, 0.0f, 0.0f);
            gl.Vertex(-2.0f, 0.25f, 1.0f);

            gl.Color(1.0f, 0.0f, 0.0f);
            gl.Vertex(-2.0f, 0.25f, -1.0f);
            //-------------------------------------
            gl.Color(0.0f, 1.0f, 0.0f);
            gl.Vertex(-2.0f, -0.25f, 1.0f);

            gl.Color(0.0f, 1.0f, 0.0f);
            gl.Vertex(2.0f, -0.25f, 1.0f);

            gl.Color(0.0f, 1.0f, 0.0f);
            gl.Vertex(2.0f, 0.25f, 1.0f);

            gl.Color(0.0f, 1.0f, 0.0f);
            gl.Vertex(-2.0f, 0.25f, 1.0f);
            //-------------------------------------
            gl.Color(1.0f, 0.0f, 0.0f);
            gl.Vertex(2.0f, -0.25f, 1.0f);

            gl.Color(1.0f, 0.0f, 0.0f);
            gl.Vertex(2.0f, -0.25f, -1.0f);

            gl.Color(1.0f, 0.0f, 0.0f);
            gl.Vertex(2.0f, 0.25f, -1.0f);

            gl.Color(1.0f, 0.0f, 0.0f);
            gl.Vertex(2.0f, 0.25f, 1.0f);
            //-------------------------------------
            gl.Color(0.0f, 1.0f, 1.0f);
            gl.Vertex(-2.0f, 0.25f, -1.0f);

            gl.Color(0.0f, 1.0f, 1.0f);
            gl.Vertex(2.0f, 0.25f, -1.0f);

            gl.Color(0.0f, 1.0f, 1.0f);
            gl.Vertex(2.0f, 0.25f, 1.0f);

            gl.Color(0.0f, 1.0f, 1.0f);
            gl.Vertex(-2.0f, 0.25f, 1.0f);
            //--------------------------------------
            gl.Color(0.0f, 0.0f, 1.0f);
            gl.Vertex(-2.0f, -0.25f, -1.0f);

            gl.Color(0.0f, 0.0f, 1.0f);
            gl.Vertex(2.0f, -0.25f, -1.0f);

            gl.Color(0.0f, 0.0f, 1.0f);
            gl.Vertex(2.0f, -0.25f, 1.0f);

            gl.Color(0.0f, 0.0f, 1.0f);
            gl.Vertex(-2.0f, -0.25f, 1.0f);

            gl.End();
//.........这里部分代码省略.........
开发者ID:ulqiorra,项目名称:Gyroscope,代码行数:101,代码来源:SharpGLForm.cs

示例2: DrawGrid

        public void DrawGrid(OpenGL gl, int camX,int camY)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.LoadIdentity();

            int MapHeight = tileMap.mapHeight;
            int MapWidth = tileMap.mapWidth;

            float[] darkColor = { 0.2f, 0.2f, 0.2f };
            float[] lightColor = { 0.25f, 0.25f, 0.25f };
            for (int h = 0; h < MapHeight; h++)
            {
                if (h % 10 == 0)
                {
                    gl.LineWidth(2.0f);
                    gl.Color(lightColor);
                }
                else
                {
                    gl.LineWidth(1.0f);
                    gl.Color(darkColor);
                }
                if (h == 0)
                {
                    gl.LineWidth(4.0f);
                    gl.Color(lightColor);
                }
                gl.Begin(OpenGL.GL_LINES);							// Start Drawing Verticle Cell Borders
                gl.Vertex(0 - camX, h * tileSize - camY, 0);// Left Side Of Horizontal Line
                gl.Vertex((MapWidth * tileSize) - camX, (h * tileSize) - camY, 0);// Right Side Of Horizontal Line
                gl.End();
            }
            for (int v = 0; v < MapWidth; v++)
            {
                if (v % 10 == 0)
                {
                    gl.LineWidth(2.0f);
                    gl.Color(lightColor);
                }
                else
                {
                    gl.LineWidth(1.0f);
                    gl.Color(darkColor);
                }
                if (v == 0)
                {
                    gl.LineWidth(4.0f);
                    gl.Color(lightColor);
                }
                gl.Begin(OpenGL.GL_LINES);							// Start Drawing Verticle Cell Borders
                gl.Vertex(v * tileSize - camX, 0 - camY, 0);// Left Side Of Horizontal Line
                gl.Vertex((v * tileSize) - camX, (MapHeight * tileSize) - camY, 0);// Right Side Of Horizontal Line
                gl.End();
            }
        }
开发者ID:jesterguy,项目名称:Modern_Tactics,代码行数:55,代码来源:BattleMap.cs

示例3: 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);
        }
开发者ID:rhynodegreat,项目名称:sharpgl,代码行数:20,代码来源:Scene.cs

示例4: 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());

            //  Go through each group.
            foreach (var mesh in meshes)
            {
                var texture = meshTextures.ContainsKey(mesh) ? meshTextures[mesh] : null;
                if(texture != null)
                    texture.Bind(gl);

                uint mode = OpenGL.GL_TRIANGLES;
                if (mesh.indicesPerFace == 4)
                    mode = OpenGL.GL_QUADS;
                else if(mesh.indicesPerFace > 4)
                    mode = OpenGL.GL_POLYGON;

                //  Render the group faces.
                gl.Begin(mode);
                for (int i = 0; i < mesh.vertices.Length; i++ )
                {
                    gl.Vertex(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z);
                    if(mesh.normals != null)
                        gl.Normal(mesh.normals[i].x, mesh.normals[i].y, mesh.normals[i].z);
                    if(mesh.uvs != null)
                        gl.TexCoord(mesh.uvs[i].x, mesh.uvs[i].y);
                }
                gl.End();

                if(texture != null)
                    texture.Unbind(gl);
            }
        }
开发者ID:rhynodegreat,项目名称:sharpgl,代码行数:40,代码来源:Scene.cs

示例5: BasicResize

        //utilities
        public static void BasicResize(OpenGL _context, Size _size)
        {
            //ThrowIfNull(_context);

            //  Set the projection matrix.
            _context.MatrixMode(OpenGL.GL_PROJECTION);

            //  Load the identity.
            _context.LoadIdentity();

            //  Create a perspective transformation.
            _context.Perspective(60.0f, _size.Width / _size.Height, 0.01, 100.0);

            //  Use the 'look at' helper function to position and aim the camera.
            _context.LookAt(0, 0, 2, 0, 0, 0, 0, 1, 0);

            //  Set the modelview matrix.
            _context.MatrixMode(OpenGL.GL_MODELVIEW);
        }
开发者ID:mkramers,项目名称:Projects,代码行数:20,代码来源:MainWindow.xaml.cs

示例6: SampleRendering

        private void SampleRendering(OpenGL gl, float rX, float rY, float rZ)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
            gl.LoadIdentity();					// Reset The View
            gl.Translate(-1.5f, 0.0f, -6.0f);				// Move Left And Into The Screen

            gl.Rotate(rtri, rX, rY, rZ);				// Rotate The Pyramid On It's Y Axis

            gl.Begin(OpenGL.GL_TRIANGLES);					// Start Drawing The Pyramid

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Front)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Left Of Triangle (Front)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Right Of Triangle (Front)

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Right)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Left Of Triangle (Right)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Right Of Triangle (Right)

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Back)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Left Of Triangle (Back)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Right Of Triangle (Back)

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Left)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Left Of Triangle (Left)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Right Of Triangle (Left)
            gl.End();						// Done Drawing The Pyramid

            gl.LoadIdentity();
            gl.Translate(1.5f, 0.0f, -7.0f);				// Move Right And Into The Screen

            gl.Rotate(rquad, rX, rY, rZ);			// Rotate The Cube On X, Y & Z

            gl.Begin(OpenGL.GL_QUADS);					// Start Drawing The Cube

            gl.Color(0.0f, 1.0f, 0.0f);			// Set The Color To Green
            gl.Vertex(1.0f, 1.0f, -1.0f);			// Top Right Of The Quad (Top)
            gl.Vertex(-1.0f, 1.0f, -1.0f);			// Top Left Of The Quad (Top)
            gl.Vertex(-1.0f, 1.0f, 1.0f);			// Bottom Left Of The Quad (Top)
            gl.Vertex(1.0f, 1.0f, 1.0f);			// Bottom Right Of The Quad (Top)


            gl.Color(1.0f, 0.5f, 0.0f);			// Set The Color To Orange
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Top Right Of The Quad (Bottom)
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Top Left Of The Quad (Bottom)
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Bottom Left Of The Quad (Bottom)
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Bottom Right Of The Quad (Bottom)

            gl.Color(1.0f, 0.0f, 0.0f);			// Set The Color To Red
            gl.Vertex(1.0f, 1.0f, 1.0f);			// Top Right Of The Quad (Front)
            gl.Vertex(-1.0f, 1.0f, 1.0f);			// Top Left Of The Quad (Front)
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Bottom Left Of The Quad (Front)
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Bottom Right Of The Quad (Front)

            gl.Color(1.0f, 1.0f, 0.0f);			// Set The Color To Yellow
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Bottom Left Of The Quad (Back)
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Bottom Right Of The Quad (Back)
            gl.Vertex(-1.0f, 1.0f, -1.0f);			// Top Right Of The Quad (Back)
            gl.Vertex(1.0f, 1.0f, -1.0f);			// Top Left Of The Quad (Back)

            gl.Color(0.0f, 0.0f, 1.0f);			// Set The Color To Blue
            gl.Vertex(-1.0f, 1.0f, 1.0f);			// Top Right Of The Quad (Left)
            gl.Vertex(-1.0f, 1.0f, -1.0f);			// Top Left Of The Quad (Left)
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Bottom Left Of The Quad (Left)
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Bottom Right Of The Quad (Left)

            gl.Color(1.0f, 0.0f, 1.0f);			// Set The Color To Violet
            gl.Vertex(1.0f, 1.0f, -1.0f);			// Top Right Of The Quad (Right)
            gl.Vertex(1.0f, 1.0f, 1.0f);			// Top Left Of The Quad (Right)
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Bottom Left Of The Quad (Right)
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Bottom Right Of The Quad (Right)
            gl.End();						// Done Drawing The Q

            gl.Flush();

            rtri += 1.0f;// 0.2f;						// Increase The Rotation Variable For The Triangle 
            rquad -= 1.0f;// 0.15f;						// Decrease The Rotation Variable For The Quad 
        }
开发者ID:hhool,项目名称:sharpgl,代码行数:89,代码来源:FormRenderContextsSample.cs

示例7: Draw

        public override void Draw(ref OpenGL gl)
        {
            if (!TexturesInitialised)
            {
                InitializeTexture(ref gl);
            }
            //  Clear the color and depth buffer.
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            //  Load the identity matrix.
            gl.LoadIdentity();
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            gl.Enable(OpenGL.GL_LIGHTING);
            gl.Enable(OpenGL.GL_LIGHT0);
            gl.Enable(OpenGL.GL_DEPTH_TEST);
            gl.Enable(OpenGL.GL_NORMALIZE);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, gtexture[0]);
            gl.Color(1.0f, 1.0f, 1.0f, 0.1f);

            gl.Begin(OpenGL.GL_QUADS);
            gl.FrontFace(OpenGL.GL_FRONT_FACE);

            gl.TexCoord(1.0f, 1.0f);
            gl.Vertex(gImage1.Width, gImage1.Height, 1.0f);
            gl.TexCoord(0.0f, 1.0f);
            gl.Vertex(0.0f, gImage1.Height, 1.0f);
            gl.TexCoord(0.0f, 0.0f);
            gl.Vertex(0.0f, 0.0f, 1.0f);
            gl.TexCoord(1.0f, 0.0f);
            gl.Vertex(gImage1.Width, 0.0f, 1.0f);
            gl.End();

            gl.Disable(OpenGL.GL_TEXTURE_2D);

            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.LoadIdentity();
            gl.Ortho(0.0, (double)gImage1.Width, (double)gImage1.Height, 0.0, -1.0, 1.0);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.Disable(OpenGL.GL_DEPTH_TEST);
        }
开发者ID:EternalEnvy,项目名称:SmackBrosClient,代码行数:40,代码来源:GameplayScreen.cs

示例8: Resized

        //Handles the Resized event of the openGLControl1 control
        private void Resized(ref OpenGL gl, double Width, double Height)
        {
            //  Set the projection matrix.
            gl.MatrixMode(OpenGL.GL_PROJECTION);

            //  Load the identity.
            gl.LoadIdentity();

            if (!TexturesInitialised)
            {
                gl.Ortho(-1, 1, -1, 1, -1, 1);
            }
            else
            {
                gl.Ortho(0, gImage1.Width, gImage1.Height, 0, -1, 1);
            }
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.Disable(OpenGL.GL_DEPTH_TEST);

            //  Create a perspective transformation.
            gl.Perspective(45.0f, (double)Width / (double)Height, 1.0, 1000.0);
            gl.Viewport(0, 0, (int)Width, (int)Height);
            //  Use the 'look at' helper function to position and aim the camera.
            gl.LookAt(-5, 5, -5, 0, 0, 0, 0, 1, 0);

            //  Set the modelview matrix.
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
        }
开发者ID:EternalEnvy,项目名称:SmackBrosClient,代码行数:29,代码来源:GameplayScreen.cs

示例9: ComputeBoundingBox

        private void ComputeBoundingBox(Node node, ref Vector3 min, ref Vector3 max, ref Matrix4 trafo, ref OpenGL gl)
        {
            gl.PushMatrix();
            gl.LoadIdentity();
            Matrix4 prev = trafo;
            trafo = Matrix4.Mult(prev, FromMatrix(node.Transform));

            if (node.HasMeshes)
            {
                foreach (int index in node.MeshIndices)
                {
                    Mesh mesh = m_model.Meshes[index];
                    for (int i = 0; i < mesh.VertexCount; i++)
                    {
                        Vector3 tmp = FromVector(mesh.Vertices[i]);
                        Vector3.Transform(tmp, trafo);

                        min.X = Math.Min(min.X, tmp.X);
                        min.Y = Math.Min(min.Y, tmp.Y);
                        min.Z = Math.Min(min.Z, tmp.Z);

                        max.X = Math.Max(max.X, tmp.X);
                        max.Y = Math.Max(max.Y, tmp.Y);
                        max.Z = Math.Max(max.Z, tmp.Z);
                    }
                }
            }

            for (int i = 0; i < node.ChildCount; i++)
            {
                ComputeBoundingBox(node.Children[i], ref min, ref max, ref trafo, ref gl);
            }
            trafo = prev;
        }
开发者ID:EternalEnvy,项目名称:SmackBrosClient,代码行数:34,代码来源:GameplayScreen.cs

示例10: BindTexture

        /// <summary>
        /// Bind a texture
        /// </summary>
        /// <param name="gl">OpenGL control</param>
        /// <param name="textures">List of all textures</param>
        /// <param name="textureName">Texture name will be bind</param>
        private bool BindTexture(OpenGL gl, Hashtable textures, string textureName)
        {
            Texture thisTexture = null;

            if (textures.ContainsKey(textureName))
            {
                thisTexture = (Texture)textures[textureName];

                gl.MatrixMode(OpenGL.GL_TEXTURE);
                gl.LoadIdentity();

                thisTexture.Bind(gl);

                return true;
            }

            return false;
        }
开发者ID:k19862217,项目名称:DioramaExhibitionSupportSystem,代码行数:24,代码来源:3DSDrawer.cs

示例11: DrawText

        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="gl">The gl.</param>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="r">The r.</param>
        /// <param name="g">The g.</param>
        /// <param name="b">The b.</param>
        /// <param name="faceName">Name of the face.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="text">The text.</param>
        public void DrawText(OpenGL gl, int x, int y, float r, float g, float b, string faceName, float fontSize, string text)
        {
            //  Get the font size in pixels.
            int fontHeight = (int)(fontSize * (16.0f / 12.0f));

            //  Do we have a font bitmap entry for this OpenGL instance and face name?
            var result = from fbe in fontBitmapEntries
                         where fbe.HDC == gl.RenderContextProvider.DeviceContextHandle
                         && fbe.HRC == gl.RenderContextProvider.RenderContextHandle
                         && string.Compare(fbe.FaceName, faceName, true) == 0
                         && fbe.Height == fontHeight
                         select fbe;

            //  Get the FBE or null.
            FontBitmapEntry fontBitmapEntry = result == null || result.Count() == 0 ? null : result.First();

            //  If we don't have the FBE, we must create it.
            if (fontBitmapEntry == null)
                fontBitmapEntry = CreateFontBitmapEntry(gl, faceName, fontHeight);

            double width = gl.RenderContextProvider.Width;
            double height = gl.RenderContextProvider.Height;

            double aspect_ratio = width / height;
            
            //  Create the appropriate projection matrix.
            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.PushMatrix();
            gl.LoadIdentity();
            
            int[] viewport = new int[4];
            gl.GetInteger(OpenGL.GL_VIEWPORT, viewport);
            //gl.Ortho2D(viewport[0], viewport[2], viewport[1], viewport[3]);
            gl.Ortho(0, width, 0, height, -1, 1);

            //  Create the appropriate modelview matrix.
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.PushMatrix();
            gl.LoadIdentity();
            //gl.Translate(0, 0, -5);
            //gl.RasterPos(x, y);
            gl.Color(r, g, b);
            gl.RasterPos(x, y);

            gl.PushAttrib(OpenGL.GL_LIST_BIT | OpenGL.GL_CURRENT_BIT |
                OpenGL.GL_ENABLE_BIT | OpenGL.GL_TRANSFORM_BIT);
            gl.Color(r, g, b);
            gl.Disable(OpenGL.GL_LIGHTING);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.Disable(OpenGL.GL_DEPTH_TEST);
            gl.RasterPos(x, y);
           /** gl.Enable(OpenGL.GL_BLEND);
            gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA); */

            //  Set the list base.
            gl.ListBase(fontBitmapEntry.ListBase);

            //  Create an array of lists for the glyphs.
            List<byte> lists = new List<byte>();
            foreach(char c in text)
                lists.Add((byte)c);            

            //  Call the lists for the string.
            gl.CallLists(lists.Count, lists.ToArray());
            gl.Flush();
            
            //  Reset the list bit.
            gl.PopAttrib();

            //  Pop the modelview.
            gl.PopMatrix();

            //  back to the projection and pop it, then back to the model view.
            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.PopMatrix();
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
        }
开发者ID:mind0n,项目名称:hive,代码行数:89,代码来源:FontOutlines.cs

示例12: Resized

        public void Resized(OpenGL gl, double aspect)
        {
            //  Set the projection matrix.
            gl.MatrixMode(OpenGL.GL_PROJECTION);

            //  Load the identity.
            gl.LoadIdentity();

            //  Create a perspective transformation.
            gl.Perspective(60.0f, aspect, 0.01, 100.0);
            CamController.Aspect = aspect;
            //  Use the 'look at' helper function to position and aim the camera.
            CamController.SetCam(gl);

            //  Set the modelview matrix.
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
        }
开发者ID:Vinic,项目名称:TomatoEngine,代码行数:17,代码来源:TomatoMainEngine.cs

示例13: openGLControl_OpenGLDraw

 private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
 {
     _gl = openGLControl.OpenGL;
     _gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
     _gl.LoadIdentity();
     _gl.LookAt(0, 0, _w, 0, 0, 0, 0, 1, 0); //-10, 10, _w, 0, 0, 0, 0, 1, 0
     _gl.Rotate((float)_rotX, (float)_rotY, (float)_rotZ);
     _gl.Translate(_transX, _transY, _transZ);
     foreach (Polygon polygon in _polygons)
         {
             if (!polygon.IsEnabled) continue;
             polygon.PushObjectSpace(_gl);
             polygon.Render(_gl, SharpGL.SceneGraph.Core.RenderMode.Render);
             polygon.PopObjectSpace(_gl);
         }
 }
开发者ID:MaKiPL,项目名称:FF8-Rinoa-s-Toolset,代码行数:16,代码来源:SharpGLForm.cs

示例14: InitView

        private static void InitView(OpenGLControl control, OpenGL gl)
        {
            gl.MatrixMode(MatrixMode.Projection);
            gl.LoadIdentity();
            gl.Ortho(0, control.ActualWidth, control.ActualHeight, 0, -10, 10);

            gl.MatrixMode(MatrixMode.Modelview);
        }
开发者ID:bnayae,项目名称:VisualRx.DeleteCandidate,代码行数:8,代码来源:MarbleDiagramRenderer.cs

示例15: RenderObjects

        public void RenderObjects(OpenGL gl, GameObject[] objects)
        {
            //clears the screen
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            //St matrix mode to PROJECTION so we can move the camera
            gl.MatrixMode(OpenGL.GL_PROJECTION);
            //  Load the identity matrix.
            gl.LoadIdentity();
            //Move the camera
            CamController.SetCam(gl);
            //Set matrix mode back to Modelview so we can draw objects
            gl.MatrixMode(OpenGL.GL_MODELVIEW);

            if (_mode == RenderMode.WireFrame || _mode == RenderMode.Hitboxes)
            {
                foreach(GameObject obj in objects){
                    //Draw the object with texture
                    obj.Draw(gl);
                    //Unbind texture so we can draw lines
                    gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
                    if ( _mode == RenderMode.Hitboxes)
                    {
                        obj.DrawVelocity(gl);
                        DrawCircle(gl, obj.GetPosition().x,obj.GetPosition().y, obj.GetPhysSize());
                    }
                    else
                    {
                        obj.DrawWireFrame(gl);
                    }
                }
            }
            else
            {
                foreach ( GameObject obj in objects )
                {
                    //Draw the object with texture
                    obj.Draw(gl);
                }
            }
            //Unbind texture
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
        }
开发者ID:Vinic,项目名称:TomatoEngine,代码行数:42,代码来源:RenderEngine.cs


注:本文中的SharpGL.OpenGL.LoadIdentity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。