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 OnSurfaceCreated(IGL10 unused, EGLConfig config) { // Set the background frame color GLES20.GlClearColor(0.0f, 0.0f, 0.0f, 1.0f); mTriangle = new Triangle(); }
public void OnDrawFrame(IGL10 unused) { // Draw background color GLES20.GlClear(GLES20.GL_COLOR_BUFFER_BIT); // Draw triangle mTriangle.Draw(); }
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 OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { gl.GlClearColor(0.0f, 0.0f, 0.0f, 0.5f); gl.GlClearDepthf(1.0f); gl.GlEnable(IGL10Constants.GL_DEPTH_TEST); gl.GlDepthFunc(IGL10Constants.GL_LEQUAL); gl.GlHint(IGL10Constants.GL_PERSPECTIVE_CORRECTION_HINT, IGL10Constants.GL_NICEST); }
public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { // Set the window color. GLES20.GlClearColor(0.1f, 0.1f, 0.1f, 1.0f); mTextureDisplay.Init(); mTextDisplay.SetListener(new WorldOnTextInfoChangeListenerClass(this)); mLabelDisplay.Init(GetPlaneBitmaps()); mObjectDisplay.Init(mContext); }
public void OnDrawFrame(IGL10 gl) { GLES20.GlClear(GLES20.GlColorBufferBit | GLES20.GlDepthBufferBit); // Draw the triangle facing straight on. angleInDegrees += 1.0f; //Prepare model transformation matrix float[] mModelMatrix = new float[16]; //Draw with VBO GLES20.GlBindBuffer(GLES20.GlArrayBuffer, VBOBuffers[0]); GLES20.GlEnableVertexAttribArray(mPositionHandle); GLES20.GlVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GlFloat, false, 0, 0); GLES20.GlBindBuffer(GLES20.GlArrayBuffer, VBOBuffers[1]); GLES20.GlEnableVertexAttribArray(mColorHandle); GLES20.GlVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GlFloat, false, 0, 0); GLES20.GlBindBuffer(GLES20.GlArrayBuffer, 0); //END OF Draw with VBO // This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix // (which currently contains model * view). // Allocate storage for the final combined matrix. This will be passed into the shader program. */ float[] mMVPMatrix = new float[16]; Matrix.MultiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0); // This multiplies the modelview matrix by the projection matrix, and stores the result in the MVP matrix // (which now contains model * view * projection). // THIS IS NOT WORK AT C# Matrix class -> Matrix.MultiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); float[] _mMVPMatrix = new float[16]; Matrix.MultiplyMM(_mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); GLES20.GlUniformMatrix4fv(mMVPMatrixHandle, 1, false, _mMVPMatrix, 0); //GLES20.GlDrawArrays(GLES20.GlTriangles, 0, 3); for (int y = 0; y < 30; y++) { for (int x = 0; x < 30; x++) { Matrix.SetIdentityM(mModelMatrix, 0); Matrix.ScaleM(mModelMatrix, 0, 0.5f, 0.5f, 0.5f); Matrix.TranslateM(mModelMatrix, 0, x * 2.0f, y * 2.0f, 0.0f); Matrix.RotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 0.0f, 0.0f); Matrix.MultiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0); Matrix.MultiplyMM(_mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); GLES20.GlUniformMatrix4fv(mMVPMatrixHandle, 1, false, _mMVPMatrix, 0); GLES20.GlDrawArrays(GLES20.GlTriangles, 0, 3); } } }
public void OnDrawFrame(IGL10 gl) { GLES20.GlClear(GLES20.GlColorBufferBit | GLES20.GlDepthBufferBit); //Prepare model transformation matrix float[] mModelMatrix = new float[16]; Matrix.SetIdentityM(mModelMatrix, 0); Matrix.RotateM(mModelMatrix, 0, angerX, 1.0f, 0.0f, 0.0f); Matrix.RotateM(mModelMatrix, 0, angerY, 0.0f, 1.0f, 0.0f); Matrix.ScaleM(mModelMatrix, 0, scale, scale, scale); //Draw with VBO GLES20.GlBindBuffer(GLES20.GlArrayBuffer, VBOBuffers[0]); GLES20.GlEnableVertexAttribArray(mPositionHandle); GLES20.GlVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GlFloat, false, 0, 0); GLES20.GlBindBuffer(GLES20.GlArrayBuffer, VBOBuffers[1]); GLES20.GlEnableVertexAttribArray(mColorHandle); GLES20.GlVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GlFloat, false, 0, 0); GLES20.GlBindBuffer(GLES20.GlArrayBuffer, VBOBuffers[2]); GLES20.GlEnableVertexAttribArray(mTextureCoordHandle); GLES20.GlVertexAttribPointer(mTextureCoordHandle, 2, GLES20.GlFloat, false, 0, 0); GLES20.GlActiveTexture(GLES20.GlTexture0); GLES20.GlBindTexture(GLES20.GlTexture2d, textureHandle[0]); GLES20.GlUniform1i(mTextureHandle, 0); GLES20.GlBindBuffer(GLES20.GlArrayBuffer, 0); //END OF Draw with VBO // This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix // (which currently contains model * view). // Allocate storage for the final combined matrix. This will be passed into the shader program. */ float[] mMVPMatrix = new float[16]; Matrix.MultiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0); // This multiplies the modelview matrix by the projection matrix, and stores the result in the MVP matrix // (which now contains model * view * projection). // THIS IS NOT WORK AT C# Matrix class -> Matrix.MultiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); float[] _mMVPMatrix = new float[16]; Matrix.MultiplyMM(_mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); GLES20.GlUniformMatrix4fv(mMVPMatrixHandle, 1, false, _mMVPMatrix, 0); GLES20.GlDrawArrays(GLES20.GlTriangles, 0, modelVerticesData.Length / 3); //Cube has 12 triagle faces each face has 3 coord }
public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { gl.GlClearColor(0f, 0f, 0f, 1f); gl.GlShadeModel(GL10.GlSmooth); gl.GlHint(GL10.GlPerspectiveCorrectionHint, GL10.GlNicest); gl.GlHint(GL10.GlLineSmoothHint, GL10.GlNicest); gl.GlHint(GL10.GlPolygonSmoothHint, GL10.GlNicest); gl.GlEnable(GL10.GlLineSmooth); gl.GlDisable(GL10.GlDepthTest); gl.GlDisable(GL10.GlCullFaceCapability); mObserver.OnSurfaceCreated(); }
public void OnSurfaceChanged(IGL10 gl, int width, int height) { GLES20.GlViewport(0, 0, width, height); float ratio = (float)width / height; float left = -ratio; float right = ratio; float top = 1.0f; float bottom = -1.0f; float near = 1.0f; float far = 20.0f; Matrix.FrustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far); }
public virtual void OnDrawFrame(IGL10 gl) { camera.OnDrawFrame(); foreach (GLObject glObject in glObjects) { glObject.DrawFrame(); } if (canvasView != null) { canvasView.Invalidate(); } }
/** 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 OnDrawFrame(IGL10 gl) { GLES20.GlClear(GLES20.GlColorBufferBit | GLES20.GlDepthBufferBit); if (mArSession == null) { return; } if (mDisplayRotationManager.GetDeviceRotation()) { mDisplayRotationManager.UpdateArSessionDisplayGeometry(mArSession); } try { mArSession.SetCameraTextureName(mTextureDisplay.GetExternalTextureId()); ARFrame frame = mArSession.Update(); mTextureDisplay.OnDrawFrame(frame); float fpsResult = DoFpsCalculate(); System.Collections.ICollection faces = (System.Collections.ICollection)mArSession.GetAllTrackables(Java.Lang.Class.FromType(typeof(ARFace))); if (faces.Count == 0) { mTextDisplay.OnDrawFrame(null); return; } Log.Debug(TAG, "Face number: " + faces.Count); ARCamera camera = frame.Camera; foreach (ARFace face in faces) { if (face.TrackingState == ARTrackableTrackingState.Tracking) { mFaceGeometryDisplay.OnDrawFrame(camera, face); StringBuilder sb = new StringBuilder(); UpdateMessageData(sb, fpsResult, face); mTextDisplay.OnDrawFrame(sb); } } } catch (ArDemoRuntimeException e) { Log.Debug(TAG, "Exception on the ArDemoRuntimeException!"); } catch (Throwable t) { // This prevents the app from crashing due to unhandled exceptions. Log.Debug(TAG, "Exception on the OpenGL thread", t); } }
/// <summary> /// Save filter bitmap from {@link ImageFilterView} /// </summary> /// <param name="glSurfaceView">surface view on which is image is drawn</param> /// <param name="gl">open gl source to read pixels from {@link GLSurfaceView}</param> /// <returns>save bitmap</returns> /// <OutOfMemoryError>error when system is out of memory to load and save bitmap</OutOfMemoryError> public static Bitmap CreateBitmapFromGlSurface(GLSurfaceView glSurfaceView, IGL10 gl) { try { //My Code Work <3 var w = glSurfaceView.Width; var h = glSurfaceView.Height; var ib = IntBuffer.Allocate(w * h); IntBuffer ibt = IntBuffer.Allocate(w * h); try { gl.GlReadPixels(0, 0, w, h, GL10.GlRgba, GL10.GlUnsignedByte, ib); //Parallel.For(0, h, i => //{ // for (var j = 0; j < w; j++) // ibt.Put((h - i - 1) * w + j, ib.Get(i * w + j)); //}); for (var i = 0; i < h; i++) { for (var j = 0; j < w; j++) { ibt.Put((h - i - 1) * w + j, ib.Get(i * w + j)); } } var mBitmap = Bitmap.CreateBitmap(w, h, Bitmap.Config.Argb8888); mBitmap.CopyPixelsFromBuffer(ibt); return(mBitmap); } catch (GLException e) { Console.WriteLine(e); return(null); } catch (OutOfMemoryError e) { Console.WriteLine(e); return(null); } } catch (Exception e) { Console.WriteLine(e); return(null); } }
void GLSurfaceView.IRenderer.OnDrawFrame(IGL10 gl) { // create the surface using (var surface = SKSurface.Create(context, renderTarget)) { // draw using SkiaSharp OnDrawFrame(surface, renderTarget); surface.Canvas.Flush(); } // flush the SkiaSharp contents to GL context.Flush(); }
public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { _glGraphics.GL10 = gl; lock (_stateChanged) { if (_state == GLGameState.Initialized) { _screen = GetStartScreen(); } _state = GLGameState.Running; _screen.Resume(); _startTime = Java.Lang.JavaSystem.NanoTime(); } }
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; }
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 Unbind() { IGL10 gl = _glGraphics.GL10; if (_hasTexCoords) { gl.GlDisableClientState(GL10.GlTextureCoordArray); } if (_hasColor) { gl.GlDisableClientState(GL10.GlColorArray); } }
public void OnDrawFrame(IGL10 gl) { // Move ShellViewModel.Animate(); mLightDir[0] = -0.5f; mLightDir[1] = -1.0f; mLightDir[2] = -0.5f; // in left-handed region Vector.normalize(mLightDir); mRT["screen"].switchTargetFrameBuffer(); GLES20.GlClear(GL10.GlColorBufferBit | GL10.GlDepthBufferBit); //////////////////////////////////////////////////////////////////// //// draw models ShellViewModel.LockWith(() => { foreach (var shell in ShellViewModel.Shells) { if (shell.Loaded) { foreach (var rs in shell.RenderSets) { mRT[rs.target].switchTargetFrameBuffer(); GLSL glsl = mGLSL[rs.shader]; GLES20.GlUseProgram(glsl.mProgram); // Projection Matrix GLES20.GlUniformMatrix4fv(glsl.muPMatrix, 1, false, ShellViewModel.ProjectionMatrix, 0); // LightPosition GLES20.GlUniform3fv(glsl.muLightDir, 1, mLightDir, 0); bindBuffer(shell.Surface, glsl); if (!rs.shader.EndsWith("alpha")) { drawNonAlpha(shell.Surface, glsl); drawAlpha(shell.Surface, glsl, false); } else { drawAlpha(shell.Surface, glsl, true); } } } } }); GLES20.GlFlush(); checkGlError(TAG); }
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 void Draw(int primitiveType, int offset, int numVertices) { IGL10 gl = _glGraphics.GL10; if (_indices != null) { _indices.Position(offset); gl.GlDrawElements(primitiveType, numVertices, GL10.GlUnsignedShort, _indices); } else { gl.GlDrawArrays(primitiveType, offset, numVertices); } }
public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { // Set background color and enable depth testing GLES20.GlClearColor(1f, 1f, 1f, 1.0f); GLES20.GlEnable(GLES20.GlDepthTest); resetModelMatCalculator(); mCameraFrustum = new CameraFrustum(); mFloorGrid = new Grid(); mCameraFrustumAndAxis = new CameraFrustumAndAxis(); mTrajectory = new Trajectory(3); // Construct the initial view matrix Matrix.SetIdentityM(mViewMatrix, 0); Matrix.SetLookAtM(mViewMatrix, 0, 5f, 5f, 5f, 0f, 0f, 0f, 0f, 1f, 0f); mCameraFrustumAndAxis.ModelMatrix = ModelMatCalculator.ModelMatrix; }
public override void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { base.OnSurfaceCreated(gl, config); //SETUP OpenGL ES GLES20.GlClearColor(0.9f, 0.9f, 0.9f, 0.9f); GLES20.GlEnable(GLES20.GlDepthTest); //uncoment if needs enabled dpeth test //ENDSETUP OpenGL ES //Loading objects glObjects.Add(new GLObject(this, "vertex_shader", "fragment_shader", "oldhouse_objvertex", "oldhouse_objnormal", "oldhouse_objtexture", "body")); //Ask android to run RAM garbage cleaner System.GC.Collect(); }
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 OnDrawFrame(IGL10 gl) { GLES10.GlClear(GLES10.GlColorBufferBit | GLES10.GlDepthBufferBit | GLES10.GlStencilBufferBit); // create the contexts if not done already if (context == null) { var glInterface = GRGlInterface.CreateNativeGlInterface(); context = GRContext.Create(GRBackend.OpenGL, glInterface); } // manage the drawing surface if (renderTarget == null || surface == null || renderTarget.Width != surfaceWidth || renderTarget.Height != surfaceHeight) { // create or update the dimensions renderTarget?.Dispose(); var buffer = new int[3]; GLES20.GlGetIntegerv(GLES20.GlFramebufferBinding, buffer, 0); GLES20.GlGetIntegerv(GLES20.GlStencilBits, buffer, 1); GLES20.GlGetIntegerv(GLES20.GlSamples, buffer, 2); var samples = buffer[2]; var maxSamples = context.GetMaxSurfaceSampleCount(colorType); if (samples > maxSamples) { samples = maxSamples; } var glInfo = new GRGlFramebufferInfo((uint)buffer[0], colorType.ToGlSizedFormat()); renderTarget = new GRBackendRenderTarget(surfaceWidth, surfaceHeight, samples, buffer[1], glInfo); // create the surface surface?.Dispose(); surface = SKSurface.Create(context, renderTarget, surfaceOrigin, colorType); } using (new SKAutoCanvasRestore(surface.Canvas, true)) { // start drawing var e = new SKPaintGLSurfaceEventArgs(surface, renderTarget, surfaceOrigin, colorType); OnPaintSurface(e); #pragma warning disable CS0618 // Type or member is obsolete OnDrawFrame(e.Surface, e.RenderTarget); #pragma warning restore CS0618 // Type or member is obsolete } // flush the SkiaSharp contents to GL surface.Canvas.Flush(); context.Flush(); }
public void OnDrawFrame(IGL10 gl) { GLES10.GlClear(GLES10.GlStencilBufferBit); // create the surface using (var surface = SKSurface.Create(context, renderTarget)) { // draw using SkiaSharp OnDrawFrame(surface, renderTarget); surface.Canvas.Flush(); } // flush the SkiaSharp contents to GL context.Flush(); }
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 void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { if (RenderManager.externalPaused) { RenderManager.initShaders(); } else { RenderManager.createObjects(); } GLES20.GlClearColor(0.1f, 0.1f, 0.9f, 0.0f); GLES20.GlEnable(GLES20.GlDepthTest); GLES20.GlEnable(GLES20.GlCullFaceMode); GLES20.GlCullFace(GLES20.GlBack); }
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 OnDrawFrame (IGL10 gl) { if (!_isInitialised) { _effectContext = EffectContext.CreateWithCurrentGlContext (); Renderer.Init (); LoadTextures (); _isInitialised = true; } if (CurrentEffect != Resource.Id.none) { InitialiseEffect (); ApplyEffect (); } RenderResult (); }
public void Draw(IGL10 gl) { gl.GlFrontFace(IGL10Constants.GL_CW); gl.GlVertexPointer(3, IGL10Constants.GL_FLOAT, 0, mVertexBuffer); gl.GlColorPointer(4, IGL10Constants.GL_FLOAT, 0, mColorBuffer); gl.GlEnableClientState(IGL10Constants.GL_VERTEX_ARRAY); gl.GlEnableClientState(IGL10Constants.GL_COLOR_ARRAY); // draw all 36 triangles gl.GlDrawElements(IGL10Constants.GL_TRIANGLES, 36, IGL10Constants.GL_UNSIGNED_BYTE, mIndexBuffer); gl.GlDisableClientState(IGL10Constants.GL_VERTEX_ARRAY); gl.GlDisableClientState(IGL10Constants.GL_COLOR_ARRAY); }
public void OnDrawFrame(IGL10 unused) { GLES20.GlClear(GLES20.GlColorBufferBit); drawRectangle(yuvTextures[1], remoteVertices); drawRectangle(yuvTextures[0], localVertices); ++numFramesSinceLastLog; long now = JavaSystem.NanoTime(); if (lastFPSLogTime == -1 || now - lastFPSLogTime > 1e9) { double fps = numFramesSinceLastLog / ((now - lastFPSLogTime) / 1e9); Log.Debug(TAG, "Rendered FPS: " + fps); lastFPSLogTime = now; numFramesSinceLastLog = 1; } checkNoGLES2Error(); }
public void OnDrawFrame(IGL10 gl) { // Our vertices. float[] vertices = { -1.5f, 1.5f, 0.0f, // 0, Top Left -1.5f, -1.5f, 0.0f, // 1, Bottom Left 1.5f, 1.5f, 0.0f, // 3, Top Right 1.5f, -1.5f, 0.0f, // 2, Bottom Right }; // a float is 4 bytes, therefore we multiply the number if // vertices with 4. ByteBuffer vbb = ByteBuffer.AllocateDirect(vertices.Length * 4); vbb.Order(ByteOrder.NativeOrder()); FloatBuffer vertexBuffer = vbb.AsFloatBuffer(); vertexBuffer.Put(vertices); vertexBuffer.Position(0); // The order we like to connect them. byte[] colors = { (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255 }; // a float is 4 bytes, therefore we multiply the number if // vertices with 4. ByteBuffer cbb = ByteBuffer.AllocateDirect(colors.Length * 4); cbb.Order(ByteOrder.NativeOrder()); cbb.Put(colors); cbb.Position(0); gl.GlVertexPointer(3, GL10.GlFloat, 0, vertexBuffer); gl.GlEnableClientState(GL10.GlVertexArray); gl.GlColorPointer(4, GL10.GlUnsignedByte, 0, cbb); gl.GlEnableClientState(GL10.GlColorArray); gl.GlDrawArrays(GL10.GlTriangleStrip, 0, 4); }
public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { // Create the triangle SetupTriangle(); // Create the image information SetupImage(); // Set the clear color to yellow GLES20.GlClearColor(1.0f, 1.0f, 0f, 1); GLES20.GlEnable(GLES20.GlBlend); GLES20.GlBlendFunc(GLES20.GlOne, GLES20.GlOneMinusSrcAlpha); #region Solid colors mode /* * // Create the shaders, solid color * int vertexShader = ShaderHelper.LoadShader(GLES20.GlVertexShader, ShaderHelper.VsSolidColor); * int fragmentShader = ShaderHelper.LoadShader(GLES20.GlFragmentShader, ShaderHelper.FsSolidColor); * * ShaderHelper.SpSolidColor = GLES20.GlCreateProgram(); // create empty OpenGL ES Program * GLES20.GlAttachShader(ShaderHelper.SpSolidColor, vertexShader); // add the vertex shader to program * GLES20.GlAttachShader(ShaderHelper.SpSolidColor, fragmentShader); // add the fragment shader to program * GLES20.GlLinkProgram(ShaderHelper.SpSolidColor); // creates OpenGL ES program executables * * // Set our shader programm * GLES20.GlUseProgram(ShaderHelper.SpSolidColor); */ #endregion #region Texture mode // Create the shaders, images int vertexShader = ShaderHelper.LoadShader(GLES20.GlVertexShader, ShaderHelper.VsImage); int fragmentShader = ShaderHelper.LoadShader(GLES20.GlFragmentShader, ShaderHelper.FsImage); ShaderHelper.SpImage = GLES20.GlCreateProgram(); GLES20.GlAttachShader(ShaderHelper.SpImage, vertexShader); GLES20.GlAttachShader(ShaderHelper.SpImage, fragmentShader); GLES20.GlLinkProgram(ShaderHelper.SpImage); // Set our shader programm GLES20.GlUseProgram(ShaderHelper.SpImage); #endregion }
public void OnSurfaceCreated(IGL10 unused, EGLConfig config) { try { var vertexSource = LoadRawString(Resource.Raw.copy_oes_vs); var fragmentSource = LoadRawString(Resource.Raw.copy_oes_fs); _shaderCopyOes.SetProgram(vertexSource, fragmentSource); } catch (System.Exception ex) { showError(ex.Message.ToString()); } var vertexSourceFilter = LoadRawString(Resource.Raw.filter_vs); var fragmentSourceFilter = LoadRawString(Resource.Raw.filter_fs); _shaderFilterDefault.SetProgram(vertexSourceFilter, fragmentSourceFilter); _fboExternal.Reset(); _fboOffscreen.Reset(); }
public void OnDrawFrame(IGL10 gl) { // Move ShellViewModel.Animate (); mLightDir[0] = -0.5f; mLightDir[1] = -1.0f; mLightDir[2] = -0.5f; // in left-handed region Vector.normalize(mLightDir); mRT["screen"].switchTargetFrameBuffer(); GLES20.GlClear(GL10.GlColorBufferBit | GL10.GlDepthBufferBit); //////////////////////////////////////////////////////////////////// //// draw models ShellViewModel.LockWith (() => { foreach (var shell in ShellViewModel.Shells) { if(shell.Loaded) { foreach(var rs in shell.RenderSets) { mRT[rs.target].switchTargetFrameBuffer(); GLSL glsl = mGLSL[rs.shader]; GLES20.GlUseProgram(glsl.mProgram); // Projection Matrix GLES20.GlUniformMatrix4fv(glsl.muPMatrix, 1, false, ShellViewModel.ProjectionMatrix, 0); // LightPosition GLES20.GlUniform3fv(glsl.muLightDir, 1, mLightDir, 0); bindBuffer(shell.Surface, glsl); if(!rs.shader.EndsWith("alpha")) { drawNonAlpha(shell.Surface, glsl); drawAlpha(shell.Surface, glsl, false); } else { drawAlpha(shell.Surface, glsl, true); } } } } }); GLES20.GlFlush(); checkGlError(TAG); }
public void OnDrawFrame (IGL10 gl) { // Our vertices. float[] vertices = { -1.5f, 1.5f, 0.0f, // 0, Top Left -1.5f, -1.5f, 0.0f, // 1, Bottom Left 1.5f, 1.5f, 0.0f, // 3, Top Right 1.5f, -1.5f, 0.0f, // 2, Bottom Right }; // a float is 4 bytes, therefore we multiply the number if // vertices with 4. ByteBuffer vbb = ByteBuffer.AllocateDirect(vertices.Length * 4); vbb.Order(ByteOrder.NativeOrder()); FloatBuffer vertexBuffer = vbb.AsFloatBuffer(); vertexBuffer.Put(vertices); vertexBuffer.Position(0); // The order we like to connect them. byte[] colors = { (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255, (byte)0.0, (byte)255 }; // a float is 4 bytes, therefore we multiply the number if // vertices with 4. ByteBuffer cbb = ByteBuffer.AllocateDirect(colors.Length * 4); cbb.Order(ByteOrder.NativeOrder()); cbb.Put (colors); cbb.Position (0); gl.GlVertexPointer (3, GL10.GlFloat, 0, vertexBuffer); gl.GlEnableClientState (GL10.GlVertexArray); gl.GlColorPointer(4, GL10.GlUnsignedByte, 0, cbb); gl.GlEnableClientState (GL10.GlColorArray); gl.GlDrawArrays (GL10.GlTriangleStrip, 0, 4); }
public void OnSurfaceCreated (IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { nativeInit (IntPtr.Zero); }
public void OnSurfaceChanged(IGL10 unused, int width, int height) { GLES20.GlViewport(0, 0, width, height); checkNoGLES2Error(); }
public void OnSurfaceChanged (IGL10 gl, int w, int h) { //gl.glViewport(0, 0, w, h); nativeResize (IntPtr.Zero, IntPtr.Zero, w, h); }
public void OnSurfaceCreated(IGL10 gl, EGLConfig config) { this.engine.CreateSurface(); this.SetupPlanet(); }
public void OnSurfaceCreated(IGL10 unused, EGLConfig config) { int program = GLES20.GlCreateProgram(); addShaderTo(GLES20.GlVertexShader, VERTEX_SHADER_STRING, program); addShaderTo(GLES20.GlFragmentShader, FRAGMENT_SHADER_STRING, program); GLES20.GlLinkProgram(program); int[] result = new int[] { GLES20.GlFalse }; result[0] = GLES20.GlFalse; GLES20.GlGetProgramiv(program, GLES20.GlLinkStatus, result, 0); abortUnless(result[0] == GLES20.GlTrue, GLES20.GlGetProgramInfoLog(program)); GLES20.GlUseProgram(program); GLES20.GlUniform1i(GLES20.GlGetUniformLocation(program, "y_tex"), 0); GLES20.GlUniform1i(GLES20.GlGetUniformLocation(program, "u_tex"), 1); GLES20.GlUniform1i(GLES20.GlGetUniformLocation(program, "v_tex"), 2); // Actually set in drawRectangle(), but queried only once here. posLocation = GLES20.GlGetAttribLocation(program, "in_pos"); int tcLocation = GLES20.GlGetAttribLocation(program, "in_tc"); GLES20.GlEnableVertexAttribArray(tcLocation); GLES20.GlVertexAttribPointer(tcLocation, 2, GLES20.GlFloat, false, 0, textureCoords); GLES20.GlClearColor(0.0f, 0.0f, 0.0f, 1.0f); checkNoGLES2Error(); }
public void OnSurfaceChanged (IGL10 gl, int width, int height) { if (Renderer != null) { Renderer.UpdateViewSize (width, height); } }
public void OnSurfaceChanged(IGL10 gl, int width, int height) { this.engine.UpdateSurface(width, height); }
public void OnDrawFrame(IGL10 gl) { OS.UpdateAndRender(); }
public void OnDrawFrame (IGL10 gl) { nativeRender (IntPtr.Zero); }
public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { /* * By default, OpenGL enables features that improve quality * but reduce performance. One might want to tweak that * especially on software renderer. */ gl.GlDisable (GL10.GlDither); /* * Some one-time OpenGL initialization can be made here * probably based on features of this particular context */ gl.GlHint (GL10.GlPerspectiveCorrectionHint, GL10.GlFastest); if (mTranslucentBackground) gl.GlClearColor (0,0,0,0); else gl.GlClearColor (1,1,1,1); // FIXME: Mono.Android.dll misses this constant. Filed as #3531. gl.GlEnable(2884);//GL10.GlCullFace); gl.GlShadeModel(GL10.GlSmooth); gl.GlEnable(GL10.GlDepthTest); }
/// <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 unused, int width, int height) { // Adjust the viewport based on geometry changes, // such as screen rotation GLES20.GlViewport(0, 0, width, height); }
public void OnSurfaceCreated (IGL10 gl, EGLConfig config) { // throw new NotImplementedException(); }
public void OnSurfaceCreated (IGL10 gl, EGLConfig config) { }
public void OnSurfaceCreated (IGL10 gl, EGLConfig config) { nativeInit (IntPtr.Zero); }
public void OnDrawFrame(IGL10 gl) { if (this.nextTexture != null) { var tmp = this.nextTexture; this.nextTexture = null; Utils.BindTextureAsset(this.engine.Planet.TextureId, this.context, tmp); } this.engine.RenderFrame(); }
public void OnSurfaceChanged(IGL10 gl, int width, int height) { }
public void OnSurfaceCreated(IGL10 gl, EGLConfig config) { if (surfaceCreated) { surfaceCreated = false; return; } surfaceCreated = true; application.Shown(); }