protected internal virtual void copy(BaseRenderer from) { imageWriterSkipEOL = from.imageWriterSkipEOL; depthWriterSkipEOL = from.depthWriterSkipEOL; compiledRendererKey = from.compiledRendererKey; compiledRenderer = from.compiledRenderer; lighting = from.lighting; textureAccess = from.textureAccess; transform2D = from.transform2D; nearZ = from.nearZ; farZ = from.farZ; scissorX1 = from.scissorX1; scissorY1 = from.scissorY1; scissorX2 = from.scissorX2; scissorY2 = from.scissorY2; cachedTexture = from.cachedTexture; isTriangle = from.isTriangle; colorTestRef = from.colorTestRef; colorTestMsk = from.colorTestMsk; alphaRef = from.alphaRef; alphaMask = from.alphaMask; stencilRef = from.stencilRef; stencilMask = from.stencilMask; sfix = from.sfix; dfix = from.dfix; colorMask = from.colorMask; primaryColorSetGlobally = from.primaryColorSetGlobally; texTranslateX = from.texTranslateX; texTranslateY = from.texTranslateY; texScaleX = from.texScaleX; texScaleY = from.texScaleY; textureWidth = from.textureWidth; textureHeight = from.textureHeight; texEnvColorB = from.texEnvColorB; texEnvColorG = from.texEnvColorG; texEnvColorR = from.texEnvColorR; envMapLightPosU = from.envMapLightPosU; envMapLightPosV = from.envMapLightPosV; envMapDiffuseLightU = from.envMapDiffuseLightU; envMapDiffuseLightV = from.envMapDiffuseLightV; envMapShininess = from.envMapShininess; texMinFilter = from.texMinFilter; texMagFilter = from.texMagFilter; primaryColor = from.primaryColor; ditherMatrix = from.ditherMatrix; }
protected internal virtual void initRendering(GeContext context) { if (renderingInitialized) { return; } fbp = getFrameBufferAddress(context.fbp); psm = context.psm; zbp = getFrameBufferAddress(context.zbp); colorTestRef = getColorBGR(context.colorTestRef); colorTestMsk = getColorBGR(context.colorTestMsk); alphaRef = context.alphaRef & context.alphaMask; alphaMask = context.alphaMask; stencilRef = context.stencilRef & context.stencilMask; stencilMask = context.stencilMask; sfix = context.sfix; dfix = context.dfix; colorMask = getColor(context.colorMask); textureWidth = context.texture_width[mipmapLevel]; textureHeight = context.texture_height[mipmapLevel]; texEnvColorB = getColor(context.tex_env_color[2]); texEnvColorG = getColor(context.tex_env_color[1]); texEnvColorR = getColor(context.tex_env_color[0]); texMinFilter = context.tex_min_filter; texMagFilter = context.tex_mag_filter; primaryColor = getColor(context.vertexColor); baseRendererKey = getBaseRendererKey(context); if (!transform2D && context.lightingFlag.Enabled) { lighting = new Lighting(context.view_uploaded_matrix, context.mat_emissive, context.ambient_light, context.lightFlags, context.light_pos, context.light_kind, context.light_type, context.lightAmbientColor, context.lightDiffuseColor, context.lightSpecularColor, context.lightConstantAttenuation, context.lightLinearAttenuation, context.lightQuadraticAttenuation, context.spotLightCutoff, context.spotLightCosCutoff, context.light_dir, context.spotLightExponent, context.materialShininess, context.lightMode, context.vinfo.normal != 0); } // Is the lighting model using the material color from the vertex color? if (!transform2D && context.lightingFlag.Enabled && context.mat_flags != 0 && context.useVertexColor && context.vinfo.color != 0 && isTriangle) { setVertexPrimaryColor = true; } primaryColorSetGlobally = false; if (transform2D || !context.lightingFlag.Enabled) { // No lighting, take the primary color from the vertex. // This will be done by the BasePrimitiveRenderer when the vertices are known. if (context.useVertexColor && context.vinfo.color != 0) { setVertexPrimaryColor = true; if (!isTriangle) { // Use the color of the 2nd sprite vertex primaryColorSetGlobally = true; } } else { // Use context.vertexColor as the primary color primaryColorSetGlobally = true; } } textureAccess = null; if (isUsingTexture(context)) { int textureBufferWidth = VideoEngine.alignBufferWidth(context.texture_buffer_width[mipmapLevel], context.texture_storage); int textureHeight = context.texture_height[mipmapLevel]; int textureAddress = context.texture_base_pointer[mipmapLevel]; if (cachedTexture == null) { int[] clut32 = VideoEngine.Instance.readClut32(mipmapLevel); short[] clut16 = VideoEngine.Instance.readClut16(mipmapLevel); // Always request the whole buffer width IMemoryReader imageReader = ImageReader.getImageReader(textureAddress, textureBufferWidth, textureHeight, textureBufferWidth, context.texture_storage, context.texture_swizzle, context.tex_clut_addr, context.tex_clut_mode, context.tex_clut_num_blocks, context.tex_clut_start, context.tex_clut_shift, context.tex_clut_mask, clut32, clut16); textureAccess = new RandomTextureAccessReader(imageReader, textureBufferWidth, textureHeight); } else { textureAccess = cachedTexture.OriginalTexture; } // Avoid an access outside the texture area textureAccess = TextureClip.getTextureClip(context, mipmapLevel, textureAccess, textureBufferWidth, textureHeight); } renderingInitialized = true; }
public TextureClipWidth(IRandomTextureAccess textureAccess, int width) { this.textureAccess = textureAccess; this.width = width; }
public static IRandomTextureAccess getTextureClip(GeContext context, int mipmapLevel, IRandomTextureAccess textureAccess, int width, int height) { bool needClipWidth = false; bool needClipHeight = false; // No need to clip width if it will be wrapped with "repeat" mode on the required width if (context.tex_wrap_s != TWRAP_WRAP_MODE_REPEAT || context.texture_width[mipmapLevel] > width) { needClipWidth = true; } // No need to clip height if it will be wrapped with "repeat" mode on the required height if (context.tex_wrap_t != TWRAP_WRAP_MODE_REPEAT || context.texture_height[mipmapLevel] > height) { needClipHeight = true; } if (needClipWidth) { if (needClipHeight) { textureAccess = new TextureClipWidthHeight(textureAccess, width, height); } else { textureAccess = new TextureClipWidth(textureAccess, width); } } else { if (needClipHeight) { textureAccess = new TextureClipHeight(textureAccess, height); } } return(textureAccess); }
public TextureClipWidthHeight(IRandomTextureAccess textureAccess, int width, int height) { this.textureAccess = textureAccess; this.width = width; this.height = height; }
public TextureClipHeight(IRandomTextureAccess textureAccess, int height) { this.textureAccess = textureAccess; this.height = height; }