Esempio n. 1
0
 private void prepareWriters()
 {
     fbAddress    = getTextureAddress(fbp, prim.pxMin, prim.pyMin, fbw, psm);
     depthAddress = getTextureAddress(zbp, prim.pxMin, prim.pyMin, zbw, depthBufferPixelFormat);
     if (!RendererTemplate.isRendererWriterNative(RuntimeContext.MemoryInt, psm))
     {
         rendererWriter = RendererWriter.getRendererWriter(fbAddress, fbw, psm, depthAddress, zbw, depthBufferPixelFormat, needDestinationDepthRead, needDepthWrite);
     }
     imageWriterSkipEOL = fbw - prim.destinationWidth;
     depthWriterSkipEOL = zbw - prim.destinationWidth;
 }
Esempio n. 2
0
        public virtual RendererTemplate getCompiledRenderer(BasePrimitiveRenderer renderer, LongLongKey id, GeContext context)
        {
            RendererTemplate compiledRenderer = compiledRenderers[id];

            if (compiledRenderer == null)
            {
                compiledRenderer = compileRenderer(renderer, id, context);
                if (compiledRenderer != null)
                {
                    compiledRenderers[id] = compiledRenderer;
                }
            }

            return(compiledRenderer);
        }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
        private RendererTemplate compileRenderer(BasePrimitiveRenderer renderer, LongLongKey id, GeContext context)
        {
            if (log.InfoEnabled)
            {
                Console.WriteLine(string.Format("Compiling Renderer {0}", id));
            }

            Dictionary <string, object> variables = new Dictionary <string, object>();

            // All these variables have to be defined as static members in the class RendererTemplate.
            variables["hasMemInt"]                = Convert.ToBoolean(RuntimeContext.hasMemoryInt());
            variables["transform2D"]              = Convert.ToBoolean(renderer.transform2D);
            variables["clearMode"]                = Convert.ToBoolean(renderer.clearMode);
            variables["clearModeColor"]           = Convert.ToBoolean(context.clearModeColor);
            variables["clearModeStencil"]         = Convert.ToBoolean(context.clearModeStencil);
            variables["clearModeDepth"]           = Convert.ToBoolean(context.clearModeDepth);
            variables["needSourceDepthRead"]      = Convert.ToBoolean(renderer.needSourceDepthRead);
            variables["needDestinationDepthRead"] = Convert.ToBoolean(renderer.needDestinationDepthRead);
            variables["needDepthWrite"]           = Convert.ToBoolean(renderer.needDepthWrite);
            variables["needTextureUV"]            = Convert.ToBoolean(renderer.needTextureUV);
            variables["simpleTextureUV"]          = Convert.ToBoolean(renderer.simpleTextureUV);
            variables["swapTextureUV"]            = Convert.ToBoolean(renderer.swapTextureUV);
            variables["needScissoringX"]          = Convert.ToBoolean(renderer.needScissoringX);
            variables["needScissoringY"]          = Convert.ToBoolean(renderer.needScissoringY);
            variables["nearZ"] = new int?(renderer.nearZ);
            variables["farZ"]  = new int?(renderer.farZ);
            variables["colorTestFlagEnabled"]   = Convert.ToBoolean(context.colorTestFlag.Enabled);
            variables["colorTestFunc"]          = new int?(context.colorTestFunc);
            variables["alphaTestFlagEnabled"]   = Convert.ToBoolean(context.alphaTestFlag.Enabled);
            variables["alphaFunc"]              = new int?(context.alphaFunc);
            variables["alphaRef"]               = new int?(context.alphaRef);
            variables["alphaMask"]              = new int?(context.alphaMask);
            variables["stencilTestFlagEnabled"] = Convert.ToBoolean(context.stencilTestFlag.Enabled);
            variables["stencilFunc"]            = new int?(context.stencilFunc);
            variables["stencilOpFail"]          = new int?(context.stencilOpFail);
            variables["stencilOpZFail"]         = new int?(context.stencilOpZFail);
            variables["stencilOpZPass"]         = new int?(context.stencilOpZPass);
            variables["stencilRef"]             = new int?(context.stencilRef);
            variables["depthTestFlagEnabled"]   = Convert.ToBoolean(context.depthTestFlag.Enabled);
            variables["depthFunc"]              = new int?(context.depthFunc);
            variables["blendFlagEnabled"]       = Convert.ToBoolean(context.blendFlag.Enabled);
            variables["blendEquation"]          = new int?(context.blendEquation);
            variables["blendSrc"]               = new int?(context.blend_src);
            variables["blendDst"]               = new int?(context.blend_dst);
            variables["sfix"] = new int?(context.sfix);
            variables["dfix"] = new int?(context.dfix);
            variables["colorLogicOpFlagEnabled"] = Convert.ToBoolean(context.colorLogicOpFlag.Enabled);
            variables["logicOp"]                 = new int?(context.logicOp);
            variables["colorMask"]               = new int?(PixelColor.getColor(context.colorMask));
            variables["depthMask"]               = Convert.ToBoolean(context.depthMask);
            variables["textureFlagEnabled"]      = Convert.ToBoolean(context.textureFlag.Enabled);
            variables["useVertexTexture"]        = Convert.ToBoolean(renderer.useVertexTexture);
            variables["lightingFlagEnabled"]     = Convert.ToBoolean(context.lightingFlag.Enabled);
            variables["sameVertexColor"]         = Convert.ToBoolean(renderer.sameVertexColor);
            variables["setVertexPrimaryColor"]   = Convert.ToBoolean(renderer.setVertexPrimaryColor);
            variables["primaryColorSetGlobally"] = Convert.ToBoolean(renderer.primaryColorSetGlobally);
            variables["isTriangle"]              = Convert.ToBoolean(renderer.isTriangle);
            variables["matFlagAmbient"]          = Convert.ToBoolean((context.mat_flags & CMAT_FLAG_AMBIENT) != 0);
            variables["matFlagDiffuse"]          = Convert.ToBoolean((context.mat_flags & CMAT_FLAG_DIFFUSE) != 0);
            variables["matFlagSpecular"]         = Convert.ToBoolean((context.mat_flags & CMAT_FLAG_SPECULAR) != 0);
            variables["useVertexColor"]          = Convert.ToBoolean(context.useVertexColor);
            variables["textureColorDoubled"]     = Convert.ToBoolean(context.textureColorDoubled);
            variables["lightMode"]               = new int?(context.lightMode);
            variables["texMapMode"]              = new int?(context.tex_map_mode);
            variables["texProjMapMode"]          = new int?(context.tex_proj_map_mode);
            variables["texTranslateX"]           = new float?(context.tex_translate_x);
            variables["texTranslateY"]           = new float?(context.tex_translate_y);
            variables["texScaleX"]               = new float?(context.tex_scale_x);
            variables["texScaleY"]               = new float?(context.tex_scale_y);
            variables["texWrapS"]                = new int?(context.tex_wrap_s);
            variables["texWrapT"]                = new int?(context.tex_wrap_t);
            variables["textureFunc"]             = new int?(context.textureFunc);
            variables["textureAlphaUsed"]        = Convert.ToBoolean(context.textureAlphaUsed);
            variables["psm"]                  = new int?(context.psm);
            variables["texMagFilter"]         = new int?(context.tex_mag_filter);
            variables["needTextureWrapU"]     = Convert.ToBoolean(renderer.needTextureWrapU);
            variables["needTextureWrapV"]     = Convert.ToBoolean(renderer.needTextureWrapV);
            variables["needSourceDepthClamp"] = Convert.ToBoolean(renderer.needSourceDepthClamp);
            variables["isLogTraceEnabled"]    = Convert.ToBoolean(renderer.isLogTraceEnabled);
            variables["collectStatistics"]    = Convert.ToBoolean(DurationStatistics.collectStatistics);
            variables["ditherFlagEnabled"]    = Convert.ToBoolean(context.ditherFlag.Enabled);

            string           specializedClassName = NewCompiledRendererClassName;
            ClassSpecializer cs = new ClassSpecializer();
            Type             specializedClass = cs.specialize(specializedClassName, typeof(RendererTemplate), variables);
            RendererTemplate compiledRenderer = null;

            if (specializedClass != null)
            {
                try
                {
                    compiledRenderer = (RendererTemplate)System.Activator.CreateInstance(specializedClass);
                }
                catch (InstantiationException e)
                {
                    Console.WriteLine("Error while instanciating compiled renderer", e);
                }
                catch (IllegalAccessException e)
                {
                    Console.WriteLine("Error while instanciating compiled renderer", e);
                }
            }

            return(compiledRenderer);
        }