Ejemplo n.º 1
0
        public override void draw(ref Geometry.Geometry g, ref Matrix4 model, ref Matrix4 vp)
        {
            UtilOld.depthSort(model * vp, g);
            GL.Disable(EnableCap.DepthTest);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Enable(EnableCap.Blend);
            Matrix4 modelIT = model.Inverted();

            modelIT.Transpose();
            int dim;

            if (g.primitiveType == BeginMode.Lines)
            {
                dim = 2;
            }
            else
            {
                dim = 3;
            }
            mShader.bind();
            mShader.uploadAttrib <int>("indices", g.mGeometryIndices.Length, dim, 4, VertexAttribPointerType.UnsignedInt, false, ref g.mGeometryIndices, 0);
            mShader.uploadAttrib <float>("position", g.mGeometry.Count(), 3, 4, VertexAttribPointerType.Float, false, ref g.mGeometry, 0);
            if (g.mNormals == null)
            {
                Math.addNormalsToMesh(g);
            }
            if (g.mNormals != null)
            {
                mShader.uploadAttrib <float>("normal", g.mNormals.Count(), 3, 4, VertexAttribPointerType.Float, false, ref g.mNormals, 0);
            }
            GL.Uniform4(mShader.uniform("color"), mColor);
            GL.UniformMatrix4(mShader.uniform("modelTransform"), true, ref model);
            GL.UniformMatrix4(mShader.uniform("viewProjTransform"), false, ref vp); // TODO: Fix this

            GL.ProgramUniformMatrix4(mShader.mProgramShader, mShader.uniform("modelInvTrans"), true, ref modelIT);
            GL.Uniform3(mShader.uniform("lightInt"), 3 * MAX_LIGHT_COUNT, ref lightIntensities[0].X);
            GL.Uniform3(mShader.uniform("lightPos"), 3 * MAX_LIGHT_COUNT, ref lightPositions[0].X);
            mShader.drawIndexed(g.primitiveType, 0, g.mNumPrimitives);
            GL.Disable(EnableCap.Blend);
            GL.Enable(EnableCap.DepthTest);
        }