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); }
protected virtual void OnInitDraw(/* final */ GL10 pGL) { GLHelper.SetColor(pGL, this.mRed, this.mGreen, this.mBlue, this.mAlpha); GLHelper.EnableVertexArray(pGL); GLHelper.BlendFunction(pGL, this.mSourceBlendFunction, this.mDestinationBlendFunction); }
public void UnloadFromHardware(GL10 pGL) { GLHelper.EnableTextures(pGL); this.DeleteTextureOnHardware(pGL); this.mHardwareTextureID = -1; this.mLoadedToHardware = false; if (this.mTextureStateListener != null) { this.mTextureStateListener.OnUnloadedFromHardware(this); } }
protected override void OnApplyVertices(/* final */ GL10 pGL) { if (GLHelper.EXTENSIONS_VERTEXBUFFEROBJECTS) { // TODO: Figure what the required conversion here is /* final */ GL11 gl11 = (GL11)pGL; this.GetVertexBuffer().SelectOnHardware(gl11); GLHelper.VertexZeroPointer(gl11); } else { GLHelper.VertexPointer(pGL, this.GetVertexBuffer().GetFloatBuffer()); } }
public void OnApplyMatrix(/* final */ GL10 pGL) { GLHelper.SetProjectionIdentityMatrix(pGL); //pGL.GlOrthof(this.getMinX(), this.getMaxX(), this.getMaxY(), this.getMinY(), this.mNearZ, this.mFarZ); pGL.GlOrthof(this.MinX, this.MaxX, this.MaxY, this.MinY, this.mNearZ, this.mFarZ); /* final */ float rotation = this.mRotation; if (rotation != 0) { //this.ApplyRotation(pGL, this.getCenterX(), this.getCenterY(), rotation); this.ApplyRotation(pGL, this.CenterX, this.CenterY, rotation); } }
private void WriteTextureToHardware(GL10 pGL) { bool preMultipyAlpha = this.mTextureOptions.mPreMultipyAlpha; //final ArrayList<TextureSourceWithLocation> textureSources = this.mTextureSources; List <TextureSourceWithLocation> textureSources = this.mTextureSources; int textureSourceCount = textureSources.Count; for (int j = 0; j < textureSourceCount; j++) { TextureSourceWithLocation textureSourceWithLocation = textureSources[j]; if (textureSourceWithLocation != null) { Bitmap bmp = textureSourceWithLocation.OnLoadBitmap(); try { if (bmp == null) { throw new IllegalArgumentException("TextureSource: " + textureSourceWithLocation.ToString() + " returned a null Bitmap."); } if (preMultipyAlpha) { GLUtils.TexSubImage2D(GL10Consts.GlTexture2d, 0, textureSourceWithLocation.GetTexturePositionX(), textureSourceWithLocation.GetTexturePositionY(), bmp, GL10Consts.GlRgba, GL10Consts.GlUnsignedByte); } else { GLHelper.GlTexSubImage2D(pGL, GL10Consts.GlTexture2d, 0, textureSourceWithLocation.GetTexturePositionX(), textureSourceWithLocation.GetTexturePositionY(), bmp, GL10Consts.GlRgba, GL10Consts.GlUnsignedByte); } bmp.Recycle(); } catch (IllegalArgumentException iae) { // TODO Load some static checkerboard or so to visualize that loading the texture has failed. Debug.E("Error loading: " + textureSourceWithLocation.ToString(), iae); if (this.mTextureStateListener != null) { this.mTextureStateListener.OnTextureSourceLoadExeption(this, textureSourceWithLocation.mTextureSource, iae); } else { throw iae; } } } } }
public void OnApply(GL10 pGL) { if (GLHelper.EXTENSIONS_VERTEXBUFFEROBJECTS) { GL11 gl11 = (GL11)pGL; this.mTextureRegionBuffer.SelectOnHardware(gl11); GLHelper.BindTexture(pGL, this.mTexture.GetHardwareTextureID()); GLHelper.TexCoordZeroPointer(gl11); } else { GLHelper.BindTexture(pGL, this.mTexture.GetHardwareTextureID()); GLHelper.TexCoordPointer(pGL, this.mTextureRegionBuffer.GetFloatBuffer()); } }
public void OnApplyCameraSceneMatrix(/* final */ GL10 pGL) { GLHelper.SetProjectionIdentityMatrix(pGL); /* final */ float width = this.mMaxX - this.mMinX; /* final */ float height = this.mMaxY - this.mMinY; pGL.GlOrthof(0, width, height, 0, this.mNearZ, this.mFarZ); /* final */ float cameraSceneRotation = this.mCameraSceneRotation; if (cameraSceneRotation != 0) { this.ApplyRotation(pGL, width * 0.5f, height * 0.5f, cameraSceneRotation); } }
public void LoadToHardware(GL10 pGL) { GLHelper.EnableTextures(pGL); this.mHardwareTextureID = Texture.GenerateHardwareTextureID(pGL); this.AllocateAndBindTextureOnHardware(pGL); this.ApplyTextureOptions(pGL); this.WriteTextureToHardware(pGL); this.mUpdateOnHardwareNeeded = false; this.mLoadedToHardware = true; if (this.mTextureStateListener != null) { this.mTextureStateListener.OnLoadedToHardware(this); } }
// =========================================================== // Methods // =========================================================== public void SelectOnHardware(GL11 pGL11) { int hardwareBufferID = this.mHardwareBufferID; if (hardwareBufferID == -1) { return; } GLHelper.BindBuffer(pGL11, hardwareBufferID); // TODO Does this always need to be binded, or are just for buffers of the same 'type'(texture/vertex)? if (this.mHardwareBufferNeedsUpdate) { // Debug.d("BufferObject.updating: ID = " + this.mHardwareBufferID); this.mHardwareBufferNeedsUpdate = false; //synchronized(this) { lock (_methodLock) { GLHelper.BufferData(pGL11, this.mFloatBuffer.mByteBuffer, this.mDrawType); } } }
private void DeleteTextureOnHardware(GL10 pGL) { GLHelper.DeleteTexture(pGL, this.mHardwareTextureID); }
private void AllocateAndBindTextureOnHardware(GL10 pGL) { GLHelper.BindTexture(pGL, this.mHardwareTextureID); Texture.SendPlaceholderBitmapToHardware(this.mWidth, this.mHeight); }
private void DeleteBufferOnHardware(GL11 pGL11) { GLHelper.DeleteBuffer(pGL11, this.mHardwareBufferID); }
protected override void OnInitDraw(GL10 pGL) { base.OnInitDraw(pGL); GLHelper.EnableTextures(pGL); GLHelper.EnableTexCoordArray(pGL); }