public void OnSurfaceChanged(IGL10 gl, int width, int height) { gl.GlViewport(0, 0, width, height); mViewportWidth = width; mViewportHeight = height; float ratio = (float)width / height; mViewRect.Top = 1.0f; mViewRect.Bottom = -1.0f; mViewRect.Left = -ratio; mViewRect.Right = ratio; UpdatePageRects(); gl.GlMatrixMode(GL10.GlProjection); gl.GlLoadIdentity(); if (USE_PERSPECTIVE_PROJECTION) { GLU.GluPerspective(gl, 20f, (float)width / height, .1f, 100f); } else { GLU.GluOrtho2D(gl, mViewRect.Left, mViewRect.Right, mViewRect.Bottom, mViewRect.Top); } gl.GlMatrixMode(GL10.GlModelview); gl.GlLoadIdentity(); }
public void OnSurfaceChanged(IGL10 gl, int width, int height) { gl.GlViewport(0, 0, width, height); gl.GlMatrixMode(IGL10Constants.GL_PROJECTION); gl.GlLoadIdentity(); GLU.GluPerspective(gl, 45.0f, (float)width / (float)height, 0.1f, 100.0f); gl.GlViewport(0, 0, width, height); gl.GlMatrixMode(IGL10Constants.GL_MODELVIEW); gl.GlLoadIdentity(); }
public void OnDrawFrame(IGL10 gl) { gl.GlClear(IGL10Constants.GL_COLOR_BUFFER_BIT | IGL10Constants.GL_DEPTH_BUFFER_BIT); gl.GlLoadIdentity(); gl.GlTranslatef(0.0f, 0.0f, -10.0f); gl.GlRotatef(mCubeRotation, 1.0f, 1.0f, 1.0f); mCube.Draw(gl); gl.GlLoadIdentity(); mCubeRotation -= 0.7f; }
/// <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); } }
/// <summary> /// Raises the surface changed event. /// </summary> /// <param name="gl">Gl.</param> /// <param name="width">Width.</param> /// <param name="height">Height.</param> 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(0, width, 0, height, -1, 1); // Translates 4 units into the screen. gl.GlMatrixMode(GL10.GlModelview); gl.GlLoadIdentity(); // OpenGL docs //gl.GlTranslatef(0, 0, -4); // OpenGL docs gl.GlClearColor(255, 255, 255, 255); gl.GlClear(GL10.GlColorBufferBit | // OpenGL docs. GL10.GlDepthBufferBit); }
public void OnDrawFrame(IGL10 gl) { /* * Usually, the first thing one might want to do is to clear * the screen. The most efficient way of doing this is to use * glClear(). */ gl.GlClear(GL10.GlColorBufferBit | GL10.GlDepthBufferBit); /* * Now we're ready to draw some 3D objects */ gl.GlMatrixMode(GL10.GlModelview); gl.GlLoadIdentity(); gl.GlTranslatef(0, 0, -3.0f); gl.GlRotatef(mAngle, 0, 1, 0); gl.GlRotatef(mAngle * 0.25f, 1, 0, 0); gl.GlEnableClientState(GL10.GlVertexArray); gl.GlEnableClientState(GL10.GlColorArray); mCube.Draw(gl); gl.GlRotatef(mAngle * 2.0f, 0, 1, 1); gl.GlTranslatef(0.5f, 0.5f, 0.5f); mCube.Draw(gl); mAngle += 1.2f; }
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); }
public void OnDrawFrame(IGL10 gl) { // 清除屏幕缓存和深度缓存 gl.GlClear(GL10.GlColorBufferBit | GL10.GlDepthBufferBit); // 启用顶点坐标数据 gl.GlEnableClientState(GL10.GlVertexArray); // 启用贴图坐标数组数据 gl.GlEnableClientState(GL10.GlTextureCoordArray); // ① // 设置当前矩阵模式为模型视图。 gl.GlMatrixMode(GL10.GlModelview); gl.GlLoadIdentity(); // 把绘图中心移入屏幕2个单位 gl.GlTranslatef(0f, 0.0f, -2.0f); // 旋转图形 gl.GlRotatef(ma.angleY, 0, 1, 0); gl.GlRotatef(ma.angleX, 1, 0, 0); // 设置顶点的位置数据 gl.GlVertexPointer(3, GL10.GlFloat, 0, cubeVerticesBuffer); // 设置贴图的坐标数据 gl.GlTexCoordPointer(2, GL10.GlFloat, 0, cubeTexturesBuffer); // ② // 执行纹理贴图 gl.GlBindTexture(GL10.GlTexture2d, texture); // ③ // 按cubeFacetsBuffer指定的面绘制三角形 gl.GlDrawElements(GL10.GlTriangles, cubeFacetsBuffer.Remaining(), GL10.GlUnsignedByte, cubeFacetsBuffer); // 绘制结束 gl.GlFinish(); // 禁用顶点、纹理坐标数组 gl.GlDisableClientState(GL10.GlVertexArray); gl.GlDisableClientState(GL10.GlTextureCoordArray); // 递增角度值以便每次以不同角度绘制 }
public void OnDrawFrame(IGL10 gl) { /* * Usually, the first thing one might want to do is to clear * the screen. The most efficient way of doing this is to use * glClear(). */ gl.GlClear (GL10.GlColorBufferBit | GL10.GlDepthBufferBit); /* * Now we're ready to draw some 3D objects */ gl.GlMatrixMode (GL10.GlModelview); gl.GlLoadIdentity (); gl.GlTranslatef (0, 0, -3.0f); gl.GlRotatef (mAngle, 0, 1, 0); gl.GlRotatef (mAngle*0.25f, 1, 0, 0); gl.GlEnableClientState (GL10.GlVertexArray); gl.GlEnableClientState (GL10.GlColorArray); mCube.Draw (gl); gl.GlRotatef (mAngle*2.0f, 0, 1, 1); gl.GlTranslatef (0.5f, 0.5f, 0.5f); mCube.Draw (gl); mAngle += 1.2f; }
public void OnSurfaceChanged(IGL10 gl, int width, int height) { // 设置3D视窗的大小及位置 gl.GlViewport(0, 0, width, height); // 将当前矩阵模式设为投影矩阵 gl.GlMatrixMode(GL10.GlProjection); // 初始化单位矩阵 gl.GlLoadIdentity(); // 计算透视视窗的宽度、高度比 float ratio = (float)width / height; // 调用此方法设置透视视窗的空间大小。 gl.GlFrustumf(-ratio, ratio, -1, 1, 1, 10); }
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); }
public void OnSurfaceChanged (IGL10 gl, int width, int height) { gl.GlViewport (0, 0, width, height); /* * Set our projection matrix. This doesn't have to be done * each time we draw, but usually a new projection needs to * be set when the viewport is resized. */ float ratio = (float) width / height; gl.GlMatrixMode (GL10.GlProjection); gl.GlLoadIdentity (); gl.GlFrustumf (-ratio, ratio, -1, 1, 1, 10); }
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); }
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 (); }
public void OnSurfaceChanged(IGL10 gl, int width, int height) { gl.GlViewport(0, 0, width, height); /* * Set our projection matrix. This doesn't have to be done * each time we draw, but usually a new projection needs to * be set when the viewport is resized. */ float ratio = (float)width / height; gl.GlMatrixMode(GL10.GlProjection); gl.GlLoadIdentity(); gl.GlFrustumf(-ratio, ratio, -1, 1, 1, 10); }
public override void Present(float deltaTime) { IGL10 gl = _glGraphics.GL10; gl.GlClear(GL10.GlColorBufferBit); gl.GlMatrixMode(GL10.GlModelview); _vertices.Bind(); for (int i = 0; i < NUM_BOBS; i++) { gl.GlLoadIdentity(); gl.GlTranslatef(_bobs[i].dx, _bobs [i].dy, 0); gl.GlRotatef(_bobs[i].grad, 0, 0, -1f); _vertices.Draw(GL10.GlTriangles, 0, 6); } _vertices.Unbind(); }
public void OnDrawFrame(IGL10 gl) { mObserver.OnDrawFrame(); gl.GlClearColor(Color.GetRedComponent(mBackgroundColor) / 255f, Color.GetGreenComponent(mBackgroundColor) / 255f, Color.GetBlueComponent(mBackgroundColor) / 255f, Color.GetAlphaComponent(mBackgroundColor) / 255f); gl.GlClear(GL10.GlColorBufferBit); gl.GlLoadIdentity(); if (USE_PERSPECTIVE_PROJECTION) { gl.GlTranslatef(0, 0, -6f); } for (int i = 0; i < mCurlMeshes.Count; ++i) { mCurlMeshes.ElementAt(i).OnDrawFrame(gl); } }
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); }
/// <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); } } }
public void OnSurfaceChanged(IGL10 gl, int width, int height) { float ratio = (float)width / height; //����OpenGL�����Ĵ�С gl.GlViewport(0, 0, width, height); //����ͶӰ���� gl.GlMatrixMode(GL10.GlProjection); //����ͶӰ���� gl.GlLoadIdentity(); // �����ӿڵĴ�С viewport[2] = width; viewport[3] = height; OnZoomReset(true); m_bViewRest = false; mbChangeView = true; //GL.Ortho(-mdSizeFactorX, mdSizeFactorX, -mdSizeFactorY, mdSizeFactorY, mdzNear, mdzFar); //updateMatrix(); // Calculate the aspect ratio of the window // ѡ��ģ�۲���� gl.GlMatrixMode(GL10.GlModelview); // ����ģ�۲���� gl.GlLoadIdentity(); // gl.glViewport(0, 0, width, height); // gl.glMatrixMode(GL10.GL_PROJECTION); // gl.glLoadIdentity(); // float ratio = (float)width / height; // gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10); //gl.GlGetIntegerv(GL11.GlViewport, viewport_buf); //GLES20.GlGetFloatv(GL11.GlModelviewMatrix, mvmatrix_buf); //GLES20.GlGetFloatv(GL11.GlProjectionMatrix, projmatrix_buf); }