public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { GLES20.GlClearColor(0.1f, 0.1f, 0.1f, 1.0f); // Create the texture and pass it to ARCore session to be filled during update(). mBackgroundRenderer.CreateOnGlThread(this); mSession?.SetCameraTextureName(mBackgroundRenderer.TextureId); // Prepare the other rendering objects. try { mVirtualObject.CreateOnGlThread(this, "andy.obj", "andy.png"); mVirtualObject.setMaterialProperties(0.0f, 3.5f, 1.0f, 6.0f); mVirtualObjectShadow.CreateOnGlThread(this, "andy_shadow.obj", "andy_shadow.png"); mVirtualObjectShadow.SetBlendMode(ObjectRenderer.BlendMode.Shadow); mVirtualObjectShadow.setMaterialProperties(1.0f, 0.0f, 0.0f, 1.0f); } catch (Java.IO.IOException e) { Log.Error(TAG, "Failed to read obj file"); } try { mPlaneRenderer.CreateOnGlThread(this, "trigrid.png"); } catch (IOException e) { Log.Error(TAG, "Failed to read plane texture"); } mPointCloud.CreateOnGlThread(this); }
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, 1.0f); GLES20.GlEnable(GLES20.GlDepthTest); //uncoment if needs enabled dpeth test //GLES20.GlEnable(2884); // GlCullFace == 2884 see OpenGL documentation to this constant value GLES20.GlDisable(2884); //GLES20.GlFrontFace(GLES20.GlCcw); //GLES20.GlCullFace(GLES20.GlFront); GLES20.GlEnable(GL10.GlBlend); GLES20.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha); // GLES20.GlDisable(GL10.GlLighting); // GLES20.GlEnable(2884); // GLES20.GlDisable(GL10.GlDepthBufferBit); // GLES20.GlEnable(GL10.GlDither); // GLES20.GlEnable(GL10.GlBlend); // GLES20.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOne); //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 OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { GLES20.GlClearColor(0.1f, 0.1f, 0.1f, 1.0f); mBackgroundRenderer.CreateOnGlThread(_context); mSession.SetCameraTextureName(mBackgroundRenderer.TextureId); try { mVirtualObject.CreateOnGlThread(/*context=*/ Context, "andy.obj", "andy.png"); mVirtualObject.setMaterialProperties(0.0f, 3.5f, 1.0f, 6.0f); mVirtualObjectShadow.CreateOnGlThread(/*context=*/ Context, "andy_shadow.obj", "andy_shadow.png"); mVirtualObjectShadow.SetBlendMode(ObjectRenderer.BlendMode.Shadow); mVirtualObjectShadow.setMaterialProperties(1.0f, 0.0f, 0.0f, 1.0f); } catch (Java.IO.IOException ex) { Log.Error(TAG, "Failed to read obj file"); } try { mPlaneRenderer.CreateOnGlThread(/*context=*/ _context, "trigrid.png"); } catch (Java.IO.IOException ex) { Log.Error(TAG, "Failed to read plane texture"); } mPointCloud.CreateOnGlThread(/*context=*/ Context); }
public /* override */ void OnSurfaceCreated(GL10 pGL, EGLConfig pConfig) { Debug.D("onSurfaceCreated"); GLHelper.Reset(pGL); GLHelper.SetPerspectiveCorrectionHintFastest(pGL); // pGL.glEnable(GL10.GL_POLYGON_SMOOTH); // pGL.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST); // pGL.glEnable(GL10.GL_LINE_SMOOTH); // pGL.glHint(GL10.GL_LINE_SMOOTH_HINT, GL10.GL_NICEST); // pGL.glEnable(GL10.GL_POINT_SMOOTH); // pGL.glHint(GL10.GL_POINT_SMOOTH_HINT, GL10.GL_NICEST); GLHelper.SetShadeModelFlat(pGL); GLHelper.DisableLightning(pGL); GLHelper.DisableDither(pGL); GLHelper.DisableDepthTest(pGL); GLHelper.DisableMultisample(pGL); GLHelper.EnableBlend(pGL); GLHelper.EnableTextures(pGL); GLHelper.EnableTexCoordArray(pGL); GLHelper.EnableVertexArray(pGL); GLHelper.EnableCulling(pGL); pGL.GlFrontFace(GL10Consts.GlCcw); pGL.GlCullFace(GL10Consts.GlBack); // GLHelper.EnableExtensions(pGL, this.mEngine.getEngineOptions().getRenderOptions()); GLHelper.EnableExtensions(pGL, this.mEngine.EngineOptions.RenderOptions); }
public void OnSurfaceCreated(Javax.Microedition.Khronos.Egl.EGLConfig config) { GL.ClearColor(0.1f, 0.1f, 0.4f, 1.0f); // 背景色の設定。 GL.Enable(EnableCap.DepthTest); // Depthバッファの有効化(Z座標で手前に表示) Shader = new Shader(); Shape = new Triangle(0.5f); }
/// <summary> /// Called when the OpenGL surface its created /// </summary> public void OnSurfaceCreated(IGL10 gl, EGLConfig config) { GLES20.GlClearColor(0.1f, 0.1f, 0.1f, 1.0f); this.backgroundRenderer.CreateOnGlThread(this.context); this.session.SetCameraTextureName(this.backgroundRenderer.TextureId); LoadArAssets(); this.session.Resume(); }
// =========================================================== // Methods // =========================================================== private int findConfigAttrib(EGL10 pEGL, EGLDisplay pEGLDisplay, EGLConfig pEGLConfig, int pAttribute, int pDefaultValue) { if (pEGL.EglGetConfigAttrib(pEGLDisplay, pEGLConfig, pAttribute, this.mValue)) { return this.mValue[0]; } return pDefaultValue; }
public void OnSurfaceCreated(Javax.Microedition.Khronos.Opengles.IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { // Set the background frame color GLES20.GlClearColor(0.0f, 0.0f, 0.0f, 1.0f); mTriangle = new Triangle(); mSquare = new Square(); }
// =========================================================== // Methods // =========================================================== private int findConfigAttrib(EGL10 pEGL, EGLDisplay pEGLDisplay, EGLConfig pEGLConfig, int pAttribute, int pDefaultValue) { if (pEGL.EglGetConfigAttrib(pEGLDisplay, pEGLConfig, pAttribute, this.mValue)) { return(this.mValue[0]); } return(pDefaultValue); }
public void OnSurfaceCreated(IGL10 gl, EGLConfig config) { try { } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public void OnSurfaceCreated(IGL10 gl, EGLConfig config) { try { } catch (Exception e) { Console.WriteLine(e); } }
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) { // Clear the original color and set a new color. GLES20.GlClearColor(0.1f, 0.1f, 0.1f, 1.0f); foreach (HandRelatedDisplay handRelatedDisplay in mHandRelatedDisplays) { handRelatedDisplay.Init(); } mTextureDisplay.Init(); mTextDisplay.SetListener(new HandOnTextInfoChangeListenerClass(this)); }
public void OnSurfaceCreated(IGL10 gl, EGLConfig config) { GLES20.GlEnable(GL10.GlBlend); // For premultiplied alpha: // GLES20.GlBlendFunc( GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA ); GLES20.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha); GLES20.GlEnable(GL10.GlScissorTest); TextureCache.Reload(); }
/** * Prepares EGL. We want a GLES 2.0 context and a surface that supports pbuffer. */ private void eglSetup(int width, int height) { mEGL = (IEGL10)EGLContext.EGL; mEGLDisplay = mEGL.EglGetDisplay(EGL10.EglDefaultDisplay); if (!mEGL.EglInitialize(mEGLDisplay, null)) { throw new RuntimeException("unable to initialize EGL10"); } // Configure EGL for pbuffer and OpenGL ES 2.0. We want enough RGB bits // to be able to tell if the frame is reasonable. int[] attribList = { EGL10.EglRedSize, 16, EGL10.EglGreenSize, 16, EGL10.EglBlueSize, 16, EGL10.EglAlphaSize, 16, EGL10.EglSurfaceType, EGL10.EglPbufferBit, EGL10.EglRenderableType, EGL_OPENGL_ES2_BIT, EGL10.EglNone }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!mEGL.EglChooseConfig(mEGLDisplay, attribList, configs, 1, numConfigs)) { throw new RuntimeException("unable to find RGB888+pbuffer EGL config"); } // Configure context for OpenGL ES 2.0. int[] attrib_list = { EGL14.EglContextClientVersion, 2, EGL10.EglNone }; mEGLContext = mEGL.EglCreateContext(mEGLDisplay, configs[0], EGL10.EglNoContext, attrib_list); CheckEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } // Create a pbuffer surface. By using this for output, we can use glReadPixels // to test values in the output. int[] surfaceAttribs = { EGL10.EglWidth, width, EGL10.EglHeight, height, EGL10.EglNone }; mEGLSurface = mEGL.EglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs); CheckEglError("eglCreatePbufferSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { // Clear the color and set the window color. GLES20.GlClearColor(0.1f, 0.1f, 0.1f, 1.0f); foreach (BodyRelatedDisplay bodyRelatedDisplay in mBodyRelatedDisplays) { bodyRelatedDisplay.Init(); } mTextureDisplay.Init(); mTextDisplay.SetListener(new BodyOnTextInfoChangeListenerClass(this)); }
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 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 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 OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { // 关闭抗抖动 gl.GlDisable(GL10.GlDither); // 设置系统对透视进行修正 gl.GlHint(GL10.GlPerspectiveCorrectionHint, GL10.GlFastest); gl.GlClearColor(0, 0, 0, 0); // 设置阴影平滑模式 gl.GlShadeModel(GL10.GlSmooth); // 启用深度测试 gl.GlEnable(GL10.GlDepthTest); // 设置深度测试的类型 gl.GlDepthFunc(GL10.GlLequal); // 启用2D纹理贴图 gl.GlEnable(GL10.GlTexture2d); // 装载纹理 loadTexture(gl); }
public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { GLES20.GlClearColor(0.1f, 0.1f, 0.1f, 1.0f); if (isOpenCameraOutside) { mTextureDisplay.Init(mTextureId); } else { mTextureDisplay.Init(); } Log.Debug(TAG, "On surface created textureId= " + mTextureId); mFaceGeometryDisplay.Init(mContext); mTextDisplay.SetListener(new FaceOnTextInfoChangeListenerClass(this)); }
public override void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { base.OnSurfaceCreated(gl, config); //SETUP OpenGL ES GLES20.GlClearColor(0.5f, 0.5f, 0.5f, 1.0f); GLES20.GlEnable(GLES20.GlDepthTest); //uncoment if needs enabled dpeth test // GLES20.GlEnable(2884); // GlCullFace == 2884 see OpenGL documentation to this constant value // GLES20.GlCullFace(GLES20.GlFront); //ENDSETUP OpenGL ES //Loading objects glObjects.Add(new GLObject(this, "den_vertex_shader", "den_fragment_shader", "den_house1_objvertex", "den_house1_objnormal", "den_house1_objtexture", "den_housetextutre2")); glObjects.Add(new GLObject(this, "den_vertex_shader", "den_fragment_shader", "den_house2_objvertex", "den_house2_objnormal", "den_house2_objtexture", "den_housetextutre2")); glObjects.Add(new GLObject(this, "den_vertex_shader", "den_fragment_shader", "den_house3_objvertex", "den_house3_objnormal", "den_house3_objtexture", "den_housetextutre2")); glObjects.Add(new DenGlassObject(this, "den_glass")); //Ask android to run RAM garbage cleaner System.GC.Collect(); }
public EGLConfig chooseConfig(EGL10 pEGL, EGLDisplay pEGLDisplay) { int[] num_config = new int[1]; pEGL.EglChooseConfig(pEGLDisplay, this.mConfigSpec, null, 0, num_config); int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; pEGL.EglChooseConfig(pEGLDisplay, this.mConfigSpec, configs, numConfigs, num_config); EGLConfig config = this.chooseConfig(pEGL, pEGLDisplay, configs); if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
// =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== public override EGLConfig chooseConfig(EGL10 pEGL, EGLDisplay pEGLDisplay, EGLConfig[] pEGLConfigs) { EGLConfig closestConfig = null; int closestDistance = 1000; //for(final EGLConfig config : pEGLConfigs) { foreach (EGLConfig config in pEGLConfigs) { int r = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglRedSize, 0); int g = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglGreenSize, 0); int b = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglBlueSize, 0); int a = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglAlphaSize, 0); int d = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglDepthSize, 0); int s = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglStencilSize, 0); int distance = Math.Abs(r - this.mRedSize) + Math.Abs(g - this.mGreenSize) + Math.Abs(b - this.mBlueSize) + Math.Abs(a - this.mAlphaSize) + Math.Abs(d - this.mDepthSize) + Math.Abs(s - this.mStencilSize); if (distance < closestDistance) { closestDistance = distance; closestConfig = config; } } return closestConfig; }
public EGLConfig chooseConfig(EGL10 pEGL, EGLDisplay pEGLDisplay) { int[] num_config = new int[1]; pEGL.EglChooseConfig(pEGLDisplay, this.mConfigSpec, null, 0, num_config); int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; pEGL.EglChooseConfig(pEGLDisplay, this.mConfigSpec, configs, numConfigs, num_config); EGLConfig config = this.chooseConfig(pEGL, pEGLDisplay, configs); if (config == null) { throw new IllegalArgumentException("No config chosen"); } return(config); }
// =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== public override EGLConfig chooseConfig(EGL10 pEGL, EGLDisplay pEGLDisplay, EGLConfig[] pEGLConfigs) { EGLConfig closestConfig = null; int closestDistance = 1000; //for(final EGLConfig config : pEGLConfigs) { foreach (EGLConfig config in pEGLConfigs) { int r = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglRedSize, 0); int g = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglGreenSize, 0); int b = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglBlueSize, 0); int a = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglAlphaSize, 0); int d = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglDepthSize, 0); int s = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglStencilSize, 0); int distance = Math.Abs(r - this.mRedSize) + Math.Abs(g - this.mGreenSize) + Math.Abs(b - this.mBlueSize) + Math.Abs(a - this.mAlphaSize) + Math.Abs(d - this.mDepthSize) + Math.Abs(s - this.mStencilSize); if (distance < closestDistance) { closestDistance = distance; closestConfig = config; } } return(closestConfig); }
public void OnSurfaceCreated(Javax.Microedition.Khronos.Egl.EGLConfig config) { Log.Info(Tag, "onSurfaceCreated"); GLES20.GlClearColor(0.1f, 0.1f, 0.1f, 0.5f); // Dark background so text shows up well cubeVertices = PrepareBuffer(WorldLayoutData.CubeCoords); cubeColors = PrepareBuffer(WorldLayoutData.CubeColors); cubeFoundColors = PrepareBuffer(WorldLayoutData.CubeFoundColors); cubeNormals = PrepareBuffer(WorldLayoutData.CubeNormals); cubeTextureCoords = PrepareBuffer(WorldLayoutData.CubeTexCoords); floorVertices = PrepareBuffer(WorldLayoutData.FloorCoords); floorNormals = PrepareBuffer(WorldLayoutData.FloorNormals); floorColors = PrepareBuffer(WorldLayoutData.FloorColors); monkeyFound = LoadGlTexture(Resource.Drawable.texture2); monkeyNotFound = LoadGlTexture(Resource.Drawable.texture1); int vertexShader = LoadGlShader(GLES20.GlVertexShader, Resource.Raw.vertex); int gridShader = LoadGlShader(GLES20.GlFragmentShader, Resource.Raw.fragment); glProgram = GLES20.GlCreateProgram(); GLES20.GlAttachShader(glProgram, vertexShader); GLES20.GlAttachShader(glProgram, gridShader); GLES20.GlLinkProgram(glProgram); GLES20.GlEnable(GLES20.GlDepthTest); // Object first appears directly in front of user Matrix.SetIdentityM(modelCube, 0); Matrix.TranslateM(modelCube, 0, 0, 0, -mObjectDistance); Matrix.SetIdentityM(modelFloor, 0); Matrix.TranslateM(modelFloor, 0, 0, -mFloorDepth, 0); // Floor appears below user CheckGlError("onSurfaceCreated"); }
public void OnSurfaceCreated(Javax.Microedition.Khronos.Opengles.IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { // Set the background frame color GLES20.GlClearColor(0.0f, 0.0f, 0.0f, 1.0f); initTex(); mSTexture = new SurfaceTexture(hTex[0]); mSTexture.SetOnFrameAvailableListener(this); mCamera = Android.Hardware.Camera.Open(); try { mCamera.SetPreviewTexture(mSTexture); } catch (Exception ioe) { } GLES20.GlClearColor(0.0f, 0.0f, 0.0f, 1.0f); hProgram = loadShader(vss, fss); mTriangle = new Triangle(); }
private int[] VBOBuffers = new int[2]; //2 buffers for vertices and colors public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { const float edge = 1.0f; // X, Y, Z, float[] triangleVerticesData = { -1.5f, -0.25f, 0.0f, 0.5f, -0.25f, 0.0f, 0.0f, 0.559016994f, 0.0f }; FloatBuffer mTriangleVertices = ByteBuffer.AllocateDirect(triangleVerticesData.Length * mBytesPerFloat).Order(ByteOrder.NativeOrder()).AsFloatBuffer(); mTriangleVertices.Put(triangleVerticesData).Flip(); // R, G, B, A float[] triangleColorsData = { 1.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }; FloatBuffer mTriangleColors = ByteBuffer.AllocateDirect(triangleColorsData.Length * mBytesPerFloat).Order(ByteOrder.NativeOrder()).AsFloatBuffer(); mTriangleColors.Put(triangleColorsData).Flip(); //Use VBO GLES20.GlGenBuffers(2, VBOBuffers, 0); //2 buffers for vertices and colors GLES20.GlBindBuffer(GLES20.GlArrayBuffer, VBOBuffers[0]); GLES20.GlBufferData(GLES20.GlArrayBuffer, mTriangleVertices.Capacity() * mBytesPerFloat, mTriangleVertices, GLES20.GlStaticDraw); GLES20.GlBindBuffer(GLES20.GlArrayBuffer, VBOBuffers[1]); GLES20.GlBufferData(GLES20.GlArrayBuffer, mTriangleColors.Capacity() * mBytesPerFloat, mTriangleColors, GLES20.GlStaticDraw); GLES20.GlBindBuffer(GLES20.GlArrayBuffer, 0); GLES20.GlClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Position the eye behind the origin. float eyeX = 0.0f; float eyeY = 0.0f; float eyeZ = 4.5f; // We are looking toward the distance float lookX = 0.0f; float lookY = 0.0f; float lookZ = -5.0f; // Set our up vector. This is where our head would be pointing were we holding the camera. float upX = 0.0f; float upY = 1.0f; float upZ = 0.0f; // Set the view matrix. This matrix can be said to represent the camera position. // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose. Matrix.SetLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ); string vertexShader = "uniform mat4 u_MVPMatrix; \n" // A constant representing the combined model/view/projection matrix. + "attribute vec4 a_Position; \n" // Per-vertex position information we will pass in. + "attribute vec4 a_Color; \n" // Per-vertex color information we will pass in. + "varying vec4 v_Color; \n" // This will be passed into the fragment shader. + "void main() \n" // The entry point for our vertex shader. + "{ \n" + " v_Color = a_Color; \n" // Pass the color through to the fragment shader. It will be interpolated across the triangle. + " gl_Position = u_MVPMatrix \n" // gl_Position is a special variable used to store the final position. + " * a_Position; \n" // Multiply the vertex by the matrix to get the final point in normalized screen coordinates. + "} \n"; string fragmentShader = "precision mediump float; \n" // Set the default precision to medium. We don't need as high of a // precision in the fragment shader. + "varying vec4 v_Color; \n" // This is the color from the vertex shader interpolated across the triangle per fragment. + "void main() \n" // The entry point for our fragment shader. + "{ \n" + " gl_FragColor = v_Color; \n" // Pass the color directly through the pipeline. + "} \n"; int vertexShaderHandle = GLES20.GlCreateShader(GLES20.GlVertexShader); if (vertexShaderHandle != 0) { // Pass in the shader source. GLES20.GlShaderSource(vertexShaderHandle, vertexShader); // Compile the shader. GLES20.GlCompileShader(vertexShaderHandle); // Get the compilation status. int[] compileStatus = new int[1]; GLES20.GlGetShaderiv(vertexShaderHandle, GLES20.GlCompileStatus, compileStatus, 0); // If the compilation failed, delete the shader. if (compileStatus[0] == 0) { GLES20.GlDeleteShader(vertexShaderHandle); vertexShaderHandle = 0; } } if (vertexShaderHandle == 0) { throw new Exception("Error creating vertex shader."); } // Load in the fragment shader shader. int fragmentShaderHandle = GLES20.GlCreateShader(GLES20.GlFragmentShader); if (fragmentShaderHandle != 0) { // Pass in the shader source. GLES20.GlShaderSource(fragmentShaderHandle, fragmentShader); // Compile the shader. GLES20.GlCompileShader(fragmentShaderHandle); // Get the compilation status. int[] compileStatus = new int[1]; GLES20.GlGetShaderiv(fragmentShaderHandle, GLES20.GlCompileStatus, compileStatus, 0); // If the compilation failed, delete the shader. if (compileStatus[0] == 0) { GLES20.GlDeleteShader(fragmentShaderHandle); fragmentShaderHandle = 0; } } if (fragmentShaderHandle == 0) { throw new Exception("Error creating fragment shader."); } // Create a program object and store the handle to it. int programHandle = GLES20.GlCreateProgram(); if (programHandle != 0) { // Bind the vertex shader to the program. GLES20.GlAttachShader(programHandle, vertexShaderHandle); // Bind the fragment shader to the program. GLES20.GlAttachShader(programHandle, fragmentShaderHandle); // Bind attributes GLES20.GlBindAttribLocation(programHandle, 0, "a_Position"); GLES20.GlBindAttribLocation(programHandle, 1, "a_Color"); // Link the two shaders together into a program. GLES20.GlLinkProgram(programHandle); // Get the link status. int[] linkStatus = new int[1]; GLES20.GlGetProgramiv(programHandle, GLES20.GlLinkStatus, linkStatus, 0); // If the link failed, delete the program. if (linkStatus[0] == 0) { GLES20.GlDeleteProgram(programHandle); programHandle = 0; } } if (programHandle == 0) { throw new Exception("Error creating program."); } // Set program handles. These will later be used to pass in values to the program. mMVPMatrixHandle = GLES20.GlGetUniformLocation(programHandle, "u_MVPMatrix"); mPositionHandle = GLES20.GlGetAttribLocation(programHandle, "a_Position"); mColorHandle = GLES20.GlGetAttribLocation(programHandle, "a_Color"); // Tell OpenGL to use this program when rendering. GLES20.GlUseProgram(programHandle); }
// =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== public abstract EGLConfig chooseConfig(EGL10 pEGL, EGLDisplay pEGLDisplay, EGLConfig[] pEGLConfigs);
public void OnSurfaceCreated(IGL10 gl, EGLConfig config) { // throw new NotImplementedException(); }
public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) { NativeInit(IntPtr.Zero); }
public void OnSurfaceCreated(IGL10 gl, EGLConfig config) { FreeContext(); }
public void OnSurfaceCreated (IGL10 gl, EGLConfig config) { // throw new NotImplementedException(); }
public void OnSurfaceCreated(IGL10 gl, EGLConfig config) { }