コード例 #1
0
        /// <summary>
        /// Raises the draw frame event.
        /// </summary>
        /// <param name="gl">Gl.</param>
        public void OnDrawFrame(IGL10 gl)
        {
            // Replace the current matrix with the identity matrix
            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();             // OpenGL docs
            gl.GlOrthof(_left, _right, _bottom, _top, -1, 1);

            for (int idx = 0; idx < _triangles.Count; idx++)
            {
                gl.GlVertexPointer(3, GL10.GlFloat, 0, _triangles[idx].Vertices);
                gl.GlEnableClientState(GL10.GlVertexArray);
                gl.GlColorPointer(4, GL10.GlUnsignedByte, 0, _triangles[idx].Colors);
                gl.GlEnableClientState(GL10.GlColorArray);

                gl.GlDrawArrays(GL10.GlTriangleStrip, 0, _triangles[idx].Count);
            }

            for (int idx = 0; idx < _lines.Count; idx++)
            {
                gl.GlVertexPointer(3, GL10.GlFloat, 0, _lines[idx].Vertices);
                gl.GlEnableClientState(GL10.GlVertexArray);

                SimpleColor color = new SimpleColor()
                {
                    Value = _lines[idx].Color
                };
                gl.GlColor4f(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);
                gl.GlLineWidth(_lines [idx].Width);
                gl.GlDrawArrays(GL10.GlLineStrip, 0, _lines[idx].Count);
            }
        }
コード例 #2
0
        public override void Present(float deltaTime)
        {
            IGL10 gl = _glGraphics.GL10;

            gl.GlViewport(0, 0, _glGraphics.Width, _glGraphics.Height);
            gl.GlClearColor(0, 0, 0, 1);
            gl.GlClear(GL10.GlColorBufferBit);
            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();
            gl.GlOrthof(0, 540, 0, 960, 1, -1);
            gl.GlEnable(GL10.GlTexture2d);


            gl.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha);
            gl.GlEnable(GL10.GlBlend);

            gl.GlBindTexture(GL10.GlTexture2d, _textureId);



            gl.GlEnableClientState(GL10.GlVertexArray);
            gl.GlEnableClientState(GL10.GlTextureCoordArray);

            _vertices.Position(0);
            gl.GlVertexPointer(2, GL10.GlFloat, _vertexSize, _vertices);
            _vertices.Position(2);
            gl.GlTexCoordPointer(2, GL10.GlFloat, _vertexSize, _vertices);
            gl.GlDrawArrays(GL10.GlTriangles, 0, 3);
            //gl.GlDisableClientState(GL10.GlVertexArray);
            //gl.GlDisableClientState(GL10.GlTextureCoordArray);
        }
コード例 #3
0
		public void OnSurfaceChanged (IGL10 gl, int width, int height)
		{
			// Replace the current matrix with the identity matrix
			gl.GlMatrixMode (GL10.GlProjection);
			gl.GlLoadIdentity(); // OpenGL docs
			gl.GlOrthof (-2, 2, -2, 2, -1, 10);

			// Translates 4 units into the screen.
			gl.GlMatrixMode (GL10.GlModelview);
			//gl.GlTranslatef(0, 0, -4); // OpenGL docs

			gl.GlClearColor (255, 255, 255, 255);
			gl.GlClear(GL10.GlColorBufferBit | // OpenGL docs.
			           GL10.GlDepthBufferBit);
		}
コード例 #4
0
        public void OnSurfaceChanged(IGL10 gl, int width, int height)
        {
            // Replace the current matrix with the identity matrix
            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();             // OpenGL docs
            gl.GlOrthof(-2, 2, -2, 2, -1, 10);

            // Translates 4 units into the screen.
            gl.GlMatrixMode(GL10.GlModelview);
            //gl.GlTranslatef(0, 0, -4); // OpenGL docs

            gl.GlClearColor(255, 255, 255, 255);
            gl.GlClear(GL10.GlColorBufferBit |             // OpenGL docs.
                       GL10.GlDepthBufferBit);
        }
コード例 #5
0
        public override void Present(float delta)
        {
            IGL10 gl = _glGraphics.GL10;

            gl.GlViewport(0, 0, _glGraphics.Width, _glGraphics.Height - 200);
            gl.GlClear(GL10.GlColorBufferBit);
            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();
            gl.GlOrthof(0, 540, 0, 960, 1, -1);

            gl.GlColor4f(1, 0, 0, 1);
            gl.GlEnableClientState(GL10.GlVertexArray);
            _vertices.Position(0);
            gl.GlVertexPointer(2, GL10.GlFloat, _vertexSize, _vertices);
            gl.GlDrawArrays(GL10.GlTriangles, 0, 3);
        }
コード例 #6
0
        public override void Resume()
        {
            IGL10 gl = _glGraphics.GL10;

            gl.GlViewport(0, 0, _glGraphics.Width, _glGraphics.Height);
            gl.GlClearColor(0, 1, 0, 1);


            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();
            gl.GlOrthof(0, 540, 0, 960, 1, -1);

            gl.GlEnable(GL10.GlTexture2d);
            _texture.Reload();
            //_texture.BindTexture ();
        }
コード例 #7
0
        public override void Present(float deltaTime)
        {
            IGL10 gl = _glGraphics.GL10;

            gl.GlViewport(0, 0, _glGraphics.Width, _glGraphics.Height);
            gl.GlClear(GL10.GlColorBufferBit);
            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();
            gl.GlOrthof(0, 540, 0, 960, 1, -1);
            gl.GlEnable(GL10.GlTexture2d);

            _texture.BindTexture();

            gl.GlEnableClientState(GL10.GlVertexArray);
            gl.GlEnableClientState(GL10.GlTextureCoordArray);
            _vertices.Position(0);
            gl.GlVertexPointer(2, GL10.GlFloat, _vertexSize, _vertices);
            _vertices.Position(2);
            gl.GlTexCoordPointer(2, GL10.GlFloat, _vertexSize, _vertices);
            gl.GlDrawElements(GL10.GlTriangles, 6, GL10.GlUnsignedShort, _indices);
        }
コード例 #8
0
ファイル: OpenGLTarget2D.cs プロジェクト: JoeCooper/ui
		/// <summary>
		/// Raises the draw frame event.
		/// </summary>
		/// <param name="gl">Gl.</param>
        public void OnDrawFrame(IGL10 gl)
        {
            lock (_triangles)
            {
                // Replace the current matrix with the identity matrix
                gl.GlMatrixMode(GL10.GlProjection);
                gl.GlLoadIdentity(); // OpenGL docs
                gl.GlOrthof(_left, _right, _bottom, _top, -1, 1);


                SimpleColor color = SimpleColor.FromKnownColor(KnownColor.White);
                gl.GlClearColor(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);
                gl.GlClear(GL10.GlColorBufferBit);

                for (int idx = 0; idx < _triangles.Count; idx++)
                {
                    gl.GlVertexPointer(3, GL10.GlFloat, 0, _triangles[idx].Vertices);
                    gl.GlEnableClientState(GL10.GlVertexArray);
                    gl.GlColorPointer(4, GL10.GlUnsignedByte, 0, _triangles[idx].Colors);
                    gl.GlEnableClientState(GL10.GlColorArray);

                    gl.GlDrawArrays(GL10.GlTriangleStrip, 0, _triangles[idx].Count);
                }

                for (int idx = 0; idx < _lines.Count; idx++)
                {
                    gl.GlVertexPointer(3, GL10.GlFloat, 0, _lines[idx].Vertices);
                    gl.GlEnableClientState(GL10.GlVertexArray);

                    color = new SimpleColor()
                    {
                        Value = _lines[idx].Color
                    };
                    gl.GlColor4f(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);
                    gl.GlLineWidth(_lines[idx].Width);
                    gl.GlDrawArrays(GL10.GlLineStrip, 0, _lines[idx].Count);
                }
            }
        }