Ejemplo n.º 1
0
        override public void draw(ref Geometry.Geometry g, ref Matrix4 model, ref Matrix4 vp)
        {
            // bind shader
            GL.Disable(EnableCap.DepthTest);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            mShader.bind();

            Matrix4 modelIT = model.Inverted();

            modelIT.Transpose();

            GL.Enable(EnableCap.Blend);
            mShader.uploadAttrib <int>("indices", g.mGeometryIndices.Length, 3, 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); // TODO: I literally hate this, but it was easier than patching Eric's code.
            }
            if (g.mNormals != null)
            {
                mShader.uploadAttrib <float>("normal", g.mNormals.Count(), 3, 4, VertexAttribPointerType.Float, false, ref g.mNormals, 0);
            }
            GL.Uniform1(mShader.uniform("alpha"), mAlpha);
            GL.ProgramUniformMatrix4(mShader.mProgramShader, mShader.uniform("viewProjTransform"), false, ref vp);
            GL.ProgramUniformMatrix4(mShader.mProgramShader, mShader.uniform("modelTransform"), true, ref model);
            GL.ProgramUniformMatrix4(mShader.mProgramShader, mShader.uniform("modelInvTrans"), true, ref modelIT);

            mShader.drawIndexed(g.primitiveType, 0, g.mNumPrimitives);
            GL.Disable(EnableCap.Blend);
            GL.Disable(EnableCap.DepthTest);
        }
Ejemplo n.º 2
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);
        }