void Material::Apply(const Resources& resources, u8 render_alpha, bool modulate_colors) const { // channel control and material color ApplyChannelControl(render_alpha, modulate_colors); // texture coordinates gen ApplyTexCoordGens(); // bind textures ApplyTextures(resources); for (u32 i = 0; i < 4; ++i) { // tev reg colors if(i < 3) GX_SetTevColorS10(GX_TEVREG0 + i, header->color_regs[i]); // tev k colors GX_SetTevKColor(GX_KCOLOR0 + i, header->color_constants[i]); } // tev swap colors ApplyTevSwapTable(); // tev stages ApplyTevStages(modulate_colors); // ind stages ApplyIndStages(); // alpha compare if(flags->alpha_compare) GX_SetAlphaCompare(alpha_compare->compare & 0xf, alpha_compare->ref0, alpha_compare->op, alpha_compare->compare >> 4, alpha_compare->ref1); else
void Material::Render(Model* modelObj, Transform* transform, Matrix& projectionMatrix, Matrix& viewMatrix) { if(modelObj != NULL) { ApplyShader(); ApplyAttributes(modelObj); ApplyUniforms(transform, projectionMatrix, viewMatrix); ApplyTextures(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelObj->mElementBuffer); int size; glGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_SIZE, &size); glDrawElements(GL_TRIANGLES, size/sizeof(GLushort), GL_UNSIGNED_SHORT, 0); DisableAttributes(); } }
//=========================================================================== /*virtual*/ bool Plane::CalculateSurfacePoint( const Scene::Ray& ray, const Scene& scene, Scene::SurfacePoint& surfacePoint ) const { double numerator = c3ga::lc( center - ray.point, normal ); double denominator = c3ga::lc( ray.direction, normal ); if( denominator == 0.0 ) return false; double lambda = numerator / denominator; if( lambda < 0.0 ) return false; surfacePoint.point = ray.CalculateRayPoint( lambda ); if( numerator < 0.0 ) surfacePoint.normal = normal; else surfacePoint.normal = -normal; surfacePoint.materialProperties = materialProperties; ApplyTextures( surfacePoint, scene.Eye() ); return true; }
void ApplyState(GLState state, ref_ptr<GpuProgram> program) { ApplyTextures(state, program); ApplyBlending(state, program); GLFunctions::glDepthFunc(state.GetDepthFunction()); }