public virtual void delete(IRenderingEngine re) { if (drawBufferId != -1) { re.BufferManager.deleteBuffer(drawBufferId); drawBufferId = -1; } if (textureId != -1) { re.deleteTexture(textureId); textureId = -1; } }
public virtual void bind(IRenderingEngine re, bool forDrawing) { float viewportResizeScaleFactor = ViewportResizeScaleFactor; // Create the texture if not yet created or // re-create it if the viewport resize factor has been changed dynamically. if (textureId == -1 || viewportResizeScaleFactor != resizeScale) { // The pspsharp window has been resized. Recreate all the textures using the new size. if (textureId != -1) { re.deleteTexture(textureId); textureId = -1; } if (stencilTextureId != -1) { re.deleteTexture(stencilTextureId); stencilTextureId = -1; } if (stencilFboId != -1) { re.deleteFramebuffer(stencilFboId); stencilFboId = -1; } resizeScale = viewportResizeScaleFactor; if (useViewportResize) { texS = sceDisplay.getResizedWidth(width) / (float)TexImageWidth; texT = sceDisplay.getResizedHeight(height) / (float)TexImageHeight; } else { texS = width / (float)bufferWidth; texT = height / (float)heightPow2; } textureId = re.genTexture(); re.bindTexture(textureId); re.setTexImage(0, pixelFormat, TexImageWidth, TexImageHeight, pixelFormat, pixelFormat, 0, null); re.TextureMipmapMinFilter = TFLT_NEAREST; re.TextureMipmapMagFilter = TFLT_NEAREST; re.TextureMipmapMinLevel = 0; re.TextureMipmapMaxLevel = 0; re.setTextureWrapMode(TWRAP_WRAP_MODE_CLAMP, TWRAP_WRAP_MODE_CLAMP); if (drawBufferId == -1) { drawBufferId = re.BufferManager.genBuffer(pspsharp.graphics.RE.IRenderingEngine_Fields.RE_ARRAY_BUFFER, pspsharp.graphics.RE.IRenderingEngine_Fields.RE_FLOAT, 16, pspsharp.graphics.RE.IRenderingEngine_Fields.RE_DYNAMIC_DRAW); } } else { re.bindTexture(textureId); } if (forDrawing) { re.setTextureFormat(pixelFormat, false); } }