public override void Present(float deltaTime) { IGL10 gl = _glGraphics.GL10; //gl.GlViewport (0, 0, _glGraphics.Width, _glGraphics.Height); //gl.GlClearColor(0,0,1,1); gl.GlClear(GL10.GlColorBufferBit); //gl.GlMatrixMode (GL10.GlProjection); //gl.GlLoadIdentity (); //gl.GlOrthof (0,320,0,480,1,-1); //gl.GlEnable (GL10.GlTexture2d); //gl.GlEnable (GL10.GlBlend); gl.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha); _vertices.Bind(); _textureRgba.BindTexture(); _vertices.Draw(GL10.GlTriangles, 6, 6); _textureRgb.BindTexture(); _vertices.Draw(GL10.GlTriangles, 0, 6); _vertices.Unbind(); }
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); // 递增角度值以便每次以不同角度绘制 }
/** Called to draw the current frame. */ public void onDrawFrame(IGL10 gl) { if (!IsActive) { return; } gl.GlClear(GL10.GlColorBufferBit | GL10.GlDepthBufferBit); // Call our native function to render camera content RecognitionFragment.RenderCamera(ViewportWidth, ViewportHeight, Angle); float[] mvpMatrix = new float[16]; if (computeModelViewProjectionMatrix(mvpMatrix)) { if (monkeyMesh != null && monkeyMesh.MeshLoaded) { if (monkeyMesh.GLLoaded) { //draw our 3d mesh on top of the marker monkeyMesh.DrawMesh(mvpMatrix); } else { monkeyMesh.InitMeshGL(); } RenderUtils.CheckGLError("completed Monkey head Render"); } } gl.GlFinish(); }
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 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 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; }
/** Called to draw the current frame. */ public void onDrawFrame(IGL10 gl) { if (!IsActive) { return; } gl.GlClear(GL10.GlColorBufferBit | GL10.GlDepthBufferBit); // Call our native function to render camera content GeoFragment.RenderCamera(ViewportWidth, ViewportHeight, Angle); gl.GlFinish(); }
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) { // 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 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 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 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); }
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); } }
/// <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 OnDrawFrame(IGL10 gl) { if (mbChangeView) { GL.MatrixMode(All.Projection); GL.LoadIdentity(); GL.Ortho(-mdSizeFactorX, mdSizeFactorX, -mdSizeFactorY, mdSizeFactorY, mdzNear, mdzFar); updateMatrix(); mbChangeView = false; } if (m_bFitAll || m_bViewRest) { GL.MatrixMode(All.Projection); GL.LoadIdentity(); GL.Ortho(-mdSizeFactorX, mdSizeFactorX, -mdSizeFactorY, mdSizeFactorY, mdzNear, mdzFar); //updateMatrix(); //m_bViewRest = false; } GL.MatrixMode(All.Modelview); if (mbSpecialView) { GL.LoadIdentity(); CMatrixMath.Matrix4fSetIdentity(ref m_Transform); if (mViewIndex[0]) GLU.GluLookAt(gl, 0f, -10f, 0f, 0f, 0.0f, 0f, 0f, 0f, 1f); else if (mViewIndex[1]) GLU.GluLookAt(gl, 0f, 10f, 0f, 0f, 0.0f, 0f, 0f, 0f, 1f); else if (mViewIndex[2]) GLU.GluLookAt(gl, -10f, 0f, 0f, 0f, 0.0f, 0f, 0f, 0f, 1f); else if (mViewIndex[3]) GLU.GluLookAt(gl, 10f, 0f, 0f, 0f, 0.0f, 0f, 0f, 0f, 1f); else if (mViewIndex[4]) { GLU.GluLookAt(gl, 0f, 0f, 10f, 0f, 0.0f, 0f, 0f, 1f, 0f); } else if (mViewIndex[5]) GLU.GluLookAt(gl, 0f, 0f, -10f, 0f, 0.0f, 0f, 0f, 1f, 0f); updateMatrix(); mbSpecialView = false; for (int i = 0; i < 6;i++ ) { mViewIndex[i] = false; } } //GL.LoadIdentity(); { if (m_bFitAll || m_bViewRest) { GL.LoadIdentity(); CMatrixMath.Matrix4fSetIdentity(ref m_Transform); updateMatrix(); m_bViewRest = false; m_bFitAll = false; } if (m_bTransState) { GL.Translate(mTransomValue[0], mTransomValue[1], mTransomValue[2]); } if (m_bScaleState) { GL.Scale(mScaleValue, mScaleValue, mScaleValue); updateMatrix(); } GL.PushMatrix(); //Transform.TOM(); GL.MultMatrix(Transform.TOM()); //string str = String.Format("{0},{1},{2}", Transform.M[0], Transform.M[1], Transform.M[2]); //Log.Debug(TAG, str); } gl.GlClear(GL10.GlColorBufferBit | GL10.GlDepthBufferBit); DrawAxisArrow(gl, 0f, 0f, 5f, 0f, 0f, 1.0f); DrawAxisArrow(gl, 0f, 5f, 0f, 0f, 1f, 0f); DrawAxisArrow(gl, 5f, 0f, 0f, 1f, 0f, 0f); { //glScalef(ArcBall.zoomRate, ArcBall.zoomRate, ArcBall.zoomRate);//2. ���� GL.PopMatrix(); } }
/** Called to draw the current frame. */ public void OnDrawFrame(IGL10 gl) { if (!IsActive) { return; } gl.GlClear(GL10.GlColorBufferBit | GL10.GlDepthBufferBit); // Call our native function to render camera content RecognitionFragment.RenderCamera(ViewportWidth, ViewportHeight, Angle); if (RecognitionFragment.IsTracking) { Marker currentMarker = RecognitionFragment.CurrentMarker; //Here we decide which 3d object to draw and we draw it if (currentMarker.Id.CompareTo("3_522") == 0) { float[] mvMatrix = new float[16]; float[] pMatrix = new float[16]; if (ComputeModelViewProjectionMatrix(mvMatrix, pMatrix)) { if (videoMesh != null && videoMesh.MeshLoaded) { if (videoMesh.GLLoaded) { videoMesh.DrawMesh(mvMatrix, pMatrix); } else { videoMesh.InitMeshGL(); } RenderUtils.CheckGLError("completed video mesh Render"); } } } else { float[] mvpMatrix = new float[16]; if (ComputeModelViewProjectionMatrix(mvpMatrix)) { //draw our 3d mesh on top of the marker if (monkeyMesh != null && monkeyMesh.MeshLoaded) { if (monkeyMesh.GLLoaded) { monkeyMesh.DrawMesh(mvpMatrix); } else { monkeyMesh.InitMeshGL(); } RenderUtils.CheckGLError("completed Monkey head Render"); } } } } //if the video is still playing and we have lost tracking, we still draw the video, //but in a fixed frontal position if (!RecognitionFragment.IsTracking && videoMesh != null && videoMesh.IsPlaying()) { float[] mvMatrix = new float[16]; float[] pMatrix = new float[16]; ComputeProjectionMatrix(pMatrix); if (Angle == 0) { mvMatrix[0] = 1.0f; mvMatrix[1] = 0.0f; mvMatrix[2] = 0.0f; mvMatrix[3] = -0.5f; mvMatrix[4] = 0.0f; mvMatrix[5] = -1.0f; mvMatrix[6] = 0.0f; mvMatrix[7] = 0.4f; mvMatrix[8] = 0.0f; mvMatrix[9] = 0.0f; mvMatrix[10] = -1.0f; mvMatrix[11] = -1.3f; mvMatrix[12] = 0.0f; mvMatrix[13] = 0.0f; mvMatrix[14] = 0.0f; mvMatrix[15] = 1.0f; } else if (Angle == 90) { mvMatrix[0] = 0.0f; mvMatrix[1] = 1.0f; mvMatrix[2] = 0.0f; mvMatrix[3] = -0.5f; mvMatrix[4] = 1.0f; mvMatrix[5] = 0.0f; mvMatrix[6] = 0.0f; mvMatrix[7] = -0.5f; mvMatrix[8] = 0.0f; mvMatrix[9] = 0.0f; mvMatrix[10] = -1.0f; mvMatrix[11] = -1.3f; mvMatrix[12] = 0.0f; mvMatrix[13] = 0.0f; mvMatrix[14] = 0.0f; mvMatrix[15] = 1.0f; } else if (Angle == 180) { mvMatrix[0] = -1.0f; mvMatrix[1] = 0.0f; mvMatrix[2] = 0.0f; mvMatrix[3] = 0.5f; mvMatrix[4] = 0.0f; mvMatrix[5] = 1.0f; mvMatrix[6] = 0.0f; mvMatrix[7] = -0.4f; mvMatrix[8] = 0.0f; mvMatrix[9] = 0.0f; mvMatrix[10] = -1.0f; mvMatrix[11] = -1.3f; mvMatrix[12] = 0.0f; mvMatrix[13] = 0.0f; mvMatrix[14] = 0.0f; mvMatrix[15] = 1.0f; } else if (Angle == 270) { mvMatrix[0] = 0.0f; mvMatrix[1] = -1.0f; mvMatrix[2] = 0.0f; mvMatrix[3] = 0.5f; mvMatrix[4] = -1.0f; mvMatrix[5] = 0.0f; mvMatrix[6] = 0.0f; mvMatrix[7] = 0.5f; mvMatrix[8] = 0.0f; mvMatrix[9] = 0.0f; mvMatrix[10] = -1.0f; mvMatrix[11] = -1.3f; mvMatrix[12] = 0.0f; mvMatrix[13] = 0.0f; mvMatrix[14] = 0.0f; mvMatrix[15] = 1.0f; } videoMesh.DrawMesh(mvMatrix, pMatrix); RenderUtils.CheckGLError("completed video mesh Render"); } gl.GlFinish(); }